本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.VertexPositionTexture.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# VertexPositionTexture.GetType方法的具体用法?C# VertexPositionTexture.GetType怎么用?C# VertexPositionTexture.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.VertexPositionTexture
的用法示例。
在下文中一共展示了VertexPositionTexture.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start()
{
base.Start();
filter = (MeshFilter)GetComponent(typeof(MeshFilter));
if (filter.meshToRender != null)
{
bounds = filter.meshToRender.bounds;
if (material != null)
{
// Determine what vertex buffer to create
Mesh m = filter.meshToRender;
bool hasTexture = (material.mainTexture != null && material.shader.supportsTextures);
bool hasVertexColor = (m.colors.HasElements() && material.shader.supportsVertexColor);
bool hasLights = (Light.HasLights && m.normals.HasElements() && material.shader.supportsLights);
if (hasTexture)
{
if (hasVertexColor)
{
// NOTE: Here, lights are not supported
VertexPositionColorTexture[] data = new VertexPositionColorTexture[m.vertexCount];
for (int i = 0; i < m.vertexCount; i++)
{
data[i] = new VertexPositionColorTexture(
m.vertices[i],
m.colors[i],
m.uv[i]
);
}
vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
vBuffer.SetData(data);
}
else
{
if (hasLights)
{
VertexPositionNormalTexture[] data = new VertexPositionNormalTexture[m.vertexCount];
for (int i = 0; i < m.vertexCount; i++)
{
data[i] = new VertexPositionNormalTexture(
m.vertices[i],
m.normals[i],
m.uv[i]
);
}
vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
vBuffer.SetData(data);
}
else
{
VertexPositionTexture[] data = new VertexPositionTexture[m.vertexCount];
for (int i = 0; i < m.vertexCount; i++)
{
data[i] = new VertexPositionTexture(
m.vertices[i],
m.uv[i]
);
}
vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
vBuffer.SetData(data);
}
}
}
else
{
if (hasVertexColor)
{
VertexPositionColor[] data = new VertexPositionColor[m.vertexCount];
for (int i = 0; i < m.vertexCount; i++)
{
data[i] = new VertexPositionColor(
m.vertices[i],
m.colors[i]
);
}
vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
vBuffer.SetData(data);
}
else
{
// Not supported yet
}
}
}
}
}