本文整理汇总了C#中pb_Face类的典型用法代码示例。如果您正苦于以下问题:C# pb_Face类的具体用法?C# pb_Face怎么用?C# pb_Face使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
pb_Face类属于命名空间,在下文中一共展示了pb_Face类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HiddenFace
public static bool HiddenFace(pb_Object pb, pb_Face q, float dist)
{
// Grab the face normal
Vector3 dir = pb_Math.Normal(pb.VerticesInWorldSpace(q.indices));
// If casting from the center of the plane hits, chekc the rest of the points for collisions
Vector3 orig = pb.transform.TransformPoint(pb_Math.Average(pb.GetVertices(q)));
bool hidden = true;
Transform hitObj = RaycastFaceCheck(orig, dir, dist, null);
if(hitObj != null)
{
Vector3[] v = pb.VerticesInWorldSpace(q.indices);
for(int i = 0; i < v.Length; i++)
{
if(null == RaycastFaceCheck(v[i], dir, dist, hitObj))
{
hidden = false;
break;
}
}
}
else
hidden = false;
return hidden;
}
开发者ID:BaptisteBillet,项目名称:Prochain_Arret,代码行数:27,代码来源:AutoNodraw.cs
示例2: HiddenFace
public static bool HiddenFace(pb_Object pb, pb_Face q, float dist)
{
// Grab the face normal
Vector3 dir = pbUtil.PlaneNormal(pb.VerticesInWorldSpace(q));
// And also the center of the face
Vector3 orig = pb.QuadCenter(q);
// Case a ray from the center of the face out in the normal direction.
// If an object is hit, return true (that this face is hidden), otherwise
// return false. This is pretty simplistic and doesn't account for a lot
// of "gotchas", but it ought to serve as a fairly decent jumping off point
// for NoDrawing a dense level.
RaycastHit hit;
if(Physics.Raycast(orig, dir, out hit, dist)) {
// We've hit something. Now check to see if it is a ProBuilder object,
// and if so, make sure it's a visblocking brush.
pb_Entity ent = hit.transform.GetComponent<pb_Entity>();
if(ent != null)
{
if(ent.entityType == ProBuilder.EntityType.Brush || ent.entityType == ProBuilder.EntityType.Occluder)
return true; // it's a brush, blocks vision, return true
else
return false; // not a vis blocking brush
}
}
// It ain't a ProBuilder object of the entity type Brush or Occluder (world brush)
return false;
}
开发者ID:rickypickle,项目名称:Melody-1978,代码行数:30,代码来源:AutoNodraw.cs
示例3: GetConnectedFaces
/**
* \brief Returns all connected faces.
*/
public static List<pb_Face> GetConnectedFaces(pb_Object pb, pb_Face[] selFaces)
{
int len = selFaces.Length;
List<pb_Face> faces = new List<pb_Face>();
pb_IntArray[] sharedIndices = pb.sharedIndices;
pb_Edge[][] sharedEdges = new pb_Edge[len][];
for(int i = 0; i < len; i++)
sharedEdges[i] = pb_Edge.GetUniversalEdges(selFaces[i].edges, sharedIndices);
for(int i = 0; i < pb.faces.Length; i++)
{
pb_Edge[] faceEdges = pb_Edge.GetUniversalEdges(pb.faces[i].edges, sharedIndices);
for(int j = 0; j < len; j++)
{
int ind = faceEdges.ContainsMatch(sharedEdges[j]);
if(ind > -1)
faces.Add(pb.faces[i]);
}
}
return faces;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:29,代码来源:pbMeshUtils.cs
示例4: AppendFace
/**
* \brief
* param sharedIndex An optional array that sets the new pb_Face indices to use the _sharedIndices array.
* \returns The newly appended pb_Face.
*/
public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, pb_Face face)
{
int[] shared = new int[v.Length];
for(int i = 0; i < v.Length; i++)
shared[i] = -1;
return pb.AppendFace(v, face, shared);
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:12,代码来源:pbAppendDelete.cs
示例5: ReverseWindingOrder
/**
* \brief Flips the winding order for the entire mesh.
*/
// public static void ReverseWindingOrder(this pb_Object pb)
// {
// for(int i = 0; i < pb.faces.Length; i++)
// pb.faces[i].ReverseIndices();
// pb.ToMesh();
// pb.Refresh();
// }
/**
* \brief Reverse the winding order for each passed #pb_Face.
* @param faces The faces to apply normal flippin' to.
* \returns Nothing. No soup for you.
* \sa SelectedFaces pb_Face
*/
public static void ReverseWindingOrder(this pb_Object pb, pb_Face[] faces)
{
for(int i = 0; i < faces.Length; i++)
faces[i].ReverseIndices();
pb.ToMesh();
pb.Refresh();
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:26,代码来源:pbTriangleOps.cs
示例6: SubdivideFace
public static bool SubdivideFace(this pb_Object pb, pb_Face[] faces, out pb_Face[] splitFaces)
{
List<EdgeConnection> split = new List<EdgeConnection>();
foreach(pb_Face face in pb.SelectedFaces)
split.Add(new EdgeConnection(face, new List<pb_Edge>(face.edges)));
return pb.ConnectEdges(split, out splitFaces);
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:8,代码来源:pbSubdivideSplit.cs
示例7: Triangulate
static void Triangulate(pb_Object pb)
{
Vector3[] v = pb.vertices;
Vector2[] u = pb.msh.uv;
int triangleCount = pb.msh.triangles.Length;
if(triangleCount == v.Length)
{
Debug.LogWarning("We can't pull over any further!\npb_Object: " + pb.name + " is already triangulated.");
}
int vertexCount = triangleCount;
int faceCount = vertexCount / 3;
Vector3[] tri_vertices = new Vector3[vertexCount];
Vector2[] tri_uvs = new Vector2[vertexCount];
pb_Face[] tri_faces = new pb_Face[faceCount];
int n = 0, f = 0;
foreach(pb_Face face in pb.faces)
{
int[] indices = face.indices;
for(int i = 0; i < indices.Length; i+=3)
{
tri_vertices[n+0] = v[indices[i+0]];
tri_vertices[n+1] = v[indices[i+1]];
tri_vertices[n+2] = v[indices[i+2]];
tri_uvs[n+0] = u[indices[i+0]];
tri_uvs[n+1] = u[indices[i+1]];
tri_uvs[n+2] = u[indices[i+2]];
tri_faces[f++] = new pb_Face( new int[] { n+0, n+1, n+2 },
face.material,
face.uv,
face.smoothingGroup,
face.textureGroup, // textureGroup -> force to manual uv mode
face.elementGroup,
face.manualUV, // manualUV
face.color
);
n += 3;
}
}
pb.SetVertices(tri_vertices);
pb.SetUV(tri_uvs);
pb.SetFaces(tri_faces);
pb.SetSharedIndices( pb_IntArrayUtility.ExtractSharedIndices(tri_vertices) );
pb.SetSharedIndicesUV( new pb_IntArray[0] );
}
开发者ID:benlewis,项目名称:unhinged_vr,代码行数:55,代码来源:TriangulatePbObject.cs
示例8: AppendFaces
/**
* Append a group of new faces to the pb_Object. Significantly faster than calling AppendFace multiple times.
*/
public static pb_Face[] AppendFaces(this pb_Object pb, Vector3[][] new_Vertices, Color[][] new_Colors, Vector2[][] new_uvs, pb_Face[] new_Faces, int[][] new_SharedIndices)
{
List<Vector3> _verts = new List<Vector3>(pb.vertices);
List<Color> _colors = new List<Color>(pb.colors);
List<Vector2> _uv = new List<Vector2>(pb.uv);
List<pb_Face> _faces = new List<pb_Face>(pb.faces);
pb_IntArray[] sharedIndices = pb.sharedIndices;
int vc = pb.vertexCount;
for(int i = 0; i < new_Faces.Length; i++)
{
_verts.AddRange(new_Vertices[i]);
_colors.AddRange(new_Colors[i]);
_uv.AddRange(new_uvs[i]);
new_Faces[i].ShiftIndicesToZero();
new_Faces[i].ShiftIndices(vc);
new_Faces[i].RebuildCaches();
_faces.Add(new_Faces[i]);
if(new_SharedIndices != null && new_Vertices[i].Length != new_SharedIndices[i].Length)
{
Debug.LogError("Append Face failed because sharedIndex array does not match new vertex array.");
return null;
}
if(new_SharedIndices != null)
{
for(int j = 0; j < new_SharedIndices[i].Length; j++)
{
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, new_SharedIndices[i][j], j+vc);
}
}
else
{
for(int j = 0; j < new_Vertices[i].Length; j++)
{
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, -1, j+vc);
}
}
vc = _verts.Count;
}
pb.SetSharedIndices(sharedIndices);
pb.SetVertices(_verts.ToArray());
pb.SetColors(_colors.ToArray());
pb.SetUV(_uv.ToArray());
pb.SetFaces(_faces.ToArray());
return new_Faces;
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:58,代码来源:pbAppendDelete.cs
示例9: AppendFaces
/**
* Append a group of new faces to the pb_Object. Significantly faster than calling AppendFace multiple times.
*/
public static pb_Face[] AppendFaces(this pb_Object pb, Vector3[][] new_Vertices, pb_Face[] new_Faces, int[][] new_SharedIndices)
{
List<Vector3> _verts = new List<Vector3>(pb.vertices);
List<pb_Face> _faces = new List<pb_Face>(pb.faces);
pb_IntArray[] sharedIndices = pb.sharedIndices;
int vc = pb.vertexCount;
// 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 < new_Faces.Length; i++)
{
_verts.AddRange(new_Vertices[i]);
new_Faces[i].ShiftIndicesToZero();
new_Faces[i].ShiftIndices(vc);
_faces.Add(new_Faces[i]);
if(new_SharedIndices != null && new_Vertices[i].Length != new_SharedIndices[i].Length)
{
Debug.LogError("Append Face failed because sharedIndex array does not match new vertex array.");
return null;
}
if(new_SharedIndices != null)
for(int j = 0; j < new_SharedIndices[i].Length; j++)
{
// TODO - FIX ME
// if(new_SharedIndices[i][j] < -1)
// {
// if(grp.ContainsKey(new_SharedIndices[i][j]))
// AddValueAtIndex(grp[new_SharedIndices[i][j]], j+vc);
// else
// grp.Add(new_SharedIndices[i][j], AddValueAtIndex(new_SharedIndices[i][j], j+vc));
// }
// else
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, new_SharedIndices[i][j], j+vc);
}
else
for(int j = 0; j < new_Vertices[i].Length; j++)
{
pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, -1, j+vc);
}
vc = _verts.Count;
}
pb.SetSharedIndices(sharedIndices);
pb.SetVertices(_verts.ToArray());
pb.SetFaces(_faces.ToArray());
pb.ToMesh();
return new_Faces;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:56,代码来源:pbAppendDelete.cs
示例10: Normal
public static Vector3 Normal(pb_Object pb, pb_Face face)
{
Vector3 p0 = pb.vertices[face.indices[0]];
Vector3 p1 = pb.vertices[face.indices[1]];
Vector3 p2 = pb.vertices[face.indices[2]];
Vector3 cross = Vector3.Cross(p1 - p0, p2 - p0);
if (cross.magnitude < Mathf.Epsilon)
return new Vector3(0f, 0f, 0f); // bad triangle
else
{
return cross.normalized;
}
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:14,代码来源:pb_Math.cs
示例11: pb_SerializableFace
public pb_SerializableFace(pb_Face face)
{
this.indices = face.indices;
this.distinctIndices = face.distinctIndices;
this.edges = face.edges;
this.smoothingGroup = face.smoothingGroup;
this.uv = face.uv;
this.material = face.material;
this.manualUV = false;
pb_UpgradeKitUtils.TryGetField(face, "manualUV", ref this.manualUV);
this.elementGroup = -1;
pb_UpgradeKitUtils.TryGetField(face, "elementGroup", ref this.elementGroup);
this.textureGroup = -1;
pb_UpgradeKitUtils.TryGetField(face, "textureGroup", ref this.textureGroup);
}
开发者ID:HaikunHuang,项目名称:TutorialForTaikeQ,代码行数:15,代码来源:pb_SerializableFace.cs
示例12: InitWithObject
/**
* \brief Duplicates and returns the passed pb_Object.
* @param pb The pb_Object to duplicate.
* \returns A unique copy of the passed pb_Object.
*/
public static pb_Object InitWithObject(pb_Object pb)
{
Vector3[] v = new Vector3[pb.vertexCount];
System.Array.Copy(pb.vertices, v, pb.vertexCount);
pb_Face[] f = new pb_Face[pb.faces.Length];
for(int i = 0; i < f.Length; i++)
f[i] = new pb_Face(pb.faces[i]);
pb_Object p = CreateInstanceWithVerticesFacesSharedIndices(v, f, pb.GetSharedIndices());
p.gameObject.name = pb.gameObject.name + "-clone";
return p;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:21,代码来源:pb_Object.cs
示例13: GetWindingOrder
/**
* Attempt to figure out the winding order the passed face. Note that
* this may return WindingOrder.Unknown.
*/
public static WindingOrder GetWindingOrder(this pb_Object pb, pb_Face face)
{
Vector2[] p = pb_Math.PlanarProject(pb.GetVertices( face.edges.AllTriangles() ), pb_Math.Normal(pb, face));
float sum = 0f;
// http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
for(int i = 0; i < p.Length; i++)
{
Vector2 a = p[i];
Vector2 b = i < p.Length - 1 ? p[i+1] : p[0];
sum += ( (b.x-a.x) * (b.y+a.y) );
}
return sum == 0f ? WindingOrder.Unknown : (sum >= 0f ? WindingOrder.Clockwise : WindingOrder.CounterClockwise);
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:21,代码来源:pbTriangleOps.cs
示例14: pb_Face
/**
* Deep copy constructor.
*/
public pb_Face(pb_Face face)
{
_indices = new int[face.indices.Length];
System.Array.Copy(face.indices, _indices, face.indices.Length);
_uv = new pb_UV(face.uv);
_mat = face.material;
_smoothingGroup = face.smoothingGroup;
textureGroup = face.textureGroup;
elementGroup = face.elementGroup;
_colors = new Color32[face.colors.Length];
System.Array.Copy(face.colors, _colors, colors.Length);
manualUV = face.manualUV;
RebuildCaches();
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:23,代码来源:pb_Face.cs
示例15: 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;
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:44,代码来源:pbAppendDelete.cs
示例16: InitWithObject
/**
* \brief Duplicates and returns the passed pb_Object.
* @param pb The pb_Object to duplicate.
* \returns A unique copy of the passed pb_Object.
*/
public static pb_Object InitWithObject(pb_Object pb)
{
Vector3[] v = new Vector3[pb.vertexCount];
System.Array.Copy(pb.vertices, v, pb.vertexCount);
Vector2[] u = new Vector2[pb.vertexCount];
System.Array.Copy(pb.uv, u, pb.vertexCount);
Color[] c = new Color[pb.vertexCount];
System.Array.Copy(pb.colors, c, pb.vertexCount);
pb_Face[] f = new pb_Face[pb.faces.Length];
for(int i = 0; i < f.Length; i++)
f[i] = new pb_Face(pb.faces[i]);
pb_Object p = CreateInstanceWithElements(v, u, c, f, pb.GetSharedIndices(), pb.GetSharedIndicesUV());
p.gameObject.name = pb.gameObject.name + "-clone";
return p;
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:27,代码来源:pb_Object.cs
示例17: ProBuilderize
public static pb_Object ProBuilderize(Transform t)
{
Mesh m = t.GetComponent<MeshFilter>().sharedMesh;
pb_Face[] faces = new pb_Face[m.triangles.Length/3];
int f = 0;
for(int n = 0; n < m.subMeshCount; n++)
{
for(int i = 0; i < m.triangles.Length; i+=3)
{
faces[f] = new pb_Face(
new int[3] {
m.triangles[i+0],
m.triangles[i+1],
m.triangles[i+2]
},
t.GetComponent<MeshRenderer>().sharedMaterials[n],
new pb_UV(),
0,
Color.white
);
f++;
}
}
t.gameObject.SetActive(false);
pb_Object pb = ProBuilder.CreateObjectWithVerticesFaces(m.vertices, faces);
pb.SetName("FrankenMesh");
pb_Editor_Utility.SetEntityType(ProBuilder.EntityType.Detail, pb.gameObject);
GameObject go = pb.gameObject;
go.transform.position = t.position;
go.transform.localRotation = t.localRotation;
go.transform.localScale = t.localScale;
pb.FreezeScaleTransform();
return pb;
}
开发者ID:flickenmaste,项目名称:R6Demake,代码行数:38,代码来源:ProBuilderizeGameObject.cs
示例18: GetNeighborFaces
/**
* Returns all faces that share an edge with originFace.
*/
public static List<pb_Face> GetNeighborFaces(pb_Object pb, Dictionary<int, int> lookup, IEnumerable<pb_Face> mask, pb_Face originFace)
{
List<pb_Face> faces = new List<pb_Face>();
HashSet<pb_Edge> sharedEdges = new HashSet<pb_Edge>();
for(int i = 0; i < originFace.edges.Length; i++)
{
sharedEdges.Add(new pb_Edge(lookup[originFace.edges[i].x], lookup[originFace.edges[i].y]));
}
pb_Edge edge_s = new pb_Edge(-1,-1);
for(int i = 0; i < pb.faces.Length; i++)
{
foreach(pb_Edge edge in pb.faces[i].edges)
{
edge_s.x = lookup[edge.x];
edge_s.y = lookup[edge.y];
bool contains = sharedEdges.Contains(edge_s);
if( contains )
{
if(mask.Contains(pb.faces[i]))
{
continue;
}
faces.Add(pb.faces[i]);
break;
}
}
}
return faces;
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:40,代码来源:pbMeshUtils.cs
示例19: ExtrudeEdge
void ExtrudeEdge()
{
pb_Face sourceFace = lastExtrudedFace;
// fetch a random perimeter edge connected to the last face extruded
List<pb_WingedEdge> wings = pb_WingedEdge.GetWingedEdges(pb);
IEnumerable<pb_WingedEdge> sourceWings = wings.Where(x => x.face == sourceFace);
List<pb_Edge> nonManifoldEdges = sourceWings.Where(x => x.opposite == null).Select(y => y.edge.local).ToList();
int rand = (int) Random.Range(0, nonManifoldEdges.Count);
pb_Edge sourceEdge = nonManifoldEdges[rand];
// get the direction this edge should extrude in
Vector3 dir = ((pb.vertices[sourceEdge.x] + pb.vertices[sourceEdge.y]) * .5f) - sourceFace.distinctIndices.Average(x => pb.vertices[x]);
dir.Normalize();
// this will be populated with the extruded edge
pb_Edge[] extrudedEdges;
// perform extrusion
pb.Extrude(new pb_Edge[] { sourceEdge }, 0f, false, true, out extrudedEdges);
// get the last extruded face
lastExtrudedFace = pb.faces.Last();
// not strictly necessary, but makes it easier to handle element selection
pb.SetSelectedEdges( extrudedEdges );
// translate the vertices
pb.TranslateVertices(pb.SelectedTriangles, dir * distance);
// rebuild mesh with new geometry added by extrude
pb.ToMesh();
// rebuild mesh normals, textures, collisions, etc
pb.Refresh();
}
开发者ID:ChrisCrossed,项目名称:CodeExamples,代码行数:36,代码来源:ExtrudeRandomEdges.cs
示例20: CombineObjects
/**
* \brief Given an array of "donors", this method returns a merged #pb_Object.
*/
public static bool CombineObjects(pb_Object[] pbs, out pb_Object combined)
{
combined = null;
if(pbs.Length < 1) return false;
List<Vector3> v = new List<Vector3>();
List<pb_Face> f = new List<pb_Face>();
List<pb_IntArray> s = new List<pb_IntArray>();
foreach(pb_Object pb in pbs)
{
int vertexCount = v.Count;
// Vertices
{
v.AddRange(pb.VerticesInWorldSpace());
}
// Faces
{
pb_Face[] faces = new pb_Face[pb.faces.Length];
for(int i = 0; i < faces.Length; i++)
{
faces[i] = new pb_Face(pb.faces[i]);
faces[i].ShiftIndices(vertexCount);
faces[i].RebuildCaches();
}
f.AddRange(faces);
}
// Shared Indices
{
pb_IntArray[] si = pb.GetSharedIndices();
for(int i = 0; i < si.Length; i++)
{
for(int n = 0; n < si[i].Length; n++)
si[i][n] += vertexCount;
}
s.AddRange(si);
}
}
combined = pb_Object.CreateInstanceWithVerticesFacesSharedIndices(v.ToArray(), f.ToArray(), s.ToArray());
combined.CenterPivot(new int[1]{0});
return true;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:54,代码来源:pbMeshOps.cs
注:本文中的pb_Face类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论