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(); }
/** * \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(); } } } }