Should OgreXML Bone extend Spatial (or Node)?

Much like TestTurretControl.java I want to control a bone, but the bone is not vertical like the turret.  It's part of a shoulder and has its own rotation, specified mostly by the animation it's currently doing.  So when I move the bone I want to move it according to where it already is, not from a specific axis (ie. x,y, or z) like the turret does.  To do this I need to get the current rotation of the bone, but it looks like that I can't get those rotations/transformations without making messing with the Bone.java code itself.  So my question is should Bone.java for ogrexml extend Spatial or Node so that you can easily get the world and local rotations of the bone?

should Bone.java for ogrexml extend Spatial or Node

I considered this myself when I designed the system and I concluded that extending Spatial or Node will take a significant amount of memory and overhead that is not needed for a simple use such as bone. I think your problem might be solved in a different way..
when I move the bone I want to move it according to where it already is, not from a specific axis (ie. x,y, or z) like the turret does.  To do this I need to get the current rotation of the bone, but it looks like that I can't get those rotations/transformations without making messing with the Bone.java code itself

Okay, so perhaps the issue is that you can't access the transform of the bone, if that is the issue, it can be fixed easily. Otherwise, I am bit confused on the first part. The system will update the animation, except for bones that are marked as being used-controlled. In other words, the bone you are controlling already inherits the parent's animation transform so you should already be moving the bone according to where it is supposed to be?
Momoko_Fan said:

Okay, so perhaps the issue is that you can't access the transform of the bone, if that is the issue, it can be fixed easily. Otherwise, I am bit confused on the first part. The system will update the animation, except for bones that are marked as being used-controlled. In other words, the bone you are controlling already inherits the parent's animation transform so you should already be moving the bone according to where it is supposed to be?

Sorry if I was being a bit confusing.  So for my shoulders of my character I have the top-half set to an animation of a gun holding pose, that's only 1 frame.  It looks like that when I set the bone to be user controlled, the bone is transformed to bind pose.  I guess what I should do is set the bone to the animation transformation myself (by hand), or should I comment out this in Bone.java:

    void setAnimTransforms(Vector3f translation, Quaternion rotation, Vector3f scale){
        //if (userControl)
        //    return;

        localPos.addLocal(translation);
        localRot = localRot.mult(rotation);
    }

or is there an easier way?  

Ok, I figured out how to enable it so my user transformations are done along with animations.  The issue was caused with the order of when the input vs. animation controller were updated.  I've create modifications to Bone.java  I don't really know if this is commitable because if might not apply to everybody (as seen with TestTurretControll.java).  What do you think?



Here's the diff:


@@ -69,6 +69,12 @@
      */
     private Vector3f initialPos;
     private Quaternion initialRot;
+   
+    /**
+     * The user set transforms that get set when the animation is set.
+     */
+    private Vector3f userSetPos = new Vector3f();
+    private Quaternion userSetRot = new Quaternion();
 
     /**
      * The inverse world bind transform.
@@ -190,10 +201,10 @@
      * Reset the bone and it's children to bind pose.
      */
     void reset(){
-        if (!userControl){
+        //if (!userControl){
             localPos.set(initialPos);
             localRot.set(initialRot);
-        }
+        //}
 
         for (Bone b : children)
             b.reset();
@@ -221,10 +232,12 @@
         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);
+        //localPos.set(initialPos);
+        //localRot.set(initialRot);
+        //localPos.addLocal(translation);
+        //localRot = localRot.mult(rotation);
+        userSetPos.set(translation);
+        userSetRot.set(rotation);
     }
 
 
@@ -245,11 +258,15 @@
      * 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)
+        //    return;
 
         localPos.addLocal(translation);
         localRot = localRot.mult(rotation);
+        if (userControl) {
+           localPos .addLocal(userSetPos);
+           localRot = localRot.mult(userSetRot);
+        }
     }
 
     /**

Best way is probably to have some sort of flag if you want standard animations to be applied along with user animations or if the user should have exclusive control.