本文整理汇总了C#中Mesh.CreateBabylonMesh方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.CreateBabylonMesh方法的具体用法?C# Mesh.CreateBabylonMesh怎么用?C# Mesh.CreateBabylonMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.CreateBabylonMesh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseMesh
void ParseMesh(ModelMesh modelMesh, BabylonScene scene, BabylonSkeleton skeleton, bool rightToLeft)
{
var proxyID = ProxyMesh.CreateBabylonMesh(modelMesh.Name, scene);
int indexName = 0;
foreach (var part in modelMesh.MeshParts)
{
var material = exportedMaterials.First(m => m.Name == part.Effect.GetHashCode().ToString());
var indices = new ushort[part.PrimitiveCount * 3];
part.IndexBuffer.GetData(part.StartIndex * 2, indices, 0, indices.Length);
if (rightToLeft)
{
for (int ib = 0; ib < indices.Length; ib += 3) // reverse winding of triangles
{
ushort ti = indices[ib];
indices[ib] = indices[ib + 2];
indices[ib + 2] = ti;
}
}
if (part.VertexBuffer.VertexDeclaration.VertexStride >= PositionNormalTexturedWeights.Stride)
{
var mesh = new Mesh<PositionNormalTexturedWeights>(material);
var vertices = new PositionNormalTexturedWeights[part.NumVertices];
part.VertexBuffer.GetData(part.VertexOffset * part.VertexBuffer.VertexDeclaration.VertexStride, vertices, 0, vertices.Length, part.VertexBuffer.VertexDeclaration.VertexStride);
for (int index = 0; index < vertices.Length; index++)
{
vertices[index].TextureCoordinates.Y = 1.0f - vertices[index].TextureCoordinates.Y;
if (rightToLeft)
{
vertices[index].Position.Z = -vertices[index].Position.Z;
vertices[index].Normal.Z = -vertices[index].Normal.Z;
}
}
mesh.AddPart(modelMesh.Name+"#"+indexName.ToString(), vertices.ToList(), indices.Select(i => (int)i).ToList());
mesh.CreateBabylonMesh(scene, proxyID, skeleton);
}
else
{
if (part.VertexBuffer.VertexDeclaration.VertexStride < PositionNormalTextured.Stride) return; // Error: Not a PositionNormalTextured mesh!
var mesh = new Mesh<PositionNormalTextured>(material);
var vertices = new PositionNormalTextured[part.NumVertices];
part.VertexBuffer.GetData(part.VertexOffset * part.VertexBuffer.VertexDeclaration.VertexStride, vertices, 0, vertices.Length, part.VertexBuffer.VertexDeclaration.VertexStride);
for (int index = 0; index < vertices.Length; index++)
{
vertices[index].TextureCoordinates.Y = 1.0f - vertices[index].TextureCoordinates.Y;
if (rightToLeft)
{
vertices[index].Position.Z = -vertices[index].Position.Z;
vertices[index].Normal.Z = -vertices[index].Normal.Z;
}
}
mesh.AddPart(modelMesh.Name + "#" + indexName.ToString(), vertices.ToList(), indices.Select(i => (int)i).ToList());
mesh.CreateBabylonMesh(scene, proxyID, skeleton);
}
indexName++;
}
}
示例2: ParseMesh
void ParseMesh(ModelMesh modelMesh, BabylonScene scene, BabylonSkeleton skeleton)
{
var proxyID = ProxyMesh.CreateBabylonMesh(modelMesh.Name, scene);
int indexName = 0;
foreach (var part in modelMesh.MeshParts)
{
var material = exportedMaterials.First(m => m.Name == part.Effect.GetHashCode().ToString());
var indices = new ushort[part.PrimitiveCount * 3];
part.IndexBuffer.GetData(part.StartIndex * 2, indices, 0, indices.Length);
if (part.VertexBuffer.VertexDeclaration.VertexStride >= PositionNormalTexturedWeights.Stride)
{
var mesh = new Mesh<PositionNormalTexturedWeights>(material);
var vertices = new PositionNormalTexturedWeights[part.NumVertices];
part.VertexBuffer.GetData(part.VertexOffset * part.VertexBuffer.VertexDeclaration.VertexStride, vertices, 0, vertices.Length, part.VertexBuffer.VertexDeclaration.VertexStride);
for (int index = 0; index < vertices.Length; index++)
{
vertices[index].TextureCoordinates.Y = 1.0f - vertices[index].TextureCoordinates.Y;
}
mesh.AddPart(indexName.ToString(), vertices.ToList(), indices.Select(i => (int)i).ToList());
mesh.CreateBabylonMesh(scene, proxyID, skeleton);
}
else
{
var mesh = new Mesh<PositionNormalTextured>(material);
var vertices = new PositionNormalTextured[part.NumVertices];
part.VertexBuffer.GetData(part.VertexOffset * PositionNormalTextured.Stride, vertices, 0, vertices.Length, PositionNormalTextured.Stride);
for (int index = 0; index < vertices.Length; index++)
{
vertices[index].TextureCoordinates.Y = 1.0f - vertices[index].TextureCoordinates.Y;
}
mesh.AddPart(indexName.ToString(), vertices.ToList(), indices.Select(i => (int)i).ToList());
mesh.CreateBabylonMesh(scene, proxyID, skeleton);
}
indexName++;
}
}