akuehn3000 Posted April 27, 2004 Posted April 27, 2004 Hello everyone, what´s the best way to set up a vertexbuffer that should support multiple texture coordinates? I tried the following: public struct MyVertex { public float X,Y,Z; public float Nx,Ny,Nz; public float Tu,Tv; public float Tu1,Tv1; } VertexElement[] decl = 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.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0 ), new VertexElement( 0,32, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0 ), VertexElement.VertexDeclarationEnd }; VertexDeclaration ourDeclaration = new VertexDeclaration(device, decl); device.VertexFormat = VertexFormats.Position | VertexFormats.Normal | VertexFormats.Texture0 | VertexFormats.Texture1; VertexFormats bufferFormat = device.VertexFormat; device.VertexDeclaration = ourDeclaration; But I get an error when trying instantiate the VertexDeclaration. Any ideas what´s wrong or how it could be done better? Quote
rifter1818 Posted April 27, 2004 Posted April 27, 2004 Could be that the usage for both Texture coordinants are the same,... try new vertexelement(.....,texturecoordinant,0) and new vertexelement(.....texturecoordinant,1) for those two in the dec. Quote
akuehn3000 Posted April 27, 2004 Author Posted April 27, 2004 thank you. that was the problem. and i have to use texturecoordinate2 instead of texturecoordinate0 | texturecoordinate1 as format. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.