本文整理汇总了C#中pb_Face.RebuildCaches方法的典型用法代码示例。如果您正苦于以下问题:C# pb_Face.RebuildCaches方法的具体用法?C# pb_Face.RebuildCaches怎么用?C# pb_Face.RebuildCaches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_Face
的用法示例。
在下文中一共展示了pb_Face.RebuildCaches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendFace
/**
* Append a new face to the pb_Object using sharedIndex array to set the face indices to sharedIndex groups.
*/
public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, Color[] c, Vector2[] u, pb_Face face, int[] sharedIndex)
{
int vertexCount = pb.vertexCount;
Vector3[] _verts = new Vector3[vertexCount + v.Length];
Color[] _colors = new Color[vertexCount + c.Length];
Vector2[] _uvs = new Vector2[pb.uv.Length + u.Length];
List<pb_Face> _faces = new List<pb_Face>(pb.faces);
pb_IntArray[] sharedIndices = pb.sharedIndices;
// copy new vertices
System.Array.Copy(pb.vertices, 0, _verts, 0, vertexCount);
System.Array.Copy(v, 0, _verts, vertexCount, v.Length);
// copy new colors
System.Array.Copy(pb.colors, 0, _colors, 0, vertexCount);
System.Array.Copy(c, 0, _colors, vertexCount, c.Length);
// copy new uvs
System.Array.Copy(pb.uv, 0, _uvs, 0, pb.uv.Length);
System.Array.Copy(u, 0, _uvs, pb.uv.Length, u.Length);
face.ShiftIndicesToZero();
face.ShiftIndices(vertexCount);
face.RebuildCaches();
_faces.Add(face);
for(int i = 0; i < sharedIndex.Length; i++)
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, sharedIndex[i], i+vertexCount);
pb.SetVertices( _verts );
pb.SetColors( _colors );
pb.SetUV( _uvs );
pb.SetSharedIndices(sharedIndices);
pb.SetFaces(_faces.ToArray());
return face;
}
示例2: AppendFace
/**
* Append a new face to the pb_Object.
*/
public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, pb_Face face, int[] sharedIndex)
{
List<Vector3> _verts = new List<Vector3>(pb.vertices);
List<pb_Face> _faces = new List<pb_Face>(pb.faces);
pb_IntArray[] sharedIndices = pb.sharedIndices;
int vertexCount = pb.vertexCount;
_verts.AddRange(v);
face.ShiftIndicesToZero();
face.ShiftIndices(vertexCount);
face.RebuildCaches();
_faces.Add(face);
// Dictionary<int, int> grp = new Dictionary<int, int>(); // this allows append face to add new vertices to a new shared index group
// // if the sharedIndex is negative and less than -1, it will create new gorup
// // that other sharedIndex members can then append themselves to.
for(int i = 0; i < sharedIndex.Length; i++)
{
// if(sharedIndex[i] < -1)
// {
// if(grp.ContainsKey(sharedIndex[i]))
// AddIndexToSharedIndexArray(grp[sharedIndex[i]], i+vertexCount);
// else
// grp.Add(sharedIndex[i], AddIndexToSharedIndexArray(sharedIndex[i], i+vertexCount));
// }
// else
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, sharedIndex[i], i+vertexCount);
}
pb.SetSharedIndices(sharedIndices);
pb.SetVertices(_verts.ToArray() );
pb.SetFaces(_faces.ToArray());
pb.ToMesh();
return face;
}