Author Topic: Reset Transform  (Read 4761 times)

Offline jtxx000

  • byte
  • *
  • Posts: 13
    • View Profile
Reset Transform
« on: July 05, 2003, 06:36:17 pm »
Is there a way to reset the current rotation and translation?  Or is there a way to set the translation/rotation absolutely, not reletively?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Reset Transform
« Reply #1 on: July 06, 2003, 02:51:14 pm »
You may set the rotation- and translation-matrix to whatever instance of Matrix you wish. To reset them, just do:

Code: [Select]

Object3D obj=....
Matrix mat=obj.getRotationMatrix();
mat.setIdentity();
obj.setRotationMatrix(mat);


or

Code: [Select]

Matrix mat=new Matrix();
obj.setRotationMatrix(mat);


The later way involves a creation of a new Matrix object, which may be little slower, but depending on what you want to do, more appropriate.
Because getRotationMatrix() returns the reference to the rotation matrix, an obj.getRotationMatrix().setIdentity() should do the trick too, but i simply don't like to rely on such a behaviour because it may (most likely won't, but anyway...) change in the future.
Setting the translation matrix works the same way.

Offline jtxx000

  • byte
  • *
  • Posts: 13
    • View Profile
Reset Transform
« Reply #2 on: July 06, 2003, 04:48:15 pm »
Thanks