www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: fireside on March 08, 2008, 04:04:26 am

Title: translation and removing, replacing objects
Post by: fireside 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.

Title: Re: translation and removing, replacing objects
Post by: EgonOlsen 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.
Title: Re: translation and removing, replacing objects
Post by: fireside on March 08, 2008, 09:11:01 pm
O.K.  Thanks, I'll check those methods out.