Jump to content
  • Advertisement
Sign in to follow this  
tokaplan

D3DXComputeTangent fails

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

D3DXComputeTangent fails on the mesh. I am sure that vertex declaration is correct; I took the working sample which uses D3DXComputeTangent, and after substituting its simple sphere model for more complicated mesh, D3DXComputeTangent starts to fail. Obviously, the problem is in the mesh itself and I wonder if anything can be done about it. I use MAX + Panda to export the mesh into X format. Thank you

Share this post


Link to post
Share on other sites
Advertisement
Hi there Tokaplan, how are you doing?

[The Problem]
D3DXComputeTangent is failing?

[The Solution]
Why don't you try D3DXComputeTangentFrame()?
What is the difference between the 2?

D3DXComputeTangent:
"Computes the tangent vectors for the texture coordinates given in the texture stage. Provided to support legacy applications. Use D3DXComputeTangentFrameEx for better results."

D3DXComputeTangentFrame:
"Compute tangent, binormal, and normal vectors for a mesh."

e.g.
[source lang = "c#"]
//load the mesh
mesh = Mesh.FromFile(meshFilename, MeshFlags.Managed, device);

//Vertex elements that describe the new format of the mesh
VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
new VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
new VertexElement(0, 36, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
new VertexElement(0, 48, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.BiNormal, 0),
VertexElement.VertexDeclarationEnd,
};
VertexDeclaration decl = new VertexDeclaration(device, elements);
Mesh tempMesh = mesh.Clone(MeshFlags.Managed, elements, device);
mesh.Dispose();
mesh = tempMesh;

/* Performs tangent frame computations on a mesh. Tangent, binormal, and optionally normal vectors are generated.
* Singularities are handled as required by grouping edges and splitting vertices.
*/

mesh.ComputeTangentFrame(0);




I hope this helps a bit.

Keep cool.

Share this post


Link to post
Share on other sites
I've tried D3DXCleanMesh, but it fails on my mesh as well! It returns D3DERR_INVALIDCALL (not much information indeed, it can only return this and E_OUTOFMEMORY). As for D3DXComputeTangentFrame, I'm using DX SDK 9.0b, and the compiler tells me there is no such function in this version of DX SDK.

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!