Reset Transform

Started by jtxx000, July 05, 2003, 06:36:17 PM

Previous topic - Next topic

jtxx000

Is there a way to reset the current rotation and translation?  Or is there a way to set the translation/rotation absolutely, not reletively?

EgonOlsen

You may set the rotation- and translation-matrix to whatever instance of Matrix you wish. To reset them, just do:


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


or


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.

jtxx000