本文整理汇总了C#中Vertex.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.ToArray方法的具体用法?C# Vertex.ToArray怎么用?C# Vertex.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
// Dispose of each vertex and index buffer
vertexBuffers.ForEach(vb => RemoveAndDispose(ref vb));
vertexBuffers.Clear();
indexBuffers.ForEach(ib => RemoveAndDispose(ref ib));
indexBuffers.Clear();
textureViews.ForEach(tv => RemoveAndDispose(ref tv));
textureViews.Clear();
RemoveAndDispose(ref samplerState);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
// Initialize vertex buffers
for (int indx = 0; indx < mesh.VertexBuffers.Count; indx++)
{
var vb = mesh.VertexBuffers[indx];
Vertex[] vertices = new Vertex[vb.Length];
for (var i = 0; i < vb.Length; i++)
{
// Retrieve skinning information for vertex
Common.Mesh.SkinningVertex skin = new Common.Mesh.SkinningVertex();
if (mesh.SkinningVertexBuffers.Count > 0)
skin = mesh.SkinningVertexBuffers[indx][i];
// Create vertex
vertices[i] = new Vertex(vb[i].Position, vb[i].Normal, vb[i].Color, vb[i].UV, skin);
}
vertexBuffers.Add(ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices.ToArray())));
vertexBuffers[vertexBuffers.Count - 1].DebugName = "VertexBuffer_" + indx.ToString();
}
// Initialize index buffers
foreach (var ib in mesh.IndexBuffers)
{
indexBuffers.Add(ToDispose(Buffer.Create(device, BindFlags.IndexBuffer, ib)));
indexBuffers[indexBuffers.Count - 1].DebugName = "IndexBuffer_" + (indexBuffers.Count - 1).ToString();
}
// Load textures if a material has any.
foreach (var m in mesh.Materials)
{
for (var i = 0; i < m.Textures.Length; i++)
{
if (System.IO.File.Exists(m.Textures[i]))
textureViews.Add(ToDispose(ShaderResourceView.FromFile(device, m.Textures[i])));
else
textureViews.Add(null);
}
}
// Create our sampler state
samplerState = ToDispose(new SamplerState(device, new SamplerStateDescription()
{
AddressU = TextureAddressMode.Wrap,
AddressV = TextureAddressMode.Wrap,
AddressW = TextureAddressMode.Wrap,
BorderColor = new Color4(0, 0, 0, 0),
ComparisonFunction = Comparison.Never,
Filter = Filter.Anisotropic,
MaximumAnisotropy = 16,
MaximumLod = float.MaxValue,
MinimumLod = 0,
MipLodBias = 0.0f
}));
}