Problem in rotating child nodes?

This is not a bug, it's a feature.

If you apply a transformation to a node, all of its children will inherit that transformation. This is one of the most prominent principles of scene graphs… If you do not want the wheels to be affected, then the wheels shouldn't be attached to the chassis but be attached to a common parent instead.

Momoko_Fan said:

This is not a bug, it's a feature.
If you apply a transformation to a node, all of its children will inherit that transformation. This is one of the most prominent principles of scene graphs.. If you do not want the wheels to be affected, then the wheels shouldn't be attached to the chassis but be attached to a common parent instead.


I haven't explained the problem well:
I want that wheels rotate on Y axis together with chassis, but at the same time I want that wheels rotate on their X axis. It seems to me that this rotation happens on X world axis and not on X local axis of wheels
thanks
bye

Okay now I think I found it:

wheels.getLocalRotation().multLocal(rotQuat);


This is not a legal move in jME3. You are not allowed to alter the rotation received from getLocalRotation(). After altering it, you should call setLocalRotation() to denote that you changed it (in other words, modifying the rotation received from getLocalRotation() does nothing).

It seems that problem is in Transform class, I've made following change and everything is fine with rotation of child nodes:



Index: src/jme3_core/com/jme3/math/Transform.java
===================================================================
--- src/jme3_core/com/jme3/math/Transform.java   (revision 4853)
+++ src/jme3_core/com/jme3/math/Transform.java   (working copy)
@@ -182,7 +182,7 @@
      */
     public Transform combineWithParent(Transform parent) {
         scale.multLocal(parent.scale);
-        rot.multLocal(parent.rot);
+        rot =  parent.rot.mult(rot);
         parent
             .rot
             .multLocal(translation)

KevinK said:

It seems that problem is in Transform class, I've made following change and everything is fine with rotation of child nodes:


Index: src/jme3_core/com/jme3/math/Transform.java
===================================================================
--- src/jme3_core/com/jme3/math/Transform.java   (revision 4853)
+++ src/jme3_core/com/jme3/math/Transform.java   (working copy)
@@ -182,7 +182,7 @@
      */
     public Transform combineWithParent(Transform parent) {
         scale.multLocal(parent.scale);
-        rot.multLocal(parent.rot);
+        rot =  parent.rot.mult(rot);
         parent
             .rot
             .multLocal(translation)




GREAT!!!
you've found the solution. I can confirm that it works fine
thanks

Ah okay, so transforms were not combined in the correct way, I will apply this change to my local copy.

truman said:

GREAT!!!
you've found the solution. I can confirm that it works fine
thanks

Glad to help. I had no choice but to fix it in order for my project to work correctly. :)