Author Topic: translation and removing, replacing objects  (Read 3243 times)

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
translation and removing, replacing objects
« on: March 08, 2008, 04:04:26 am »
1.  Is there a way to move the object back to zero,zero,zero so you can translate in world space?  Once an object has been moved it gets confusing to place it in world space.

2.  What do you recommend for removing an object and putting another in it's place?

3.  There are some things in javadoc about getOrigen(), setOrigen() could this be used to reset objects to their initial positions?  I would like to reset all objects to their initial position, I guess that means I don't want to actually destroy the objects that will be replaced with other objects.

« Last Edit: March 08, 2008, 04:09:42 am by fireside »
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: translation and removing, replacing objects
« Reply #1 on: March 08, 2008, 11:51:29 am »
To reset them, simply do:

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

setOrigin(...) is meant as an offset that doesn't affect child objects in its translation. It's not meant to reset objects in space.

To replace an object with another one at the same position with the same coordinates, do something like:

Code: [Select]
newObj.setTranslationMatrix(oldObj.getTranslationMatrix().cloneMatrix());
newObj.setRotationMatrix(oldObj.getRotationMatrix().cloneMatrix());

That should do the trick.
« Last Edit: March 08, 2008, 04:39:28 pm by EgonOlsen »

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: translation and removing, replacing objects
« Reply #2 on: March 08, 2008, 09:11:01 pm »
O.K.  Thanks, I'll check those methods out.
click here->Fireside 7 Games<-