akuehn3000
Newcomer
- Joined
- Jan 29, 2004
- Messages
- 18
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?
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?