Author Topic: Store and load rotation objetos3D  (Read 1964 times)

Offline MegasXLS

  • byte
  • *
  • Posts: 29
    • View Profile
Store and load rotation objetos3D
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Store and load rotation objetos3D
« Reply #1 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.

Offline Marlon

  • int
  • **
  • Posts: 74
    • View Profile
    • Forgotten Elements Action MMORPG
Re: Store and load rotation objetos3D
« Reply #2 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);
www.forgottenelements.com
Free Action JAVA MMORPG