فهرست منبع

SDK SceneComposer : fixed camera transformation type now works for move and scale tool, but act realy weird with rotate tool.

Maselbas 10 سال پیش
والد
کامیت
8b8425ba68
1فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 10 4
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/PickManager.java

+ 10 - 4
sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/PickManager.java

@@ -31,7 +31,8 @@ public class PickManager {
     private Quaternion origineRotation;
     private final Node plane;
     private Spatial spatial;
-
+    private SceneComposerToolController.TransformationType transformationType;
+    
     protected static final Quaternion PLANE_XY = new Quaternion().fromAngleAxis(0, new Vector3f(1, 0, 0));
     protected static final Quaternion PLANE_YZ = new Quaternion().fromAngleAxis(-FastMath.PI / 2, new Vector3f(0, 1, 0));//YAW090
     protected static final Quaternion PLANE_XZ = new Quaternion().fromAngleAxis(FastMath.PI / 2, new Vector3f(1, 0, 0)); //PITCH090
@@ -64,14 +65,15 @@ public class PickManager {
 
     public void setTransformation(Quaternion planeRotation, SceneComposerToolController.TransformationType type) {
         Quaternion rot = new Quaternion();
-        if (type == SceneComposerToolController.TransformationType.local) {
+        transformationType = type;
+        if (transformationType == SceneComposerToolController.TransformationType.local) {
             rot.set(spatial.getWorldRotation());
             rot.multLocal(planeRotation);
             origineRotation = spatial.getWorldRotation().clone();
-        } else if (type == SceneComposerToolController.TransformationType.global) {
+        } else if (transformationType == SceneComposerToolController.TransformationType.global) {
             rot.set(planeRotation);
             origineRotation = new Quaternion(Quaternion.IDENTITY);
-        } else if (type == SceneComposerToolController.TransformationType.camera) {
+        } else if (transformationType == SceneComposerToolController.TransformationType.camera) {
             rot.set(planeRotation);
             origineRotation = planeRotation.clone();
         }
@@ -79,6 +81,10 @@ public class PickManager {
     }
 
     public boolean updatePick(Camera camera, Vector2f screenCoord) {
+        if(transformationType == SceneComposerToolController.TransformationType.camera){
+            origineRotation = camera.getRotation();
+            plane.setLocalRotation(camera.getRotation());
+        }
         finalPickLoc = SceneEditTool.pickWorldLocation(camera, screenCoord, plane, null);
         return finalPickLoc != null;
     }