Modifications to OgreXML Bone

So this is the brainchild of this thread: http://www.jmonkeyengine.com/forum/index.php?topic=12921



It adds a flag so that the user control transforms can be combined with currently playing animation.  I think this will be useful to many especially for those developing a FPS, or such game. 



The flag is invoked by a call on a bone instance:

bone.setCombineUserControlAndAnimation(true);



Here's the diff for com.jmex.ogrexml.anim.Bone.java

@@ -54,9 +54,16 @@
 
     /**
      * If enabled, user can control bone transform with setUserTransforms.
-     * Animation transforms are not applied to this bone when enabled.
+     * By default, animation transforms are not applied to this bone when
+     * enabled, unless you enable combineUserControlAndAnimation.
      */
     boolean userControl = false;
+   
+    /**
+     * If enabled, the user control bone transforms will be added/multipled to
+     * the animation transforms.
+     */
+    boolean combineUserControlAndAnimation = false;
 
     /**
      * The attachment node.
@@ -69,6 +76,12 @@
      */
     private Vector3f initialPos;
     private Quaternion initialRot;
+   
+    /**
+     * The user set transforms that get set when the animation is set.
+     */
+    private Vector3f userSetPos;
+    private Quaternion userSetRot;
 
     /**
      * The inverse world bind transform.
@@ -123,12 +136,32 @@
 
     /**
      * If enabled, user can control bone transform with setUserTransforms.
-     * Animation transforms are not applied to this bone when enabled.
+     * By default, animation transforms are not applied to this bone when
+     * enabled, unless you call setCombineUserControlAndAnimation(true).
      */
     public void setUserControl(boolean enable){
         userControl = enable;
+        if (enable) {
+           userSetPos = new Vector3f();
+           userSetRot = new Quaternion();
+        } else {
+           userSetPos = null;
+           userSetRot = null;
+        }       
     }
+   
+    /**
+     * If enabled, the user control bone transforms will be added/multipled to
+     * the animation transforms.
+     */
+    public void setCombineUserControlAndAnimation(boolean enable){
+        if (!userControl)
+            throw new IllegalStateException("User control must be on bone to allow the combination of user control and animations." +
+                  " Just call bone.setUserControl(true); for this bone.");
 
+        combineUserControlAndAnimation = enable;
+    }
+
     void addChild(Bone bone) {
         children.add(bone);
         bone.parent = this;
@@ -190,10 +223,8 @@
      * Reset the bone and it's children to bind pose.
      */
     void reset(){
-        if (!userControl){
-            localPos.set(initialPos);
-            localRot.set(initialRot);
-        }
+        localPos.set(initialPos);
+        localRot.set(initialRot);
 
         for (Bone b : children)
             b.reset();
@@ -221,10 +252,8 @@
         if (!userControl)
             throw new IllegalStateException("User control must be on bone to allow user transforms");
 
-        localPos.set(initialPos);
-        localRot.set(initialRot);
-        localPos.addLocal(translation);
-        localRot = localRot.mult(rotation);
+        userSetPos.set(translation);
+        userSetRot.set(rotation);
     }
 
 
@@ -245,11 +274,17 @@
      * Bone is assumed to be in bind pose when this is called.
      */
     void setAnimTransforms(Vector3f translation, Quaternion rotation, Vector3f scale){
-        if (userControl)
-            return;
+        if (userControl) {           
+              localPos.addLocal(userSetPos);
+              localRot = localRot.mult(userSetRot);
+           if (!combineUserControlAndAnimation) {
+              return;
+           }           
+        }
 
         localPos.addLocal(translation);
         localRot = localRot.mult(rotation);
+
     }
 
     /**



Should this be committed?  Would this be useful to enough people?