Object's following terrain contours?,
Members - Reputation: 180
Posted 01 October 2001 - 06:51 PM
Members - Reputation: 158
Posted 02 October 2001 - 02:59 AM
One way is interpolating between terrain triangle vertices to find your altitude (I''m assuming Y). Of course, you must know what triangle you''re "on top" of, which should be easy if the terrain is laid in a grid pattern.
A second way that I have used is using the plane equation of each terrain triangle. Then, given the X and Z of your object''s position, you can figure the Y from the plane equation.
If you want full physics, with gravity, and friction playing on your object, well, then it''s going to get a lot more complicated.
The NeHe Game Development forum on this website will have a lot more information about terrain following.
Hope this helps
Posted 04 October 2001 - 04:03 AM
First, you need to calculate the height of the terrain below points at the front and back of your vehicle (the previous reply has suggested how this can be done). This will allow you to work out the angle that the vehicle needs to be rotated about a horizontal axis to be aligned with the terrain. The component of gravity in the direction that the vehicle is now pointing is given by g.sin(T), where g is the standard acceleration due to gravity and T is the angle between the vehicle in its new alignment and the horizontal.