Get current camera view point



How can I get the current view point of the camera and how can I then use it as the starting view point for next executions?

I have a 3D representation which I can rotate, zoom, move etc., and I would like to change the initial view point when I execute the program. But first I would like to manually find it, then extract the parameters and then use those.

What are the functions to use in this case.

Many thanks.

ofEasyCam save and restore position/orientation

Hey Poiex,

I assume you are using ofCamera or ofEasyCam.

The thing to know about ofCamera’s orientation, position and scale is that these things are stored inside the camera class as part of a transformation Matrix, known as the ModelViewMatrix.

If you get this matrix, and save it somewhere for later, you can apply it down the line to set your camera to the saved position. You might also want to get & store additioinal float parameters such as fov and far and near settings, to have a more complete record of your camera.

Here’s an example:

	// ---- ofApp.h  
	ofCamera testCam;  
	ofMatrix4x4 myStoredCameraMatrix;  
	// ----- ofApp.cpp  
	myStoredCameraMatrix = testCam.getModelViewMatrix();  
	// ofMatrix4x4 myStoredCameraMatrix = ofMatrix4x4::getInverseOf(testCam.getGlobalTransformMatrix()); // alternative notation  
	// this is where you set the camera back to the stored position:  




Many thanks.

I am going to try asap and let you know.



I tried the code and it partially works. The loaded configuration is not exactly that stored. There are some parameters that are probably ignored.

Are you sure that everything is stored into the 4x4 matrix?


Which parameters are being ignored?


If the oly thing you want to do is store camera settings and load them afterwards i suggest you use ofxCameraSaveLoad. It has everything you need an it will work in 2 lines of code. Its a great addon by @roymacdonald !