PDA

View Full Version : height field terrain



incus
04-13-2003, 07:46 PM
i am using a height field to create a terrain. i want the camera to follow the different y values of the x,y,z's so that it appears that u r running along the terrain. i thought if i just took my x and zs and looked them up in the array of points i would have the height but it didnt work does anyone have any ideas about how i can do this

jwatte
04-13-2003, 08:55 PM
http://www.vterrain.org/ has lots of code.

Your question has nothing to do with OpenGL; it's a simple computational geometry problem.

incus
04-13-2003, 09:38 PM
yeah i know it doesnt have much to do with opengl but i didnt know where else to go i checked out that site but couldnt find any programs that would help me out. anymore help is appreciated incus

tfpsly
04-14-2003, 02:58 AM
1) found the 4 points in the heighmap that are arount the camera (the camera posdition will rarely be exatcty on a pixel of the heighmap).
2) interpolate

nomad82
04-14-2003, 04:04 AM
www.gametutorials.com (http://www.gametutorials.com)

look into the heightmap tutorials...when you run their program, the camera adjusts to the height of the terrain (which is what i understood you wanted to happen... http://www.opengl.org/discussion_boards/ubb/smile.gif )

-------------------------- http://nomad.openglforums.com

jwatte
04-14-2003, 08:12 AM
If you allow steep hills, your camera near plane may still intersect hill sides.

Thus, what you REALLY want is a function to sink a sphere of some radius onto a height field, until it collides with the field (which doesn't have to be straight under the sphere center). This is a collision detection problem; sphere-triangle intersections will do this but there are possible optimizations.
http://www.codercorner.com/Opcode.htm
http://www.magic-software.com/Intersection3D.html