PDA

View Full Version : opengl -- displaying contours on 3D terrain.



cutting_crew
12-13-2004, 10:50 AM
hi all...

i have some terrain that i have drawn using triangle strips and now i need to plot 2D contours onto the surface. i have discovered something called marching cubes but it is hard to understand(the very few examples that i have found) and most of them are old and seem to be outdated. is there another way to plot 2D contours? i already have my terrain colormapped, a deep blue to a light blue with light blue representing the highest points of the terrain and the deep blue the lowest points. where do i (should i) go from here? thanks all in advance for your help..

gmeed
12-13-2004, 11:03 AM
What are 2d contours?

(Since this is the advanced forum, I'm assuming you're not just asking about the basic contours explained in the red book.)

cutting_crew
12-13-2004, 11:28 AM
http://cluster.space.swri.edu/Contour.html

this image is what i would like to do. my terrain is 3D and i guess my contours would be 3D too.. sorry for the confusion -- thanks for your patience..

SeskaPeel
12-13-2004, 11:53 AM
Is your problem about computing or rendering these contours ?
Answer #1 -> this is not opengl related so you're not in the right place ot ask
Answer #2 -> well ... use GL_LINES mode

SeskaPeel.

gmeed
12-13-2004, 11:54 AM
Oops, I guess you had it right. I just assumed the contours were were called 1d contours since they only depend on one variable - the height of the terrain.

One way to do this is to set up texcoord generation for a 1d texture, with the texcoord dependent only on z. Then you create a 1d texture that holds a view of your contour line (eg-an empty texture except for a thin band at one end), and map it to your terrain with texcoord wrapping enabled so you don't get just the first contour above z=0.

You mentioned you're coloring the terrain based on its height. This method is probably the fastest way to do that, too. Just use your color gradient as the 1d texture.

If this doesn't make much sense, search for "creating contours" here (http://rush3d.com/reference/opengl-redbook-1.1/chapter09.html) (chapter 9 of the red book).

rgpc
12-13-2004, 04:21 PM
I would think that using a 1D texture and setting the texcoords for each vertex according to the altitude of the terrain would do exactly what you want - but that seems too much like a basic solution to me.

zed
12-13-2004, 04:43 PM
use a 1d texture and then use auto texture generation to generate the coordinates based on the height
most recent photo i stuck up is what i assume what u want, im using a shader here but the effect can be easily achieved with like i said auto texture generation
http://uk.geocities.com/sloppyturds/nelson/richmond.html