jPCT - a 3d engine for Java > Support

Reset Transform

(1/1)

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:


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

--- End code ---


or


--- Code: ---
Matrix mat=new Matrix();
obj.setRotationMatrix(mat);

--- End code ---


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:
Thanks

Navigation

[0] Message Index

Go to full version