Author Topic: Transform regardsless of earlier transformation or rotation  (Read 2763 times)

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Transform regardsless of earlier transformation or rotation
« 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transform regardsless of earlier transformation or rotation
« Reply #1 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...