Jump to content
  • Advertisement
Sign in to follow this  

adding tangents to a model

This topic is 3918 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

ive loaded a model from an .x file to a LPD3DXMESH using "d3dMesh.h"... however the mesh doesnt have tangents... which could add with the "SetVertexDecl" function... but i have to change the vertex declaration for that... how would i add an entry at the end of the vertex declaration without changing the others?

Share this post

Link to post
Share on other sites
This is the general procedure I use for the rare occasion where I load .X meshes, its basically taken straight from the SDK samples:

-Load the mesh from the .X file
-Check the vertex declaration from the mesh, see if it contains normals/tangents/binormals
-If they're not there, create a new vertex declaration containing all of those things
-Clone the mesh with the new vertex declaration (using ID3DXBaseMesh::CloneMesh)
-If necessary, use D3DXComputeNormals to compute the normals
-If necessary, use D3DXComputeTangentFrame or D3DXComputeTangentFrameEx to compute the tangents and binormals
-Make sure to release the old mesh

I don't remember which sample exactly used this process...I think it was the ParallaxOcclusionMapping sample.

As for adding entries to the old declaration, I would suppose you would loop through the old declaration and copy the entries to your new declaration until you got to the end. Then, you could add an entry to the new declaration at the next index with the Offset set according to the last entry in the old declaration.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!