Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...