Quote:Original post by thedustbustr
OK, how do you handle an object (or camera's) orientation without using two matrices (or quats)? When you do translations you typically mean worldspace, but when you do rotations you typically mean localspace. Also, the opposite needs to be possible- what if you want to rotate in worldspace? I don't understand how you can achieve this without keeping them seperate.
[edit] Additionally, do you keep your rotations, translations, and scales seperate, let them accumulate, then concatenate them right before submitting to OGL (like in the shown code local() method)? Another way that produced good results, but I don't understand why, is just multiplying the local matrix by the rotation matrix in the rotate method, instead of accumulating rotations seperate from everything else.
My "coordinate system" class contains vector and quaternion.
With matrices, to rotate camera around local Y axis, i would do that:
camera_coordinate_system=camera_coordinate_system*my_turn;
I have overloaded * on coordinate systems that works exactly as for 4x4 matrices.
If i want to rotate camera around global y axis, i do that:
camera_coordinate_system=my_turn*camera_coordinate_system;
It will work same way with matrices if you load inverse into opengl. Otherwise, if you store matrix that should be loaded as is, reverse order of multiplications and use inverse turn (because (AB)-1=B-1A-1).
If i want to rotate camera around global Y axis without moving it, i do that:
camera_coordinate_system.orientation=my_turn*camera_coordinate_system.orientation;
where orientation may be either matrix or quaternion, works same way, at least with conventions i use.
edit: as ajas95 have pointed, there is probably something wrong with column/row major.
It is possible that your matrix lib works in directX-like way, so you'll need to do all matrix multiplications in different order.
It is possible to screw up with matrices in really many different ways. Just like with any other math thing.