PDA

View Full Version : Rendering Contour Lines



Richard145
11-21-2006, 12:01 PM
Please Help,

I am still pretty new to OpenGL and have a question regarding the rendering of contour lines.

I have a text file with X, Y, and Z coordinates that I have been successful at rendering in OpenGL - however, now I would like to place over that drawn image a series of contour-lines. I have another text file that is made up of node numbers (where each node is a single X, Y, and Z coordinate and represents a Point in the original image) and what I would like to do is lay those nodes as contour lines over the previous image.

Since all this is still fairly new to me, can anyone point me in the right direction to solve this in the most efficient manner?

Thanks for any help.

ZbuffeR
11-21-2006, 12:54 PM
Not sure if I got your question right, but you may simply draw GL_LINES using the node coordinates, on top of your geometry ?

You may get precision issues, in this case go for polygon offset, go for the example and FAQ here :
http://www.opengl.org/resources/faq/technical/source.htm

Richard145
11-21-2006, 01:16 PM
Thank you for the response ZbuffeR.

I appologize for the ambiguousness of the question. I will try to specify the question better.

The original image is being displayed as a set of Triangles and the points correspond directly to the contour-plot file.

The extra file that I want to be interpreted as a contour-plot is defined as a set of nodes/points that have been "filled/solved" at any given time step. For example, at time step N - there are two nodes (each with an X, Y, and Z coordinate) that have been "filled". At time step N + 1 - there are the two previous nodes plus some new random number of nodes. Even though, the nodes can map directly to those of the original file (being shown through OpenGL) - only those that have been "filled" are listed at any given time step.

The idea is to show fluid flow at each time step as a "smooth" line of progression. I tried mapping GL_LINE over the existing image but the result is not smooth at all - kind of disconnected.

Does anyone have any suggestions or hints as to how to approach this? Being new to OpenGL, I hope that there is a simple/quick library call I could use, but maybe not.

Thanks in advance

ZbuffeR
11-21-2006, 02:39 PM
If you want your line to smoothly grow, you simply need to interpolate linearly between previous end node and next end node.

Search for "Lerp" on wikipedia. It is very simple.

Richard145
11-22-2006, 03:31 AM
Thank you ZbuffeR. I will definately look into Lerp.