Sign in to follow this  
Hannesnisula

Accessing face normals in D3DXMESH etc

Recommended Posts

Hannesnisula    1126
I'm working on some kind of collision detection and I need the face normals to calculate the new vectors etc but I have no clue how to get the face normals from the D3DXMESH class. There's a D3DX function called D3DXIntersect which returns the face of the mesh that the ray hit. How could I then (if I can access the face normals somehow) get the face's normal when I've got it's indexnumber? I'm thinking about creating my own intersection function but I don't know how to check if the ray intersects with the world (since it has no bounding box/sphere w/e) even though I've got a pretty good idea how to do it with bounding spheres/boxes.

Share this post


Link to post
Share on other sites
_moagstar_    465
The face normals aren't stored in the D3DXMESH structure, you'll have to calculate them yourself I'm afraid. You can access the triangle information using the vertex and index buffers in order calculate the face normal.

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