本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexElement类的典型用法代码示例。如果您正苦于以下问题:C# VertexElement类的具体用法?C# VertexElement怎么用?C# VertexElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexElement类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了VertexElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MercuryVertex
/// <summary>
/// Static constructor.
/// </summary>
static MercuryVertex()
{
VertexElement posElement = new VertexElement();
VertexElement colorElement = new VertexElement();
VertexElement scaleElement = new VertexElement();
VertexElement rotationElement = new VertexElement();
VertexElements = new VertexElement[4];
posElement.VertexElementFormat = VertexElementFormat.Vector2;
posElement.VertexElementMethod = VertexElementMethod.Default;
posElement.VertexElementUsage = VertexElementUsage.Position;
colorElement.Offset = 8;
colorElement.VertexElementFormat = VertexElementFormat.Vector4;
colorElement.VertexElementMethod = VertexElementMethod.Default;
colorElement.VertexElementUsage = VertexElementUsage.Color;
scaleElement.Offset = 24;
scaleElement.VertexElementFormat = VertexElementFormat.Single;
scaleElement.VertexElementMethod = VertexElementMethod.Default;
scaleElement.VertexElementUsage = VertexElementUsage.PointSize;
rotationElement.Offset = 28;
rotationElement.VertexElementFormat = VertexElementFormat.Single;
rotationElement.VertexElementMethod = VertexElementMethod.Default;
rotationElement.VertexElementUsage = VertexElementUsage.Color;
rotationElement.UsageIndex = 1;
VertexElements[0] = posElement;
VertexElements[1] = colorElement;
VertexElements[2] = scaleElement;
VertexElements[3] = rotationElement;
}
示例2: Vertex
static Vertex()
{
s_elements = new VertexElement[3];
s_elements[0] = new VertexElement(0, 0, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.Position, 0);
s_elements[1] = new VertexElement(0, 8, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0);
s_elements[2] = new VertexElement(0, 16, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0);
}
示例3: ManagedVertexDeclaration
/// <summary>
/// Create a ManagedVertexDeclaration.
/// </summary>
/// <param name="device">The graphics device.</param>
/// <param name="elements">The vertex elements.</param>
public ManagedVertexDeclaration(GraphicsDevice device, VertexElement[] elements)
{
this.elements = elements;
this.device = device;
vertexDeclaration = CreateVertexDeclaration();
device.DeviceReset += device_DeviceReset;
}
示例4: VertexPositionVectorColorTexture
static VertexPositionVectorColorTexture()
{
VertexElement[] elements = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector4, VertexElementUsage.Color, 0), new VertexElement(28, VertexElementFormat.HalfVector2, VertexElementUsage.TextureCoordinate, 0) };
VertexDeclaration declaration = new VertexDeclaration(elements);
declaration.Name = "VertexPositionVectorColorTexture.VertexDeclaration";
VertexDeclaration = declaration;
}
示例5: init
private void init()
{
desc = new VertexElement[ElementCount];
int i = 0;
foreach (BufferLayoutElement element in Elements)
{
desc[i] = new VertexElement();
switch (element.Usage)
{
case BufferLayoutElementUsages.Position: desc[i].VertexElementUsage = VertexElementUsage.Position; break;
case BufferLayoutElementUsages.Color: desc[i].VertexElementUsage = VertexElementUsage.Color; break;
case BufferLayoutElementUsages.UV: desc[i].VertexElementUsage = VertexElementUsage.TextureCoordinate; break;
case BufferLayoutElementUsages.Normal: desc[i].VertexElementUsage = VertexElementUsage.Normal; break;
case BufferLayoutElementUsages.Index: desc[i].VertexElementUsage = VertexElementUsage.BlendIndices; break;
case BufferLayoutElementUsages.IndexClassic: desc[i].VertexElementUsage = VertexElementUsage.BlendIndices; break;
}
switch (element.Type)
{
case BufferLayoutElementTypes.Float: desc[i].VertexElementFormat = VertexElementFormat.Single; break;
case BufferLayoutElementTypes.Vector2: desc[i].VertexElementFormat = VertexElementFormat.Vector2; break;
case BufferLayoutElementTypes.Vector3: desc[i].VertexElementFormat = VertexElementFormat.Vector3; break;
case BufferLayoutElementTypes.Vector4: desc[i].VertexElementFormat = VertexElementFormat.Vector4; break;
case BufferLayoutElementTypes.RGBAx8: desc[i].VertexElementFormat = VertexElementFormat.Color; break;
}
desc[i].UsageIndex = (int)element.UsageIndex;
desc[i].Offset = element.ByteOffset;
++i;
}
}
示例6: Particle
static Particle()
{
// Position vertex element...
VertexElement positionElement = new VertexElement();
positionElement.VertexElementFormat = VertexElementFormat.Vector2;
positionElement.VertexElementUsage = VertexElementUsage.Position;
// Scale vertex element...
VertexElement scaleElement = new VertexElement();
scaleElement.Offset = 8;
scaleElement.VertexElementFormat = VertexElementFormat.Single;
scaleElement.VertexElementUsage = VertexElementUsage.PointSize;
// Rotation vertex element...
VertexElement rotationElement = new VertexElement();
rotationElement.Offset = 12;
rotationElement.VertexElementFormat = VertexElementFormat.Single;
rotationElement.VertexElementUsage = VertexElementUsage.TextureCoordinate;
// Color vertex element...
VertexElement colourElement = new VertexElement();
colourElement.Offset = 16;
colourElement.VertexElementFormat = VertexElementFormat.Vector4;
colourElement.VertexElementUsage = VertexElementUsage.Color;
// Vertex element array...
Particle.VertexElements = new VertexElement[]
{
positionElement,
scaleElement,
rotationElement,
colourElement
};
}
示例7: ExtendVertexDeclaration
/// <summary>
/// 頂点宣言クラスに新しい頂点要素を追加する
/// </summary>
/// <param name="vertexDeclaration">追加先の頂点宣言</param>
/// <param name="extraElements">追加する頂点要素</param>
/// <returns>新要素追加後の頂点宣言</returns>
public static VertexDeclaration ExtendVertexDeclaration(
VertexDeclaration vertexDeclaration, VertexElement[] extraElements)
{
VertexElement[] originalElements = vertexDeclaration.GetVertexElements();
return ExtendVertexDeclaration( vertexDeclaration.GraphicsDevice,
originalElements, extraElements );
}
示例8: BaseDrawableComponent
/// <summary>
/// CTOR. Creates a new instance
/// </summary>
/// <param name="i_Game">hosting game</param>
/// <param name="i_VertexElements">The vertex elements defining the component.
/// This is in order to load VertexDeclaration.
/// Valid values are: null, VertexPositionTexture.VertexElements,
/// VertexPositionColor</param>
/// <param name="i_NeedTexture">Defines if a 2D texture is needed by the component</param>
public BaseDrawableComponent(
Game i_Game,
VertexElement[] i_VertexElements,
bool i_NeedTexture)
: base(i_Game)
{
m_VertexElements = i_VertexElements;
NeedTexture = i_NeedTexture;
}
示例9: VertexPositionColor
static VertexPositionColor()
{
VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position,0),
new VertexElement(12, VertexElementFormat.Vector4, VertexElementUsage.Color,0)
};
VertexDeclaration = new VertexDeclaration(elements);
}
示例10: VertexPositionColorTexture
static VertexPositionColorTexture()
{
var elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(16, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
};
VertexDeclaration = new VertexDeclaration(elements);
}
示例11: VertexPositionNormalColor
static VertexPositionNormalColor()
{
VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(24, VertexElementFormat.Color, VertexElementUsage.Color, 0)
};
VertexDeclaration declaration = new VertexDeclaration(elements);
VertexDeclaration = declaration;
}
示例12: GetVertexStride
private static int GetVertexStride(VertexElement[] elements)
{
int num1 = 0;
for (int index = 0; index < elements.Length; ++index)
{
int num2 = elements[index].Offset + GraphicsExtensions.GetTypeSize(elements[index].VertexElementFormat);
if (num1 < num2)
num1 = num2;
}
return num1;
}
示例13: ShadowHullVertex
static ShadowHullVertex()
{
VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
new VertexElement(8, VertexElementFormat.Vector2, VertexElementUsage.Normal,0),
new VertexElement(16, VertexElementFormat.Color, VertexElementUsage.Color,0),
};
mVertexDeclaration = new VertexDeclaration(elements);
}
示例14: LoadContent
/// <summary>
/// Creates all required variables at load time
/// </summary>
/// <param name="game"></param>
public void LoadContent(GraphicsDevice gd)
{
vBuffer = new VertexBuffer(gd, typeof(vertexPos), numV, BufferUsage.WriteOnly);
VertexElement[] elements = new VertexElement[2];
elements[0] = new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0);
elements[1] = new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0);
vDecl = new VertexDeclaration(gd, elements);
vBuffer.SetData<vertexPos>(vertices);
}
示例15: GetVertexStride
private static int GetVertexStride(VertexElement[] elements)
{
int max = 0;
for (var i = 0; i < elements.Length; i++)
{
var start = elements[i].Offset + elements[i].VertexElementFormat.GetSize();
if (max < start)
max = start;
}
return max;
}