Sign in to follow this  
michaelbeirne

Terrain Normal

Recommended Posts

Is there a way to use D3DXIntersect or D3DXIntersectTri to work out the normals of a terrain surface? My terrain is loaded from a .x file not a height map, and i am trying to make units in a 3d rts game follow the terrain surface. Thanks.

Share this post


Link to post
Share on other sites
Not really.
When you found the tri with which your unit is colliding, you need to compute (or retrieve if you pre-computed all the normals) the triangle's normal yourself.

Share this post


Link to post
Share on other sites
Quote:
Original post by michaelbeirne
how do you do that?

D3DXVECTOR3 v1cross(vertex2 - vertex1);
D3DXVECTOR3 v2cross(vertex1 - vertex0);

D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &v1cross, &v2cross);



kp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this