Creating the transform
Transforms are simple structures. A transform contains a position, rotation, and scale. Position and scale are vectors and rotation is a quaternion. Transforms can be combined hierarchically, but this parent-child relationship should not be a part of the actual transform structure. The following steps will guide you through creating a transform structure:
- Create a new file,
Transform.h
. This file is required to declare the transform structure. - Begin declaring the
Transform
structure in this new file. Start with the properties of the transform—position
,rotation
, andscale
:struct Transform { Â Â Â Â vec3 position; Â Â Â Â quat rotation; Â Â Â Â vec3 scale;
- Create a constructor that takes a position, rotation, and scale. This constructor should assign these values to the appropriate members of the Transform struct:
Transform(const vec3& p, const quat& r, const vec3& s) : Â Â ...