private bool DrawBoneSelection() { if (viewModel.PreviousModelFactory == null) { return(false); } NPVoxBoneModel previewModel = viewModel.EditorModelFactory.GetProduct() as NPVoxBoneModel; if (previewModel == null) { return(false); } if (!viewModel.IsBoneSelectionActive()) { return(false); } NPVoxToUnity npVoxToUnity = new NPVoxToUnity(previewModel, viewModel.Animation.MeshFactory.VoxelSize); // affected area picker if (Event.current.isMouse && Event.current.type == EventType.MouseDown && Event.current.button == 0) { // NPVoxCoord someCoord = NPVoxCoord.INVALID; float mouseScale = NPVoxHandles.GetMouseScale(SceneView.currentDrawingSceneView.camera); Camera cam = SceneView.currentDrawingSceneView.camera; Ray r = SceneView.currentDrawingSceneView.camera.ScreenPointToRay( new Vector3(Event.current.mousePosition.x * mouseScale, -Event.current.mousePosition.y * mouseScale + Camera.current.pixelHeight) ); NPVoxRayCastHit raycastHit = npVoxToUnity.Raycast(r, ((NPVoxAnimationEditorSession)target).previewFilter.transform, 20); if (raycastHit.IsHit) { uint boneMask = previewModel.GetBoneMask(raycastHit.Coord); if (boneMask != 0) { if (Event.current.control || Event.current.command) { viewModel.ToggleBoneMask(boneMask, Event.current.shift); } else { viewModel.SetBoneMask(boneMask, Event.current.shift); } } } } return(true); }
private void MouseInput() { int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType eventType = Event.current.GetTypeForControl(controlID); Event e = Event.current; float mouseScale = NPVoxHandles.GetMouseScale(SceneView.currentDrawingSceneView.camera); Ray r = Camera.current.ScreenPointToRay(new Vector3(Event.current.mousePosition.x * mouseScale, -Event.current.mousePosition.y * mouseScale + Camera.current.pixelHeight)); bool bShiftHeld = e.shift; bool bAltHeld = e.alt; bool bCtrlHeld = e.control; if (Event.current.mousePosition.y < TOOLBAR_HEIGHT) { // allow to click the buttons always return; } // if (viewModel.CurrentTool == GNBlockMapEditorVM.Tool.ERASE) if (inputController.IsErasingActive()) { Handles.color = new Color(128, 0, 0, 0.25f); Handles.CubeCap(controlID, viewModel.CurrentCell, Quaternion.identity, viewModel.CellSize); } if (inputController.IsPrefabNavigationActive()) { Handles.color = new Color(128, 128, 0, 0.05f); Handles.CubeCap(controlID, viewModel.CurrentCell, Quaternion.identity, viewModel.CellSize); } if (inputController.IsPickingActive()) { Handles.color = new Color(128, 128, 0, 0.25f); Handles.CubeCap(controlID, viewModel.CurrentCell, Quaternion.identity, viewModel.CellSize); } if (inputController.IsRotationActive()) { Handles.color = new Color(0, 128, 0, 0.05f); Handles.CubeCap(controlID, viewModel.CurrentCell, Quaternion.identity, viewModel.CellSize); } switch (eventType) { case EventType.Layout: if (inputController.TakeEvents()) { HandleUtility.AddControl( controlID, HandleUtility.DistanceToCircle(r.origin, 10f) ); } break; case EventType.MouseDown: if (HandleUtility.nearestControl == controlID && e.button == 0) { GUIUtility.hotControl = controlID; if (inputController.MouseDown(e)) { e.Use(); SceneView.RepaintAll(); } } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUI.changed = true; GUIUtility.hotControl = 0; e.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { if (inputController.MouseDrag(RayCast(r))) { e.Use(); SceneView.RepaintAll(); } } break; case EventType.ScrollWheel: if (inputController.WheelScrolled(e.delta, bShiftHeld, bAltHeld, bCtrlHeld)) { e.Use(); if (inputController.MouseMoved(RayCast(r))) { } SceneView.RepaintAll(); } break; case EventType.MouseMove: if (inputController.MouseMoved(RayCast(r))) { e.Use(); SceneView.RepaintAll(); } break; } }