So, I'm interested in building a Transform class similar to the one used in Unity Engine, but in C++. My intent is for it to be user-friendly to change the position, rotation, and scale of a variable by specifying vec3s for each, where the rotation vector specifies Euler angles or some equivalent. However, the math library I have written uses quaternions, and I'd like rotations to be represented internally by quaternions. Since quaternions are a bit difficult to use on their own, or without an axis-angle conversion of some sort, I was wondering what's the best way to do this conversion somewhat efficiently on the fly, so the user doesn't need to fiddle around with quaternions? My current header file is as follows (I haven't written the implementation yet, aside from referencing the private global vectors to the public const ones):
class Transform
{
public:
Transform();
~Transform();
//// Local Information ////
// Position relative to parent
vec3 LocalPosition;
// Scale relative to parent
vec3 LocalScale;
// Rotation about x,y,z axes relative to parent
vec3 LocalRotation;
// Transformation matrix from worldspace to local space
mat4 WorldToLocal() const;
//// Global Information ////
// Position relative to world (const)
const vec3 &WorldPosition;
// Scale relative to world (const)
const vec3 &WorldScale;
// Rotation about x,y,z axes relative to world (const)
const vec3 &WorldRotation;
// Transformation matrix from local space to world space
mat4 LocalToWorld() const;
private:
vec3 _WorldPosition, _WorldScale, _WorldRotation;
// Stores rotation as a quaternion
// ??? Do I need one for global and local? How does this relate to rotation vec3? ???
quat _RotationRaw;
};
All help is greatly appreciated. I'm usually pretty good at solving these issues but I'm at a loss on this one.
Edit: Forgot to mention that I've read over the other GameDev Stack posts on the Unity Transform class, but I couldn't glean any info about this issue from them.