I'm coding an Orientation class for my objects and I just decided I wanted to improve the one I had.

I was using the GLM library and I was doing this for each object:

mat4 modelCenter = glm::mat4(1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 obj.cx, obj.cy, obj.cz, 1); //obj.rotX and rotY are floats that I use cos and sin to calculate quat modelRotationQ = quat(vec3(0, obj.rotY, obj.rotX)); mat4 modelRotation = mat4_cast(modelRotationQ); mat4 modelTranslation = glm::mat4(1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 obj.x, obj.y, obj.z, 1); mat4 modelTransformation = modelTranslation * modelRotation * modelCenter; mat4 modelViewProjection = mat4Projection * mat4View * modelTransformation;

My camera also was using a sin/cos for the rotations and I used the **glm::lookAt** function to get it's matrix.

It works, but I don't think it's good and I'd like to try and improve it.

I'm trying to ditch GLM and get my own classes so I can understand exactly what's going on with my objects.

class Vector3 { public: Vector3() { x = y = z = 0; } float x, y, z; }; class Matrix4x4 { public: float matrix[4][4]; }; class Orientation { public: private: Matrix4x4 _transformation; Vector3 _position; Vector3 _scale; };

So each object will have an Orientation, and I'll only calculate the matrix of transformation if it's required (the object has been updated) so I avoid doing all those calculations every frame, and I'll just work with the values in the vectors since it's easy to handle and I don't need to generate matrices to update an object's transformation.

Object* newObject = new Object(); newObject->_rotation.x += 90.0f; //adds 90 degrees in X newObject->_position.x += 10.0f; //translate //During render //Get the vectors values and set up a matrix4x4 once Matrix4x4 objectTransformation = newObject->GetTransformation();

The problem is, I've read a bunch of tutorials about matrices, vectors and quaternions, but I only managed to implement what was given to me. I think I don't really "understand" matrices transformations, so I'm looking for some help running me through this or any source/tutorial that does it in a very newbie level.