Overview
A scene consists of a set of 3D objects. Transformations such as translation, scaling and rotation brings them into life. The source for these transformations are mouse and keyboard inputs, which are further computed resulting in camera placements,
For example the following diagram shows a multi color cube with 50 degrees pitch and 20 degrees yaw. The cube looks elongated horizontally because aspect ratio is not applied.
Details
This post discusses camera and camera data that are used in projections and animations.
The Camera data 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.
Coordinate System
OpenGL uses Right hand side coordinate system where +Z is pointing towards you.
Pitch, Yaw and Roll
A 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 the mouse is dragged, delta x and delta y are computed.
The derived camera classes from BaseCamera 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:
Camera and CameraData
There are many specialized camera classes that are associated with different types of camera data.
The class diagram below shows their association, The light blue classes are camera data and the others are camera classes.
The details will be provided in the next posts.
ModelMatrixData class contains 3D transformation information such as pitch, yaw and roll angles, translation, scaleby . They are updated by by ThreeDCamera class based on mouse and keyboard inputs and are shared with 3D objects based on BaseGeometry class to redraw.
| Name | Description |
|---|---|
| pitch yaw roll | Computed values based on mouse and keyboard inputs. These are stored as degrees. |
| ScaleBy TranslateBy | Affine transformation values for scaling and Translation, These are stored 3x3 matrices. |
Methods
| Name | Description |
|---|---|
| augment | Augments itself from another ModelMatrixData object. |
| getModelMatrix | Returns self as 4x4 matrix. |
| Reset | Resets itself to scratch. |

