-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelInstanceVertex.cs
34 lines (26 loc) · 1.13 KB
/
ModelInstanceVertex.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/// <summary>
/// The Vertex declaration to be used for each individual instance of your models. The transform should contain positional, rotational, and scale data.
/// Also threw in color for fun
/// </summary>
public struct ModelInstanceVertex : IVertexType
{
public static readonly int Stride = 64 + sizeof(byte) * 4;
public Matrix Transform;
public Color Color;
public ModelInstanceVertex(Matrix transform, Color color)
{
Transform = transform;
Color = color;
}
public static readonly VertexDeclaration declaration = new VertexDeclaration(
new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0),
new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 1),
new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 2),
new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 3),
new VertexElement(64, VertexElementFormat.Color, VertexElementUsage.Color, 0)
);
VertexDeclaration IVertexType.VertexDeclaration
{
get { return declaration; }
}
}