Modifying camera position and orientation

Any question about the main GUI application (frontend)
Post Reply
ccod
Posts: 2
Joined: Thu Jun 22, 2017 4:15 pm

Modifying camera position and orientation

Post by ccod »

I would like to move the camera so that it lies on a given point of a loaded point cloud and at the same time re-orient it so that it uses a given up-vector.

I tried using the methods setCustomView() and setCameraPos() of ccGLWindow (in this order); while the orientation is ok, there seems to be some offset in the camera position with respect to the desired location. For a quick test, I set the position of the pivot to the desired location and the placeholder (i.e. yellow sphere) is indeed placed at the expected location.

Am I missing something here? Are the camera position and the pivot expressed in a different reference system?

Thank you!
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Modifying camera position and orientation

Post by daniel »

Yes, cameras are a bit tricky, especially since their behavior changes depending on the current projection mode (orthographic / object-centered perspective / user-centered perspective). In orthographic mode especially, the depth doesn't change anything (as it's an infinite projection).

However you shouldn't experience this kind of issue: when you call setPivotPoint, I guess you have left the 'autoUpdateCameraPos' parameter to false?

And are you calling these methods before the window is actually displayed / resized by Qt maybe? (random guesses ;) )
Daniel, CloudCompare admin
ccod
Posts: 2
Joined: Thu Jun 22, 2017 4:15 pm

Re: Modifying camera position and orientation

Post by ccod »

Thank you very much for the pointers! I'm always sticking to perspective projection; I only used setPivotPoint to quickly ensure that the desired position for the camera was ok, but then commented it out when actually calling setCameraPos. I haven't modified the value of autoUpdateCameraPos (in fact, I couldn't find this parameter in the files I am using), so I guess it has its default value.

I noticed that if I set the perspective mode to viewer-centered (calling m_app->getActiveGLWindow()->togglePerspective(false) ) the camera gets placed at the expectied position. Do you see any connection between the specific perspective mode used and the position of the camera?
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Modifying camera position and orientation

Post by daniel »

Indeed, the 'object-centered' perspective is a bit weird, because when you move the mouse you don't rotate the camera but the object (at least this is what the user experience).

And now that I think about it, maybe you should enable the 'autoUpdateCameraPos' parameter when calling 'setPivotPoint' (2nd parameter of this method). Because it's specifically meant to handle this weird inversion of the camera movement.
Daniel, CloudCompare admin
Post Reply