Game Development Community

Camera position in SceneWindow

by DieRich · in Torque 2D Beginner · 10/09/2014 (4:46 am) · 2 replies

hi all, I mount Camera to a SceneObject just like the TruckToy did, I find out SceneWindow::getCameraPosition is not the same value with calculateCameraView( &mCameraCurrent ); in SceneWindow::onRender, why is this?

I just can't understand the how Camera works, could some one tell me about it?

thanks

#1
10/09/2014 (7:23 am)
The ConsoleMethod SceneWindow::getCameraPosition returns the following value
mCameraCurrent.mSourceArea.centre();

If you look at SceneWindow's calculateCameraView method, mSourceArea is used at the beginning of the method but it is not used for the final render.

The trick is that the final camera position is calculated and stored in mCameraCurrent.mDestinationArea. Once the camera limits and zoom factor are processed, mDestinationArea is what is used to render the Scene.

Fortunately, there is a ConsoleMethod to get the camera's Render position

SceneWindow::getCameraRenderPosition();

Hope this sheds some light on the mystery!
#2
10/09/2014 (7:41 am)
Thanks, it works, thanks.