我有一个顶点结构:
public struct VertexMultitextured
{
public Vector3 Position;
public Vector3 Normal;
public Vector4 TextureCoordinate;
public Vector4 TexWeights;
public static int SizeInBytes = (3 + 3 + 4 + 4) * sizeof(float);
public static VertexElement[] VertexElements = new VertexElement[]
{
new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0 ),
new VertexElement( sizeof(float) * 3, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0 ),
new VertexElement( sizeof(float) * 6, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 0 ),
new VertexElement( sizeof(float) * 10, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 1 ),
};
}
我想创建一个VertexBuffer
使用它的。如果我使用这条线:
terrainVertexBuffer = new VertexBuffer(device, typeof(VertexMultitextured),
vertices.Length, BufferUsage.WriteOnly);
我得到一个错误,我的结构“没有实现 IVertexType 接口”,那么我该如何实现呢?还是有更简单的方法来使用这个自定义结构?
谢谢!