public bool Equals(pb_Selection sel) { if(sel != null && sel.IsValid()) return (pb == sel.pb && face == sel.face); else return false; }
private void SpawnCube() { pb_Object pb_Object = pb_ShapeGenerator.CubeGenerator(Vector3.one); pb_Object.gameObject.AddComponent <MeshCollider>().convex = false; currentSelection = new pb_Selection(pb_Object, null); }
public void Update() { if (!Input.GetMouseButtonUp(0) || Input.GetKey(KeyCode.LeftAlt) || !FaceCheck(Input.mousePosition) || !currentSelection.IsValid()) { return; } if (!currentSelection.Equals(previousSelection)) { previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face); RefreshSelectedFacePreview(); return; } Vector3 vector = pb_Math.Normal(currentSelection.pb.vertices.ValuesWithIndices(currentSelection.face.distinctIndices)); if (Input.GetKey(KeyCode.LeftShift)) { currentSelection.pb.TranslateVertices(currentSelection.face.distinctIndices, vector.normalized * -0.5f); } else { currentSelection.pb.TranslateVertices(currentSelection.face.distinctIndices, vector.normalized * 0.5f); } currentSelection.pb.Refresh(); RefreshSelectedFacePreview(); }
public bool Equals(pb_Selection sel) { if (sel != null && sel.IsValid()) { return(pb == sel.pb && face == sel.face); } return(false); }
/** * \brief Creates a new ProBuilder cube and sets it up with a concave MeshCollider. */ void SpawnCube() { // This creates a basic cube with ProBuilder features enabled. See the ProBuilder.Shape enum to // see all possible primitive types. pb_Object pb = pb_ShapeGenerator.CubeGenerator(Vector3.one); // The runtime component requires that a concave mesh collider be present in order for face selection // to work. pb.gameObject.AddComponent <MeshCollider>().convex = false; // Now set it to the currentSelection currentSelection = new pb_Selection(pb, null); }
/** * \brief The 'meat' of the operation. This listens for a click event, then checks for a positive * face selection. If the click has hit a pb_Object, select it. */ public void Update() { if (Input.GetMouseButtonUp(0) && !Input.GetKey(KeyCode.LeftAlt)) { if (FaceCheck(Input.mousePosition)) { if (currentSelection.IsValid()) { // Check if this face has been previously selected, and if so, move the face. // Otherwise, just accept this click as a selection. if (!currentSelection.Equals(previousSelection)) { previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face); RefreshSelectedFacePreview(); return; } Vector3 nrml = pb_Math.PlaneNormal( currentSelection.pb.VerticesInWorldSpace(currentSelection.face)); if (Input.GetKey(KeyCode.LeftShift)) { currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, nrml.normalized * -.5f); } else { currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, nrml.normalized * .5f); } // this create the selected face preview RefreshSelectedFacePreview(); } } } }
/** * \brief The 'meat' of the operation. This listens for a click event, then checks for a positive * face selection. If the click has hit a pb_Object, select it. */ public void Update() { if (Input.GetMouseButtonUp(0) && !Input.GetKey(KeyCode.LeftAlt)) { if (FaceCheck(Input.mousePosition)) { if (currentSelection.IsValid()) { // Check if this face has been previously selected, and if so, move the face. // Otherwise, just accept this click as a selection. if (!currentSelection.Equals(previousSelection)) { previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face); RefreshSelectedFacePreview(); return; } Vector3 localNormal = pb_Math.Normal(currentSelection.pb.GetVertices(currentSelection.face.distinctIndices)); Vector3 nrml = currentSelection.pb.transform.TransformDirection(localNormal); if (Input.GetKey(KeyCode.LeftShift)) { currentSelection.pb.TranslateVertices(currentSelection.face.distinctIndices, nrml.normalized * -.5f); } else { currentSelection.pb.TranslateVertices(currentSelection.face.distinctIndices, nrml.normalized * .5f); } currentSelection.pb.Refresh(); // Refresh will update the Collision mesh volume, face UVs as applicatble, and normal information. // this create the selected face preview RefreshSelectedFacePreview(); } } } }
/** * \brief Creates a new ProBuilder cube and sets it up with a concave MeshCollider. */ void SpawnCube() { // This creates a basic cube with ProBuilder features enabled. See the ProBuilder.Shape enum to // see all possible primitive types. pb_Object pb = (pb_Object)ProBuilder.CreatePrimitive(ProBuilder.Shape.Cube).GetComponent<pb_Object>(); // The runtime component requires that a concave mesh collider be present in order for face selection // to work. pb.gameObject.AddComponent<MeshCollider>().convex = false; // Now set it to the currentSelection currentSelection = new pb_Selection(pb, null); }
/** * \brief The 'meat' of the operation. This listens for a click event, then checks for a positive * face selection. If the click has hit a pb_Object, select it. */ public void Update() { if(Input.GetMouseButtonUp(0) && !Input.GetKey(KeyCode.LeftAlt)) { if(FaceCheck(Input.mousePosition)) { if(currentSelection.IsValid()) { // Check if this face has been previously selected, and if so, move the face. // Otherwise, just accept this click as a selection. if(!currentSelection.Equals(previousSelection)) { previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face); RefreshSelectedFacePreview(); return; } Vector3 nrml = currentSelection.pb.transform.TransformDirection(currentSelection.pb.FaceNormal(currentSelection.face)); if(Input.GetKey(KeyCode.LeftShift)) currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, nrml.normalized * -.5f); else currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, nrml.normalized * .5f); // this create the selected face preview RefreshSelectedFacePreview(); } } } }
/** * \brief The 'meat' of the operation. This listens for a click event, then checks for a positive * face selection. If the click has hit a pb_Object, select it. */ public void Update() { if(Input.GetMouseButtonUp(0) && !Input.GetKey(KeyCode.LeftAlt)) { if(FaceCheck(Input.mousePosition)) { if(currentSelection.IsValid()) { // Check if this face has been previously selected, and if so, move the face. // Otherwise, just accept this click as a selection. if(!currentSelection.Equals(previousSelection)) { previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face); RefreshSelectedFacePreview(); return; } Vector3 localNormal = pb_Math.Normal( pbUtil.ValuesWithIndices(currentSelection.pb.vertices, currentSelection.face.distinctIndices) );// currentSelection.pb.GetVertices(currentSelection.face.distinctIndices)); if(Input.GetKey(KeyCode.LeftShift)) currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, localNormal.normalized * -.5f ); else currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, localNormal.normalized * .5f ); currentSelection.pb.Refresh(); // Refresh will update the Collision mesh volume, face UVs as applicatble, and normal information. // this create the selected face preview RefreshSelectedFacePreview(); } } } }
public bool Equals(pb_Selection sel) { return (pb == sel.pb && face == sel.face); }
public bool Equals(pb_Selection sel) { return(pb == sel.pb && face == sel.face); }