Advertisement

How to get the Heigth of a point in a triangle

Started by October 10, 2002 06:34 AM
-1 comments, last by Lupson 22 years, 4 months ago
Hi everyone. Sorry for this long post, but Im soo stuck. Im working on a little hobby projekt primarily consisting of an landscape rendering 3D-engine. So far it looks quite allright but now I wanna place Objects accuratly on the ground. The terrain mesh is draw using triangles. Each triangle is stored in an node in a linked list with x,y,z vertex data, normal data and a pointer to the next node in the list. The heigth data comes from a 512*512 Heigthmap. When building the mesh I use a "STEP_SIZE" (relic from NeHe tut35) for deciding how large each triangle should be in the x and z axises. (y is vertical). Since i use a STEP_SIZE, the terrain mesh resolution is more sparse than the resolution of the heigthmap which makes it impossible to just use heigthmap data for any given x,z point. So my idea was to "snap-to-grid", which means calculate the given x,z points difference down to the nearest lower grid-size. (If STEP_SIZE = 6, x=27.45,z=63.54: xdiff is 27.45-24 and zdiff is 63.54-60, ie: 3.45 and 3.54) The next step is to retrieve the y-data for the four points that encloses the given x,z point, i.e. lowerleft, topleft, bottomright and topright. But what to do next? I've tried two approaches but neither work correctly. I get bad jumping when crossing triangle boundaries and neither gives me terrain following that is accurate enough. You can check out some screenshots that might help visualizing the terrain system at: here [edited by - Lupson on October 10, 2002 7:35:51 AM]

This topic is closed to new replies.

Advertisement