Author Topic: Rotation on group of objects  (Read 1723 times)

Offline tollos

  • byte
  • *
  • Posts: 13
    • View Profile
Rotation on group of objects
« on: June 12, 2013, 05:28:54 pm »
Hello,

I'm currently working on my own animation module for my game. Very simple stuff with only textured rectangles and pivot nodes.
I don't want to use Bones or any other tool, the objective is to make mine ... and to avoid using any 3D modeling tools since I'm totally bad at modeling  ;-)

My problem is about rotations. If I have a character with head, torso, legs, arms, ... and I need to perform a rotation on the whole character I have no idea how to do it (without using setChild()).
I have a "main" object, the head in this case and this one turns perfectly with something like that :

Code: [Select]
Matrix mat = new Matrix( target.calcSub( head.gettranslatedCenter()).normalize()).getRotationMatrix() );
head.setRotationMatrix(mat);

But my problem are the other Object3D of the model, if I apply the same they just turn to the correct direction on their center axis but without moving of course.
I was thinking about a rotation on the Y axis, but no idea how to compute the angle they should turn.

Thanks in advance !




Offline tollos

  • byte
  • *
  • Posts: 13
    • View Profile
Re: Rotation on group of objects
« Reply #1 on: June 13, 2013, 11:04:57 am »
Forget about it, by adding all my model's parts to the reference one (the head) as addChild() it works perfectly for movement and rotations ;-)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Rotation on group of objects
« Reply #2 on: June 13, 2013, 03:46:09 pm »
That's what i would have suggested anyway... :)