www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: jtxx000 on July 05, 2003, 06:36:17 pm

Title: Reset Transform
Post by: jtxx000 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?
Title: Reset Transform
Post by: EgonOlsen 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.
Title: Reset Transform
Post by: jtxx000 on July 06, 2003, 04:48:15 pm
Thanks