Author Topic: How to get camera position  (Read 2338 times)

Angelo

  • Jr. Member
  • **
  • Posts: 32
How to get camera position
« on: April 20, 2012, 11:41:36 PM »
I saw that the camera (which is a VolumeManipulator) has a "setPosition" method. I was looking for a "getPosition" method, or any other technique that would allow me to get this information.

Angelo

  • Jr. Member
  • **
  • Posts: 32
Re: How to get camera position
« Reply #1 on: April 20, 2012, 11:47:44 PM »
I saw that the camera's perspective matrix (which I access through camera.getProjection().getPerspectiveMatrix()) has a lot of useful methods:

getLookAtForward(Vec3)
getLookAtLeft(Vec3)
...
getTranslationLocal(Vec3)
getTranslationWorld(Vec3)

I would like to know what that Vec3 parameter is used for.

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: How to get camera position
« Reply #2 on: April 20, 2012, 11:57:00 PM »
You can get/set VolumeManipulator matrix using setLookAt and getLookAt, this will give you position and orientation informations with Mat4x4.getLookAt* methods. The setPosition method was in fact an old method which may be removed.
VolumeManipulator camera implementation is intented for manipulation volume (model, ....), you may which to use a different/your own implementation if you need different behavior.

The Vec3 getter parameters are destination vector for storing result.
All the math api is design this way (for performance reasons): it's up to you to allocate (or reuse) destination object.