本文整理汇总了C#中pb_Object类的典型用法代码示例。如果您正苦于以下问题:C# pb_Object类的具体用法?C# pb_Object怎么用?C# pb_Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
pb_Object类属于命名空间,在下文中一共展示了pb_Object类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:11,代码来源:pbUndo.cs
示例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;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:33,代码来源:pb_MirrorTool.cs
示例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;
}
开发者ID:BaptisteBillet,项目名称:Prochain_Arret,代码行数:27,代码来源:AutoNodraw.cs
示例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;
}
开发者ID:flickenmaste,项目名称:R6Demake,代码行数:30,代码来源:ExplodeFaces.cs
示例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;
}
开发者ID:jeraman,项目名称:29-de-abril,代码行数:26,代码来源:RuntimeEdit.cs
示例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;
}
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:33,代码来源:pb_Entity.cs
示例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;
}
开发者ID:rickypickle,项目名称:Melody-1978,代码行数:30,代码来源:AutoNodraw.cs
示例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");
}
开发者ID:BaptisteBillet,项目名称:Prochain_Arret,代码行数:27,代码来源:StripProBuilderScripts.cs
示例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;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:29,代码来源:pbMeshUtils.cs
示例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;
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:7,代码来源:pb_Smoothing_Editor.cs
示例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);
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:12,代码来源:pb_MeshUtility.cs
示例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();
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:8,代码来源:pb_Entity_Editor.cs
示例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
}
开发者ID:ChrisCrossed,项目名称:CodeExamples,代码行数:12,代码来源:SetCustomUnwrapParams.cs
示例14: OnSelectionUpdate
void OnSelectionUpdate(pb_Object[] selection)
{
try
{
foreach(pb_Object pb in selection)
DrawElements(pb);
} catch {}
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:8,代码来源:pb_Debug_Window.cs
示例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] );
}
开发者ID:benlewis,项目名称:unhinged_vr,代码行数:55,代码来源:TriangulatePbObject.cs
示例16: DrawDimensions
/**
* \brief Draws dimensions of passed pb_Object in screen space. Must be called from OnSceneGUI
*/
public static void DrawDimensions(pb_Object pb)
{
Rect r = pb_Editor_Utility.GUIRectWithObject(pb.gameObject);
Rect info = new Rect(r.x+r.width, r.y, 400, 300);
Handles.BeginGUI();
// Handles.DrawLine( new Vector2(r.x, r.y), new Vector2(r.x+r.width, r.y) );
// Handles.DrawLine( new Vector2(r.x+r.width, r.y), new Vector2(r.x+r.width, r.y+r.height) );
GUI.Label(info, "Size: " + pb.gameObject.GetComponent<Renderer>().bounds.size);
Handles.EndGUI();
}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:14,代码来源:pb_Editor_GUI.cs
示例17: Start
/**
* Sets things in motion!
*/
public void Start()
{
pb = GetComponent<pb_Object>();
// When detaching, we're going right into a turn so we won't get the opportunity to set this in the usual Turn() spot.
// Set it here. If this is the first segment in a pipe, this value will be overwritten by Turn().
movingFaces = new pb_Face[1] { pb.faces[0] };
selectedTriangles = pb_Face.AllTriangles(movingFaces);
nrm = pb_Math.Normal(pb, movingFaces[0]);
Turn();
}
开发者ID:karl-,项目名称:pipedreams,代码行数:15,代码来源:Pipe.cs
示例18: MenuMergeObjects
// static pb_Profiler profiler = new pb_Profiler("pb_Menu_Commands");
#endif
#region Object Level
#if !PROTOTYPE
/**
* Combine selected pb_Objects to a single object.
* ProBuilder only.
*/
public static void MenuMergeObjects(pb_Object[] selected)
{
if(selected.Length < 2)
{
pb_Editor_Utility.ShowNotification("Must Select 2+ Objects");
return;
}
int option = EditorUtility.DisplayDialogComplex(
"Save or Delete Originals?",
"Saved originals will be deactivated and hidden from the Scene, but available in the Hierarchy.",
"Merge Delete", // 0
"Merge Save", // 1
"Cancel"); // 2
pb_Object pb = null;
if(option == 2) return;
if( pbMeshOps.CombineObjects(selected, out pb) )
{
pb_Editor_Utility.SetEntityType(selected[0].GetComponent<pb_Entity>().entityType, pb.gameObject);
pb_Lightmap_Editor.SetObjectUnwrapParamsToDefault(pb);
pb.Optimize();
pb.gameObject.name = "pb-MergedObject" + pb.id;
switch(option)
{
case 0: // Delete donor objects
for(int i = 0; i < selected.Length; i++)
{
if(selected[i] != null)
pbUndo.DestroyImmediate(selected[i].gameObject, "Delete Merged Objects");
}
break;
case 1:
foreach(pb_Object sel in selected)
sel.gameObject.SetActive(false);
break;
}
pbUndo.RegisterCreatedObjectUndo(pb.gameObject, "Merge Objects");
Selection.activeTransform = pb.transform;
}
if(editor)
editor.UpdateSelection();
}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:63,代码来源:pb_Menu_Commands.cs
示例19: SetPivot
private static void SetPivot(pb_Object pbo, int[] testIndices)
{
Vector3 center = Vector3.zero;
foreach (Vector3 vector in pbo.VerticesInWorldSpace(testIndices))
{
center += vector;
}
center /= testIndices.Length;
Vector3 dir = (pbo.transform.position - center);
pbo.transform.position = center;
pbo.TranslateVertices(pbo.uniqueIndices, dir);
}
开发者ID:rickypickle,项目名称:Melody-1978,代码行数:14,代码来源:PivotTool.cs
示例20: 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
注:本文中的pb_Object类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论