• Advertisement
Sign in to follow this  

Terrain Normal

This topic is 4362 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Quote:
Original post by michaelbeirne
How do u access the verticies in the first lace?
You use ID3DXMEsh::LockVertexBuffer(). See the DX SDK docs for details!

kp

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement