本文整理汇总了C#中IMesh.MapFaces方法的典型用法代码示例。如果您正苦于以下问题:C# IMesh.MapFaces方法的具体用法?C# IMesh.MapFaces怎么用?C# IMesh.MapFaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMesh
的用法示例。
在下文中一共展示了IMesh.MapFaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGlobalVertex
int CreateGlobalVertex(IMesh mesh, int face, int facePart, List<GlobalVertex> vertices, bool hasUV, bool hasUV2, VNormal[] vnorms, List<GlobalVertex>[] verticesAlreadyExported, IISkinContextData skinContextData)
{
var faceObject = mesh.Faces[face];
var vertexIndex = (int)faceObject.V[facePart];
var vertex = new GlobalVertex
{
BaseIndex = vertexIndex,
Position = mesh.Verts[vertexIndex],
Normal = vnorms[vertexIndex].GetNormal(verticesAlreadyExported != null ? 1 : faceObject.SmGroup)
};
if (hasUV)
{
var tvertexIndex = (int)mesh.TvFace[face].T[facePart];
vertex.UV = Loader.Global.Point2.Create(mesh.TVerts[tvertexIndex].X, mesh.TVerts[tvertexIndex].Y);
}
if (hasUV2)
{
var tvertexIndex = (int)mesh.MapFaces(2)[face].T[facePart];
vertex.UV2 = Loader.Global.Point2.Create(mesh.MapVerts(2)[tvertexIndex].X, mesh.MapVerts(2)[tvertexIndex].Y);
}
if (skinContextData != null)
{
float weight0 = 0;
float weight1 = 0;
float weight2 = 0;
int bone0 = bonesCount;
int bone1 = bonesCount;
int bone2 = bonesCount;
int bone3 = bonesCount;
int nbBones = skinContextData.GetNumAssignedBones(vertexIndex);
if (nbBones > 0)
{
bone0 = skinContextData.GetAssignedBone(vertexIndex, 0);
weight0 = skinContextData.GetBoneWeight(vertexIndex, 0);
}
if (nbBones > 1)
{
bone1 = skinContextData.GetAssignedBone(vertexIndex, 1);
weight1 = skinContextData.GetBoneWeight(vertexIndex, 1);
}
if (nbBones > 2)
{
bone2 = skinContextData.GetAssignedBone(vertexIndex, 2);
weight2 = skinContextData.GetBoneWeight(vertexIndex, 2);
}
if (nbBones > 3)
{
bone3 = skinContextData.GetAssignedBone(vertexIndex, 3);
}
if (nbBones == 0)
{
weight0 = 1.0f;
bone0 = bonesCount;
}
if (nbBones > 4)
{
RaiseError("Too many bones influences per vertex: " + nbBones + ". Babylon.js only support 4 bones influences per vertex.", 2);
}
vertex.Weights = Loader.Global.Point4.Create(weight0, weight1, weight2, 1.0 - weight0 - weight1 - weight2);
vertex.BonesIndices = (bone3 << 24) | (bone2 << 16) | (bone1 << 8) | bone0;
}
if (verticesAlreadyExported != null)
{
if (verticesAlreadyExported[vertexIndex] != null)
{
var index = verticesAlreadyExported[vertexIndex].IndexOf(vertex);
if (index > -1)
{
return verticesAlreadyExported[vertexIndex][index].CurrentIndex;
}
}
else
{
verticesAlreadyExported[vertexIndex] = new List<GlobalVertex>();
}
vertex.CurrentIndex = vertices.Count;
verticesAlreadyExported[vertexIndex].Add(vertex);
}
vertices.Add(vertex);
return vertices.Count - 1;
}
示例2: CreateGlobalVertex
int CreateGlobalVertex(IMesh mesh, Mesh computedMesh, int face, int facePart, List<GlobalVertex> vertices, bool hasUV, bool hasUV2, bool noOptimize)
{
var vertexIndex = (int)mesh.Faces[face].V[facePart];
var vertex = new GlobalVertex
{
Position = mesh.Verts[vertexIndex],
Normal = computedMesh.vnormals[vertexIndex]._IPoint3
};
if (hasUV)
{
var tvertexIndex = (int)mesh.TvFace[face].T[facePart];
vertex.UV = Loader.Global.Point2.Create(mesh.TVerts[tvertexIndex].X, mesh.TVerts[tvertexIndex].Y);
}
if (hasUV2)
{
var tvertexIndex = (int)mesh.MapFaces(2)[face].T[facePart];
vertex.UV2 = Loader.Global.Point2.Create(mesh.MapVerts(2)[tvertexIndex].X, mesh.MapVerts(2)[tvertexIndex].Y);
}
if (!noOptimize)
{
var index = vertices.IndexOf(vertex);
if (index > -1)
{
return index;
}
}
vertices.Add(vertex);
return vertices.Count - 1;
}