www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: ErDetEnAnd? on September 04, 2008, 01:21:30 pm

Title: Transform regardsless of earlier transformation or rotation
Post by: ErDetEnAnd? on September 04, 2008, 01:21:30 pm
Hi.

I have 3 objects. 1 parent and 2 children. The parent should always be in the middle of the screen, and when clicking on a child, the clicked child center should transform to the parent center. The children share the same matrices, thus the children are transformed by same vector.

My approach only works when the objects are neither transformed nor rotated.
I calculate the subvector between the parent and the clicked child, then translates their matrix, but the result is dependant on ealier transformation and rotation. I dont think I have the correct understance of the two.

Where am I wrong?
Title: Re: Transform regardsless of earlier transformation or rotation
Post by: EgonOlsen on September 04, 2008, 02:17:37 pm
You may reset rotations and transformations by doing something like:

Code: [Select]
Object3D.getRotationMatrix().setIdentity();

Object3D.getTranslationMatrix().setIdentity();

or, which is more correct when wearing the encapsulation glasses (but produces more overhead):

Code: [Select]
Object3D.setRotationMatrix(new Matrix());

Object3D.setTranslationMatrix(new Matrix());

Maybe this helps...