How to reset direction of object

Started by alex, May 07, 2009, 11:18:09 AM

Previous topic - Next topic

alex

I want to reset  objects which  are rotated ,but I can't get the direction when these objects are Loaded.
these objects has been roteted (by rotateX()),i try to get original direction of these(by getOrigin() ),bescause of i didn't use setOrigin() giving these a original direction ,i can't get the direction i needed .
how can i get the direction ?
thanks.

alex

Incidentally , my ultimate goal is Making the world back to the initial state,Namely,back to the state object loaded.
now ,i have reseted the camera in  world.

fireside

#2
You can save the rotation matrix by object.getRotationMatrix()  and reset by object.setRotationMatrix(saved_matrix).
click here->Fireside 7 Games<-

paulscode

Yes, as fireside suggests, save the rotation matrix.  One thing I would add is that you might need to clone the rotation matrix to save it (depending on what jPCT does behind the scenes, I don't know if this is necessary):

Matrix savedMatrix = object.getRotationMatrix().cloneMatrix();

And then to reset, do the same:

object.setRotationMatrix( savedMatrix.cloneMatrix() );

Egon, is this necessary, or does jPCT automatically clone the matrix in these methods rather than using the actual instance passed to them?

fireside

#4
Also, it's necessary to set the scale to 1 before using that function and resetting the scale after rotation, so you need getScale to do that.  It's in the function def.
click here->Fireside 7 Games<-

EgonOlsen

Quote from: paulscode on May 07, 2009, 01:36:47 PM
Egon, is this necessary, or does jPCT automatically clone the matrix in these methods rather than using the actual instance passed to them?
Yes, it is. The methods work with the direct references...yes , it's bug prone that way, but when calling these methods very often, it's too slow otherwise.