Jump to content
  • Advertisement
Sign in to follow this  

[mdx] Help adding Tangent to my custom vertex definition

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

Hi, I'm trying to add the Tangent vector to my custom vertex definition. My custom vertex structure looks like this: struct MeshVertex { public Vector3 Position; public Vector3 Normal; public Vector3 Tangent; public int Color; public float Tu; public float Tv; } And I load my mesh files like this: Mesh m = tempMesh.Clone(MeshFlags.SystemMemory, VertexFormats.Position | VertexFormats.Normal | VertexFormats.Tangent | VertexFormats.Diffuse | VertexFormats.Texture1 , d); The problem is, VertexFormats.Tangent does not exist... Is there something I can put in it's place? Thanks, David

Share this post

Link to post
Share on other sites
I figured it out :)

VertexElement[] elements = new VertexElement[]
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
new VertexElement(0, 20, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
new VertexElement(0, 32, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
new VertexElement(0, 44, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),

VertexDeclaration decl = new VertexDeclaration(d, elements);
Mesh m = tempMesh.Clone(MeshFlags.Managed, elements, d);

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!