Browse Source

World/Local gizmo axis modes

Josh Engebretson 10 years ago
parent
commit
6fd42cf954

+ 4 - 0
Resources/EditorData/AtomicEditor/editor/ui/maintoolbar.tb.txt

@@ -19,3 +19,7 @@ TBLayout: distribution: gravity, spacing: 4
 		@include definitions>menubutton
 		@include definitions>menubutton
 		TBSkinImage: skin: 3DScaleBitmap
 		TBSkinImage: skin: 3DScaleBitmap
 		id 3d_scale
 		id 3d_scale
+	TBButton: toggle-mode: 1
+		lp: width: 64
+		text: "Local"
+		id 3d_axismode

+ 7 - 0
Script/AtomicEditor/ui/MainToolbar.ts

@@ -67,6 +67,13 @@ class MainToolbar extends Atomic.UIWidget {
 
 
                 return true;
                 return true;
 
 
+            } else if (ev.target.id == "3d_axismode") {
+
+                ev.target.text = ev.target.value ? "World" : "Local";
+
+                EditorUI.getShortcuts().invokeGizmoAxisModeChanged( ev.target.value ? Editor.AXIS_WORLD :  Editor.AXIS_LOCAL);
+                return true;
+
             } else if (ev.target.id == "maintoolbar_play") {
             } else if (ev.target.id == "maintoolbar_play") {
 
 
                 EditorUI.getShortcuts().invokePlay();
                 EditorUI.getShortcuts().invokePlay();

+ 7 - 13
Script/AtomicEditor/ui/Shortcuts.ts

@@ -85,21 +85,15 @@ class Shortcuts extends Atomic.ScriptObject {
         this.invokeResourceFrameShortcut("selectall");
         this.invokeResourceFrameShortcut("selectall");
     }
     }
 
 
-    invokeGizmoMode3DTranslate() {
+    invokeGizmoEditModeChanged(mode:Editor.EditMode) {
 
 
-        this.sendEvent("GizmoEditModeChanged", { mode: 1 });
+        this.sendEvent("GizmoEditModeChanged", { mode: mode });
 
 
     }
     }
 
 
-    invokeGizmoMode3DRotate() {
+    invokeGizmoAxisModeChanged(mode:Editor.AxisMode) {
 
 
-        this.sendEvent("GizmoEditModeChanged", { mode: 2 });
-
-    }
-
-    invokeGizmoMode3DScale() {
-
-        this.sendEvent("GizmoEditModeChanged", { mode: 3 });
+        this.sendEvent("GizmoAxisModeChanged", { mode: mode });
 
 
     }
     }
 
 
@@ -119,11 +113,11 @@ class Shortcuts extends Atomic.ScriptObject {
             // TODO: Make these customizable
             // TODO: Make these customizable
 
 
             if (ev.key == Atomic.KEY_W) {
             if (ev.key == Atomic.KEY_W) {
-                this.invokeGizmoMode3DTranslate();
+                this.invokeGizmoEditModeChanged(Editor.EDIT_MOVE);
             } else if (ev.key == Atomic.KEY_E) {
             } else if (ev.key == Atomic.KEY_E) {
-                this.invokeGizmoMode3DRotate();
+              this.invokeGizmoEditModeChanged(Editor.EDIT_ROTATE);
             } else if (ev.key == Atomic.KEY_R) {
             } else if (ev.key == Atomic.KEY_R) {
-                this.invokeGizmoMode3DScale();
+                this.invokeGizmoEditModeChanged(Editor.EDIT_SCALE);
             }
             }
 
 
         }
         }

+ 13 - 1
Script/TypeScript/AtomicWork.d.ts

@@ -64,7 +64,7 @@ declare module Atomic {
         qualifiers: number;
         qualifiers: number;
         // mouse buttons down
         // mouse buttons down
         buttons:number;
         buttons:number;
-              
+
     }
     }
 
 
     export interface UIShortcutEvent {
     export interface UIShortcutEvent {
@@ -242,6 +242,18 @@ declare module AtomicNET {
 
 
 }
 }
 
 
+declare module Editor {
+
+  export interface GizmoEditModeChangedEvent {
+    mode:EditMode;
+  }
+
+  export interface GizmoAxisModeChangedEvent {
+    mode:AxisMode;
+  }
+  
+}
+
 declare module ToolCore {
 declare module ToolCore {
 
 
     export interface ResourceAddedEvent {
     export interface ResourceAddedEvent {

+ 5 - 0
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.cpp

@@ -416,6 +416,11 @@ void Gizmo3D::Drag()
 
 
 }
 }
 
 
+void Gizmo3D::SetAxisMode(AxisMode mode)
+{
+    axisMode_ = mode;
+}
+
 void Gizmo3D::SetEditMode(EditMode mode)
 void Gizmo3D::SetEditMode(EditMode mode)
 {
 {
     editMode_ = mode;
     editMode_ = mode;

+ 2 - 1
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.h

@@ -109,7 +109,8 @@ public:
 
 
     void SetView(SceneView3D* view3D);
     void SetView(SceneView3D* view3D);
 
 
-    void SetEditMode(EditMode);
+    void SetAxisMode(AxisMode mode);
+    void SetEditMode(EditMode mode);
 
 
     bool Selected()
     bool Selected()
     {
     {

+ 8 - 0
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -85,6 +85,7 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, UITabCon
     SubscribeToEvent(E_EDITORACTIVENODECHANGE, HANDLER(SceneEditor3D, HandleEditorActiveNodeChange));
     SubscribeToEvent(E_EDITORACTIVENODECHANGE, HANDLER(SceneEditor3D, HandleEditorActiveNodeChange));
 
 
     SubscribeToEvent(E_GIZMOEDITMODECHANGED, HANDLER(SceneEditor3D, HandleGizmoEditModeChanged));
     SubscribeToEvent(E_GIZMOEDITMODECHANGED, HANDLER(SceneEditor3D, HandleGizmoEditModeChanged));
+    SubscribeToEvent(E_GIZMOAXISMODECHANGED, HANDLER(SceneEditor3D, HandleGizmoAxisModeChanged));
 
 
     // FIXME: Set the size at the end of setup, so all children are updated accordingly
     // FIXME: Set the size at the end of setup, so all children are updated accordingly
     // future size changes will be handled automatically
     // future size changes will be handled automatically
@@ -223,6 +224,13 @@ void SceneEditor3D::HandleGizmoEditModeChanged(StringHash eventType, VariantMap&
     gizmo3D_->SetEditMode(mode);
     gizmo3D_->SetEditMode(mode);
 }
 }
 
 
+void SceneEditor3D::HandleGizmoAxisModeChanged(StringHash eventType, VariantMap& eventData)
+{
+    AxisMode mode = (AxisMode) ((int)eventData[GizmoEditModeChanged::P_MODE].GetFloat());
+    gizmo3D_->SetAxisMode(mode);
+}
+
+
 void SceneEditor3D::Close(bool navigateToAvailableResource)
 void SceneEditor3D::Close(bool navigateToAvailableResource)
 {
 {
 
 

+ 1 - 0
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3D.h

@@ -61,6 +61,7 @@ private:
     void HandlePlayStarted(StringHash eventType, VariantMap& eventData);
     void HandlePlayStarted(StringHash eventType, VariantMap& eventData);
     void HandlePlayStopped(StringHash eventType, VariantMap& eventData);
     void HandlePlayStopped(StringHash eventType, VariantMap& eventData);
     void HandleGizmoEditModeChanged(StringHash eventType, VariantMap& eventData);
     void HandleGizmoEditModeChanged(StringHash eventType, VariantMap& eventData);
+    void HandleGizmoAxisModeChanged(StringHash eventType, VariantMap& eventData);
     void HandleNodeRemoved(StringHash eventType, VariantMap& eventData);
     void HandleNodeRemoved(StringHash eventType, VariantMap& eventData);
 
 
     SharedPtr<Scene> scene_;
     SharedPtr<Scene> scene_;

+ 5 - 0
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3DEvents.h

@@ -18,6 +18,11 @@ EVENT(E_GIZMOEDITMODECHANGED, GizmoEditModeChanged)
     PARAM(P_MODE, MODE);            // int
     PARAM(P_MODE, MODE);            // int
 }
 }
 
 
+EVENT(E_GIZMOAXISMODECHANGED, GizmoAxisModeChanged)
+{
+    PARAM(P_MODE, MODE);            // int
+}
+
 EVENT(E_GIZMOMOVED, GizmoMoved)
 EVENT(E_GIZMOMOVED, GizmoMoved)
 {
 {
 
 

+ 0 - 15
Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

@@ -161,26 +161,11 @@ void SceneView3D::MoveCamera(float timeStep)
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ = Clamp(pitch_, -90.0f, 90.0f);
         pitch_ = Clamp(pitch_, -90.0f, 90.0f);
-        // Not working on OSX
-        //input->SetMouseMode(MM_RELATIVE);
     }
     }
-    else
-    {
-        // Not working on OSX
-        /*
-        if (input->GetMouseMode() != MM_ABSOLUTE)
-            input->SetMouseMode(MM_ABSOLUTE);
-        */
-    }
-
 
 
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
     cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
 
 
-    //Vector3 pos = cameraNode_->GetWorldPosition();
-    //Quaternion q = cameraNode_->GetWorldRotation();
-    //LOGINFOF("%f %f %f : %f %f %f %f", pos.x_, pos.y_, pos.z_, q.x_, q.y_, q.z_, q.w_ );
-
 #ifdef ATOMIC_PLATFORM_WINDOWS
 #ifdef ATOMIC_PLATFORM_WINDOWS
     bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
     bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
 #else
 #else