Overview
In this post discusses camera and camera data that is used in projections and animations.
It holds transformation information such as pitch, yaw and roll angles, translation, scaleby as well as Model, View and Projection matrix information of the 3D object.
Details
Coordinate System
OpenGL uses Right hand side coordinate system where +Z is pointing towards you.
An 3D object can rotate along all the three axes as shown below.
Rotation along X Axis is called Pitch. Rotation along Y Axis is called Yaw. Rotation along Z Axis is called Roll
Pitch(X Axis) Yaw (Y Axis) Roll (Z Axis)
For example, in BaseCamera class, if a key is pressed, its scan code is stored. similarly, if mouse left button is pressed and mouse is moved and then released, delta x and delta y are computed.
The derived camera classes from BaseCamera may use this information to further compute and store additional information in camera data structures.
For Example, ThreeDCamera class implements keyboard and mouse handling as below:
X key => rotate around X axis by 10 degrees.
Y key => rotate around X axis by 10 degrees.
Z key => rotate around Z axis by 10 degrees.
Mouse Drag using left button => Compute Delta X, and Delta Y.
Later this is shared with 3D objects in the scene to draw.
BaseCamera and CameraData
There different types of Camera Data to store different types of information. There are associated with specialized camera classes to process data differently.
The following diagram depicts relation between BaseCamera and various Camera Data structures. The details of these are Discussed later.
The following discusses BaseCamera class in detail. The other classes will be discussed in later posts.
BaseCamera
BaseCamera implements handlers for mouse and keyboard events. This is a base class that can be further specialized. It's located in VedaOGLLib\Scene\BaseCamera.h.
| Name | Description |
|---|---|
| windowrect clientrect | Upon events like resize, windowrect and clientrect are updated. windowrect stores window rectangle of the hosting window after calling GetWindowRect() method. clientrect stores client rectangle of the hosting window after calling GetClientRect() method. |
| mouseX,mouseY deltaX,deltaY | Upon mouse move event, the current X and Y coordinates are stored in mouseX and mouseY. Delta of X and Y coordinates are stored in deltaX and deltaY. |
| mouseLeftDown mouseMiddleDown mouseRightDown | Upon mouse button down event, one of these is set to true based on the button pressed. Rest are set to false. |
Methods
| Name | Description |
|---|---|
| CenterCursor | This method places the cursor at the center of the screen. |
| OnKey | This method handles keyboard input events. |
| OnMouseBtnDown | This method handle mouse button click events. |
| OnMouseMove | This method handle mouse move events. |
| OnMouseWheel | This method handles Mouse scroll wheel inputs. |
| UpdateWH | This method handles window resize events. |


