www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: MegasXLS on January 13, 2012, 07:58:59 pm

Title: Store and load rotation objetos3D
Post by: MegasXLS on January 13, 2012, 07:58:59 pm
Hello everyone,

I'm having a little problem in storing 3D objects in a database for subsequent loading of objects in the same places left by the user. How do I load the rotation of objects stored in the database objects in the scene? For the translation I'm using .getTranslation (), but I do not know how to make the rotation.

o//

P. S. I am brazilian, sorry for bad english

Thx in advance.
Title: Re: Store and load rotation objetos3D
Post by: EgonOlsen on January 13, 2012, 08:01:37 pm
What's wrong with getRotationMatrix()? You can get an array-dump from a Matrix, which might be suitable to be stored in a DB more than the Matrix itself.
Title: Re: Store and load rotation objetos3D
Post by: Marlon on January 18, 2012, 10:08:29 pm
Rotation of an object:
Code: [Select]
object3D.rotateY(getModel().getDegree()/360f * PI);

Rotate to another object:
Code: [Select]
SimpleVector curPos = object3D.getTranslation();
SimpleVector targetDir = targetObject.calcSub(curPos);
float scale = object3D.getScale();
object3D.setScale(1f);
object3D.setRotationMatrix(newDir.getRotationMatrix());
object3D.setScale(scale);