本文整理汇总了C#中pb_Face.Select方法的典型用法代码示例。如果您正苦于以下问题:C# pb_Face.Select方法的具体用法?C# pb_Face.Select怎么用?C# pb_Face.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_Face
的用法示例。
在下文中一共展示了pb_Face.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectTextureGroups
/**
* If any of the faces in @selection are AutoUV and in a texture group, this
* augments the texture group buddies to the selection and returns it.
*/
private pb_Face[] SelectTextureGroups(pb_Object pb, pb_Face[] selection)
{
List<int> texGroups = selection.Select(x => x.textureGroup).Where(x => x > 0).Distinct().ToList();
pb_Face[] sel = System.Array.FindAll(pb.faces, x => !x.manualUV && texGroups.Contains(x.textureGroup));
return selection.Union(sel).ToArray();
}
示例2: GetIncompleteTextureGroups
/**
* If selection contains faces that are part of a texture group, and not all of those group faces are in the selection,
* return a pb_Face[] of that entire group so that we can show the user some indication of that groupage.
*/
private List<pb_Face[]> GetIncompleteTextureGroups(pb_Object pb, pb_Face[] selection)
{
// get distinct list of all selected texture groups
List<int> groups = selection.Select(x => x.textureGroup).Where(x => x > 0).Distinct().ToList();
List<pb_Face[]> incompleteGroups = new List<pb_Face[]>();
// figure out how many
for(int i = 0; i < groups.Count; i++)
{
pb_Face[] whole_group = System.Array.FindAll(pb.faces, x => !x.manualUV && groups[i] == x.textureGroup);
int inSelection = System.Array.FindAll(selection, x => x.textureGroup == groups[i]).Length;
if(inSelection != whole_group.Length)
incompleteGroups.Add(whole_group);
}
return incompleteGroups;
}
示例3: Extrude
/**
* Extrudes passed faces on their normal axis using extrudeDistance.
*/
public static bool Extrude(this pb_Object pb, pb_Face[] faces, float extrudeDistance, bool extrudeAsGroup, out pb_Face[] appendedFaces)
{
appendedFaces = null;
if(faces == null || faces.Length < 1)
return false;
pb_IntArray[] sharedIndices = pb.GetSharedIndices();
Dictionary<int, int> lookup = sharedIndices.ToDictionary();
Vector3[] localVerts = pb.vertices;
pb_Edge[][] perimeterEdges = extrudeAsGroup ? new pb_Edge[1][] { pbMeshUtils.GetPerimeterEdges(pb, lookup, faces).ToArray() } : faces.Select(x => x.edges).ToArray();
if(perimeterEdges == null || perimeterEdges.Length < 1 || (extrudeAsGroup && perimeterEdges[0].Length < 3))
{
Debug.LogWarning("No perimeter edges found. Try deselecting and reselecting this object and trying again.");
return false;
}
pb_Face[][] edgeFaces = new pb_Face[perimeterEdges.Length][]; // can't assume faces and perimiter edges will be 1:1 - so calculate perimeters then extract face information
int[][] allEdgeIndices = new int[perimeterEdges.Length][];
int c = 0;
for(int i = 0; i < perimeterEdges.Length; i++)
{
c = 0;
allEdgeIndices[i] = new int[perimeterEdges[i].Length * 2];
edgeFaces[i] = new pb_Face[perimeterEdges[i].Length];
for(int n = 0; n < perimeterEdges[i].Length; n++)
{
// gets the faces associated with each perimeter edge
foreach(pb_Face face in faces)
{
if(face.edges.Contains(perimeterEdges[i][n]))
{
edgeFaces[i][n] = face;
break;
}
}
allEdgeIndices[i][c++] = perimeterEdges[i][n].x;
allEdgeIndices[i][c++] = perimeterEdges[i][n].y;
}
}
List<pb_Edge>[] extrudedIndices = new List<pb_Edge>[perimeterEdges.Length];
Vector3[] normals = pb.msh.normals;
List<Vector3[]> append_vertices = new List<Vector3[]>();
List<Color[]> append_color = new List<Color[]>();
List<Vector2[]> append_uv = new List<Vector2[]>();
List<pb_Face> append_face = new List<pb_Face>();
List<int[]> append_shared = new List<int[]>();
/// build out new faces around edges
for(int i = 0; i < perimeterEdges.Length; i++)
{
extrudedIndices[i] = new List<pb_Edge>();
for(int n = 0; n < perimeterEdges[i].Length; n++)
{
pb_Edge edge = perimeterEdges[i][n];
pb_Face face = edgeFaces[i][n];
// Averages the normals using only vertices that are on the edge
Vector3 xnorm = Vector3.zero;
Vector3 ynorm = Vector3.zero;
// don't bother getting vertex normals if not auto-extruding
if( Mathf.Abs(extrudeDistance) > Mathf.Epsilon)
{
if( !extrudeAsGroup )
{
xnorm = pb_Math.Normal( localVerts[face.indices[0]], localVerts[face.indices[1]], localVerts[face.indices[2]] );
ynorm = xnorm;
}
else
{
xnorm = Norm(sharedIndices[lookup[edge.x]], allEdgeIndices[i], normals );
ynorm = Norm(sharedIndices[lookup[edge.y]], allEdgeIndices[i], normals );
}
}
int x_sharedIndex = lookup[edge.x];
int y_sharedIndex = lookup[edge.y];
// this could be condensed to a single call with an array of new faces
append_vertices.Add( new Vector3[]
{
localVerts [ edge.x ],
localVerts [ edge.y ],
localVerts [ edge.x ] + xnorm.normalized * extrudeDistance,
localVerts [ edge.y ] + ynorm.normalized * extrudeDistance
});
//.........这里部分代码省略.........