Spatial Transformer rotations

Is there a way to add rotations to a spatial transformer without it resetting on its first position…?



anyway… yeah I saw the spatial rotation example in the package although… what I saw in the code…



rotationTransformer.setRotation(0,2,new Quaternion().fromAngleAxis(90 * FastMath.DEG_TO_RAD, VECTOR3F.UNIT_Y));

rotationTransformer.setRotation(0,2,new Quaternion().fromAngleAxis(180 * FastMath.DEG_TO_RAD, VECTOR3F.UNIT_Y));



makes a continuous 180 degree rotation using axis VECTOR3F.UNIT_Y for a total of four seconds.....
when I tried to change the code....


rotationTransformer.setRotation(0,2,new Quaternion().fromAngleAxis(90 * FastMath.DEG_TO_RAD, VECTOR3F.UNIT_Y));

rotationTransformer.setRotation(0,2,new Quaternion().fromAngleAxis(90 * FastMath.DEG_TO_RAD, VECTOR3F.UNIT_X));



what I imagined it to be was it would rotate 90 degrees right for 2 seconds then 90 degrees up for 2 seconds...
what happened was... yeah it rotated 90 degrees right... although its position was reset on the first point where its first rotation happened... then rotated 90 degrees up....awwwww... can someone enlighten me on this matter?

btw... I know I could just do this


rotationTransformer.setRotation(0,2,new Quaternion().fromAngleAxis(90 * FastMath.DEG_TO_RAD, new Vector3f(1,1,0)));



but it doesn't quite get me what I want with my animation.... what if I wanted a rotation of 90 in x axis and 45 on y..... this solution wouldn't help me either... please help  :D

You could:

Quaternion newRotation = rotationTransformer.getRotation().add(new Quaternion().fromAngleAxis(90 * FastMath.DEG_TO_RAD, VECTOR3F.UNIT_X);
rotationTransformer.setRotation(0,2,newRotation);



Hope that helps  :D

hi again… sorry to bother you… it seems that there is .getLocalRotation().add() method in nodes… although it doesn't exist within SpatialTransformers… like what you have replied to me as "rotationTransformer.getRotation…"



I'm sorry if I would sought more help from yous



edit:


Quaternion newRotation = new Quaternion();
      newRotation.fromAngleAxis(90 * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);
      newRotation.add(new Quaternion().fromAngleAxis(90* FastMath.DEG_TO_RAD, Vector3f.UNIT_Y));
      camRotationTransformer.setRotation(0, 3, newRotation);



I tried this.... although it doesn't help me either

try newRotation.addLocal instead of newRotation.add… :wink:

that helped my computation problems… although it deformed my shape while doing the rotation… although I haven't tried updateGeometricState()…

well I got something that could help me… I browsed through the jmonkeyengine site and found a guide towards rotations… it seems you can slerp between 2 points… :mrgreen:



LOL… thanks for all the help guys… specially tim8dev



here it is:


Quaternion q1 = new Quaternion().fromAngleAxis(90* FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);

Quaternion q2 = new Quaternion().fromAngleAxis(90* FastMath.DEG_TO_RAD, Vector3f.UNIT_X);

q1.slerp(q1, 0.5f); //goes halfway between the two rotations

pivotNode.setLocalRotation(q1);




this does the 45 degree x and 45 degree y rotation I wanted which can also be achieved by
new Quaternion().fromAngleAxis(45 * FastMath.DEG_TO_RAD, new Vector3f(1,1,0));
although more complex problems such as 90degrees x 45 degrees y... right? so I recommend the aforementioned code better.... hope this helps anyone having the same problems....xD
LOL.. thanks for all the help guys... specially tim8dev


No problem :wink:

well I got something that could help me... I browsed through the jmonkeyengine site and found a guide towards rotations.... it seems you can slerp between 2 points... afro

I'm sorry :D I should have mentioned this.... there's the User Guide in the Wiki, wich probably explains Rotation best ;)