Browse Source

Added a setLocalTranslation and setLocalScale to the Bone class. Similarly to setLocalRotation it only works when userControl is set to true and fails otherwise.
Also I changed how the value is set (with a set(...)) because it was assigning the passed parameter to the local instance of the transform.

Rémy Bouquet 9 năm trước cách đây
mục cha
commit
be6d2765e3
1 tập tin đã thay đổi với 36 bổ sung2 xóa
  1. 36 2
      jme3-core/src/main/java/com/jme3/animation/Bone.java

+ 36 - 2
jme3-core/src/main/java/com/jme3/animation/Bone.java

@@ -812,13 +812,47 @@ public final class Bone implements Savable {
         output.writeSavableArrayList(children, "children", null);
     }
 
+    /**
+     * Sets the rotation of the bone in object space.
+     * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
+     * @param rot
+     */
     public void setLocalRotation(Quaternion rot){
         if (!userControl) {
             throw new IllegalStateException("User control must be on bone to allow user transforms");
         }
-        this.localRot = rot;
+        this.localRot.set(rot);
     }
-    
+
+    /**
+     * Sets the position of the bone in object space.
+     * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
+     * @param pos
+     */
+    public void setLocalTranslation(Vector3f pos){
+        if (!userControl) {
+            throw new IllegalStateException("User control must be on bone to allow user transforms");
+        }
+        this.localPos.set(pos);
+    }
+
+    /**
+     * Sets the scale of the bone in object space.
+     * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
+     * @param scale the scale to apply
+     */
+    public void setLocalScale(Vector3f scale){
+        if (!userControl) {
+            throw new IllegalStateException("User control must be on bone to allow user transforms");
+        }
+        this.localScale.set(scale);
+    }
+
+    /**
+     * returns true if this bone can be directly manipulated by the user.
+     * @see #setUserControl(boolean)
+     * @return
+     */
     public boolean hasUserControl(){
         return userControl;
     }