Author Topic: Camera.getPosition() returns vector[0.0,0.0,0.0] unless setPosition() called  (Read 1821 times)

Offline icmobilelab

  • byte
  • *
  • Posts: 2
    • View Profile
Hey,

Firstly, apologies if this is intended behaviour for some reason and I haven't picked it up from the docs.

I have been working the past week with JPCT-AE (Excellent btw) and similar to some posts in the forum am integrating with the Vuforia AR SDK.

I set the BackBuffer matrix of the camera based on the pose matrix and this works fine for rendering my world. (I use Invert3x3 on the rotation sub matrix).

However I was trying to make the light eminate from the camera by setting sun position based on camera position but I always get vector[0.0,0.0,0.0] returned from Camera.getPosition(). Camera.getDirection() seems to be updating fine based on the back buffer.

Based on my back buffer matrix the camera position and orientation seem to be correct:
[R00][R01][R02][]
[R10][R11][R12][]
[R20][R21][R22][]
[TrX][TrY][TrZ][1]

My thought is perhaps when calling SetOrientation this construct the appropriate rotation matrix in the backbuffer and when calling setPosition it creates the correct translation matrix in the back buffer taking account of the rotation matrix. but perhaps there is also a position member of Camera updated during setPosition and this member isn't updated when setting the back buffer directly?

Maybe Camera could override BufferedMatrix.setBack(Matrix mat) so it could set member variable(if my assumption is correct) indicating position? Or if a performance penalty with this extra calc is likely another Camera.setBack(Matrix mat, Boolean calcPosition) function added to the camera class?

Thank You For your time,

Lee

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
It's not a bug, it's by design. We had this topic a few times IIRC...its not advised to use the camera's matrix for anything but a rotation matrix. If you want to store a position, don't do it in this matrix but by using setPosition() instead. Overriding setBack() and do the splitting there might work...just give it a try.