本文整理汇总了C#中pb_Object类的典型用法代码示例。如果您正苦于以下问题:C# pb_Object类的具体用法?C# pb_Object怎么用?C# pb_Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
pb_Object类属于命名空间,在下文中一共展示了pb_Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecordSelection
/**
* @todo - Remove this and implement a pb_Selection class that can easily be recorded for undo without
* doing this weird hcak.
*/
public static void RecordSelection(pb_Object[] pb, string msg)
{
if( pb.Sum(x => x.SelectedTriangleCount) > 256 )
RegisterCompleteObjectUndo(pb, msg);
else
RecordObjects(pb, msg);
}
示例2: Mirror
/**
* \brief Duplicates and mirrors the passed pb_Object.
* @param pb The donor pb_Object.
* @param axe The axis to mirror the object on.
* \returns The newly duplicated pb_Object.
* \sa ProBuilder.Axis
*/
public static pb_Object Mirror(pb_Object pb, Vector3 scale)
{
pb_Object p = ProBuilder.CreateObjectWithObject(pb);
p.MakeUnique();
p.transform.parent = pb.transform.parent;
p.transform.position = pb.transform.position;
p.transform.localRotation = pb.transform.localRotation;
Vector3 lScale = p.gameObject.transform.localScale;
p.transform.localScale = new Vector3(lScale.x * scale.x, lScale.y * scale.y, lScale.z * scale.z);
// if flipping on an odd number of axes, flip winding order
if( (scale.x * scale.y * scale.z) < 0)
p.ReverseWindingOrder(p.faces);
p.FreezeScaleTransform();
p.Refresh();
p.GenerateUV2(true);
pb_Editor_Utility.InitObjectFlags(p, ColliderType.MeshCollider, pb.entity.entityType);
return p;
}
示例3: 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;
}
示例4: ExplodeObject
// breaks a pb_object into a zillion* faces
public static GameObject[] ExplodeObject(pb_Object pb)
{
// disable 'ze donor
pb.gameObject.SetActive(false);
GameObject[] pieces = new GameObject[pb.faces.Length];
// extract mesh and material information for every face, and assign it to a gameobject
for(int i = 0; i < pieces.Length; i++)
{
Mesh m = new Mesh();
m.vertices = pb.GetVertices(pb.faces[i]);
m.triangles = new int[6] {0,1,2, 1,3,2};
m.normals = pb.GetNormals(pb.faces[i]);
m.uv = pb.GetUVs(pb.faces[i]);
m.RecalculateBounds();
GameObject go = new GameObject();
go.transform.position = pb.transform.position + pb_Math.PlaneNormal(m.vertices).normalized * .3f;
go.transform.localRotation = pb.transform.localRotation;
go.AddComponent<MeshFilter>().sharedMesh = m;
go.AddComponent<MeshRenderer>().sharedMaterial = pb.GetMaterial(pb.faces[i]);
pieces[i] = go;
}
return pieces;
}
示例5: FaceCheck
public bool FaceCheck(Vector3 pos)
{
Ray ray = Camera.main.ScreenPointToRay (pos);
RaycastHit hit;
if( Physics.Raycast(ray.origin, ray.direction, out hit))
{
pb_Object hitpb = hit.transform.gameObject.GetComponent<pb_Object>();
if(hitpb == null)
return false;
Mesh m = hitpb.msh;
int[] tri = new int[3] {
m.triangles[hit.triangleIndex * 3 + 0],
m.triangles[hit.triangleIndex * 3 + 1],
m.triangles[hit.triangleIndex * 3 + 2]
};
pb = hitpb;
quad = hitpb.QuadWithTriangle(tri);
return true;
}
return false;
}
示例6: Awake
/**
* \brief Performs Entity specific initialization tasks (turn off renderer for nodraw faces, hide colliders, etc)
*/
public void Awake()
{
pb = GetComponent<pb_Object>();
if(pb == null)
{
return;
}
switch(entityType)
{
case EntityType.Occluder:
// Destroy(gameObject);
break;
case EntityType.Detail:
break;
case EntityType.Trigger:
#if !DEBUG
GetComponent<MeshRenderer>().enabled = false;
#endif
break;
case EntityType.Collider:
#if !DEBUG
GetComponent<MeshRenderer>().enabled = false;
#endif
break;
}
}
示例7: 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;
}
示例8: Strip
public static void Strip(pb_Object[] all)
{
for(int i = 0; i < all.Length; i++)
{
EditorUtility.DisplayProgressBar(
"Stripping ProBuilder Scripts",
"Working over " + all[i].id + ".",
((float)i / all.Length));
Mesh m = pbUtil.DeepCopyMesh(all[i].msh);
m.name = all[i].msh.name;
GameObject go = all[i].gameObject;
DestroyImmediate(all[i]);
if(go.GetComponent<pb_Entity>())
DestroyImmediate(go.GetComponent<pb_Entity>());
go.GetComponent<MeshFilter>().sharedMesh = m;
if(go.GetComponent<MeshCollider>())
go.GetComponent<MeshCollider>().sharedMesh = m;
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Strip ProBuilder Scripts", "Successfully stripped out all ProBuilder components.", "Okay");
}
示例9: 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;
}
示例10: Init
public static pb_Smoothing_Editor Init(pb_Texture_Editor del, pb_Object[] _selection)
{
pb_Smoothing_Editor pse = (pb_Smoothing_Editor)EditorWindow.GetWindow(typeof(pb_Smoothing_Editor), true, "Smoothing Groups", true);
pse.SetDelegate(del);
pse.UpdateSelection(_selection);
return pse;
}
示例11: CollapseSharedVertices
/**
* Collapse shared vertices to a single vertex on the mesh object. Does not affect
* pb_Object vertices.
*/
public static void CollapseSharedVertices(pb_Object pb)
{
List<List<int>> merge = pb_MeshUtility.FindDuplicateVertices(pb);
Mesh m = pb.msh;
pb_MeshUtility.MergeVertices(merge, ref m);
}
示例12: OnEnable
public void OnEnable()
{
ent = (pb_Entity)target;
if(ent != null)
pb = (pb_Object)ent.transform.GetComponent<pb_Object>();
// if(ent.colliderType != pb_Entity.ColliderType.Upgraded) ent.GenerateCollisions();
}
示例13: OnProBuilderObjectCreated
/**
* When a new object is created this function is called with a reference to the pb_Object
* last built.
*/
static void OnProBuilderObjectCreated(pb_Object pb)
{
pb_UnwrapParameters up = pb.unwrapParameters;
up.hardAngle = 88f; // range: 1f, 180f
up.packMargin = 15f; // range: 1f, 64f
up.angleError = 30f; // range: 1f, 75f
up.areaError = 15f; // range: 1f, 75f
}
示例14: OnSelectionUpdate
void OnSelectionUpdate(pb_Object[] selection)
{
try
{
foreach(pb_Object pb in selection)
DrawElements(pb);
} catch {}
}
示例15: 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] );
}