0

With the following Code i move a object along the x axis, and rotate it relative to its position every frame.

quad.getModel().setIdentity();
quad.getModel().scale(new Vector3f(10, 10, 10));
quad.getModel().translate(new Vector3f(x, 0, 0));
quad.getModel().rotate(x * 2, new Vector3f(0, 1f, 0f));

Now i want to remove the model.setIdentity(). How i can achieve the same thing now?

T_01
  • 1,256
  • 3
  • 16
  • 35
  • possible duplicate of [how to rotate all objects by their own centers and then translate them to the real position (it isn't working)](http://stackoverflow.com/questions/25974144/how-to-rotate-all-objects-by-their-own-centers-and-then-translate-them-to-the-re) – Spektre Oct 15 '14 at 08:25

1 Answers1

0

Okay, i figured out the solution my self. I just had to rotate it back every frame, then move it, than rotate it back. The reason is, that rotation changes the object-relative axis. So translating also moves along this new axis. Moving along the origin, or, the "old" axis, just needs to reset the rotation before that.

T_01
  • 1,256
  • 3
  • 16
  • 35