protected override void HandleTriggerDown(Transform controller, int controllerIndex) { MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); Vector3 position = Settings.SnapEnabled() ? Snap.WorldPosition(mesh.transform, controller.position) : controller.position; mesh.vertices.CreateAndAddVertexInstanceByWorldPosition(position); }
public static void UpdateMode() { Mesh mesh = Meshes.GetSelectedMesh(); if (!mesh) { return; } mesh.alignmentTools.SetActiveCollidersOnAlignmentTools(false); if (mode == ModeType.AlignmentDelete) { mesh.alignmentTools.SetActiveCollidersOnAlignmentTools(true); } switch (mode) { case ModeType.AlignmentX: case ModeType.AlignmentY: case ModeType.AlignmentZ: case ModeType.Alignment3d: case ModeType.AlignmentDelete: /* * if (!Settings.AlignmentToolsEnabled()) { * mode = ModeType."vertex"; * } */ break; } }
public void SaveAndOpen(string path = null) { if (path == null || path == "") { path = openPath; } MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); unsavedPanel.SetVisible(false); mesh.Save(); OpenWithoutSave(path); }
protected override void BuildPrimitiveController() { if (primitiveControllerInstance == null) { BuildPrimitiveController <BoxSelectionController>(); MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); BoxSelectionController boxSelectionController = primitiveControllerInstance.GetComponent <BoxSelectionController>(); boxSelectionController.realMesh = mesh; boxSelectionController.CreateMesh(); } }
protected void BuildPrimitiveController <T>() where T : PrimitiveBaseController { if (primitiveControllerInstance == null) { primitiveControllerInstance = Instantiate(GetPrimitivePrefab(), controller.position, controller.rotation); MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); primitiveControllerInstance.transform.parent = mesh.gameObject.transform; primitiveControllerInstance.GetComponent <T>().mesh = mesh; hasInitialized = true; } }
public void SaveAs(string path, Transform controller, int controllerIndex) { Debug.Log("FileManager.SaveAs"); MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); mesh.selection.ClearSelectedVertices(); mesh.vertices.DeleteVertexInstances(); mesh.triangles.DeleteTriangleInstances(); mesh.persistence.Save(path); PanelManager.HideAllPanels(null); notificationPanel.DisplayMessage("Saved", controller, controllerIndex); Mode.SetMode(Mode.mode); }
public void Save(string path, Transform controller, int controllerIndex) { MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); if (mesh.persistence.HasSavedOrLoaded()) { mesh.persistence.Save(); notificationPanel.DisplayMessage("Saved", controller, controllerIndex); } else { saveAsPanel.SetVisible(true, controller, controllerIndex); } }
public void OpenWithoutSave(string path = null) { if (path == null || path == "") { path = openPath; } MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); PanelManager.HideAllPanels(null); mesh.selection.ClearSelectedVertices(); mesh.vertices.DeleteVertexInstances(); mesh.triangles.DeleteTriangleInstances(); mesh.persistence.Load(path); Mode.SetMode(Mode.mode); }
public void Open(string path, Transform controller, int controllerIndex) { Debug.Log("FileManager.Open"); MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); if (mesh.persistence.changedSinceLastSave) { openPath = path; unsavedPanel.SetVisible(true, controller, controllerIndex); } else { OpenWithoutSave(path); } }
protected override void ClickHandler(Transform controller, int controllerIndex) { MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); mesh.ResetTransform(); }
public override void OnGrabStart(Transform controller, int controllerIndex) { base.OnGrabStart(controller, controllerIndex); MeshEngine.Mesh mesh = Meshes.GetSelectedMesh(); mesh.GetComponent <MeshInputController>().OnGrabStart(controller, controllerIndex); }
public static void SetMode(ModeType value) { ModeType oldMode = mode; mode = value; Mesh mesh = Meshes.GetSelectedMesh(); if (!mesh) { return; } //Debug.Log("oldMode=" + oldMode + ",mode=" + mode); if (!Modes.noDelete.Contains(mode)) { mesh.selection.ClearSelectedVertices(); mesh.vertices.DeleteVertexInstances(); mesh.triangles.DeleteTriangleInstances(); mesh.alignmentTools.SetActiveCollidersOnAlignmentTools(false); mesh.SetRenderOptions(true, true, true); mesh.triangles.autoCreateTriangleObjects = false; mesh.triangles.SetTriangleInstancesSelectable(true); } if (mode != ModeType.SelectVerticesByTriangles) { mesh.vertices.SetVertexInstancesSelectable(true); } switch (mode) { case ModeType.AlignmentDelete: mesh.alignmentTools.SetActiveCollidersOnAlignmentTools(true); if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.Settings: mode = oldMode; if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.Tools: mode = oldMode; if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.Open: mode = oldMode; if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.SaveAs: //meshController.keyboardPanelController.ToggleVisible(); mode = oldMode; if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.DeselectAll: mesh.selection.Clear(); mesh.copy.Clear(); mode = oldMode; if (OnModeChanged != null) { OnModeChanged(); } return; case ModeType.Vertex: case ModeType.Face: case ModeType.Delete: mesh.vertices.CreateVertexInstances(); break; case ModeType.PrimitiveSphere: case ModeType.PrimitiveCircle: case ModeType.PrimitiveCylinder: case ModeType.PrimitivePlane: case ModeType.PrimitiveBox: mesh.vertices.CreateVertexInstances(); mesh.triangles.autoCreateTriangleObjects = true; mesh.SetRenderOptions(false, false, false); mesh.triangles.SetTriangleInstancesSelectable(false); mesh.triangles.CreateTriangleInstances(); break; case ModeType.SelectVertices: mesh.vertices.CreateVertexInstances(false); mesh.triangles.SetTriangleInstancesSelectable(false); mesh.triangles.CreateTriangleInstances(); mesh.SetRenderOptions(false, false, false); break; case ModeType.SelectVerticesByTriangles: mesh.vertices.SetVertexInstancesSelectable(false); mesh.vertices.CreateVertexInstances(false); mesh.triangles.SetTriangleInstancesSelectable(true); mesh.triangles.CreateTriangleInstances(); mesh.SetRenderOptions(false, false, false); break; case ModeType.BoxSelect: mesh.vertices.CreateVertexInstances(false); mesh.triangles.autoCreateTriangleObjects = true; mesh.triangles.SetTriangleInstancesSelectable(false); mesh.triangles.CreateTriangleInstances(); mesh.SetRenderOptions(false, false, false); break; case ModeType.Normal: case ModeType.Fill: case ModeType.TriangleDelete: case ModeType.SelectTriangles: case ModeType.PickColor: mesh.SetRenderOptions(false, false, false); mesh.triangles.CreateTriangleInstances(); break; } if (!Modes.noSelectionClear.Contains(mode)) { mesh.selection.Clear(); mesh.copy.Clear(); } if (Modes.endingInTriangleSelection.Contains(oldMode) && !Modes.noTriangleSelectionClear.Contains(mode)) { mesh.selection.Clear(); mesh.copy.Clear(); } if (Modes.endingInSelection.Contains(oldMode) && mode == ModeType.DeleteSelection) { mesh.selection.DeleteSelected(); mesh.triangles.DeleteTriangleInstances(); // This shouldn't be necessary, but there is a bug somewhere mesh.triangles.SetTriangleInstancesSelectable(false); mesh.triangles.CreateTriangleInstances(); // ditto mesh.SetRenderOptions(false, false, false); mode = ModeType.SelectVertices; } if ((Modes.endingInSelection.Contains(oldMode) || Modes.endingInTriangleSelection.Contains(oldMode)) && mode == ModeType.FillSelection) { mesh.selection.FillSelected(); mesh.SetRenderOptions(false, false, false); mode = (oldMode == ModeType.SelectTriangles) ? ModeType.SelectTriangles : ModeType.SelectVertices; } if (Modes.endingInSelection.Contains(oldMode) && mode == ModeType.Extrude) { mesh.extrusion.ExtrudeSelected(true); mesh.SetRenderOptions(false, false, false); mesh.triangles.SetTriangleInstancesSelectable(false); mode = ModeType.SelectVertices; } if (oldMode == ModeType.SelectVertices && mode == ModeType.MergeVertices) { mesh.vertices.MergeSelected(); mesh.SetRenderOptions(false, false, false); mode = ModeType.SelectVertices; } if ((Modes.endingInSelection.Contains(oldMode) || Modes.endingInTriangleSelection.Contains(oldMode)) && mode == ModeType.SelectionFlipNormal) { mesh.triangles.FlipNormalsOfSelection(); mesh.SetRenderOptions(false, false, false); mode = (oldMode == ModeType.SelectTriangles) ? ModeType.SelectTriangles : ModeType.SelectVertices; } if (Modes.endingInSelection.Contains(oldMode) && mode == ModeType.Copy) { mesh.copy.CopySelection(); mesh.SetRenderOptions(false, false, false); mode = ModeType.SelectVertices; } if (Modes.endingInSelection.Contains(oldMode) && mode == ModeType.Paste) { mesh.selection.Clear(); mesh.triangles.autoCreateTriangleObjects = true; mesh.copy.Paste(); mesh.SetRenderOptions(false, false, false); mode = ModeType.SelectVertices; } if (oldMode != ModeType.Object && mode == ModeType.Object) { mesh.triangles.trianglesChanged = true; mesh.EnableBoxCollider(); } if (oldMode == ModeType.Object && mode != ModeType.Object) { mesh.DisableBoxCollider(); } if (OnModeChanged != null) { OnModeChanged(); } }