Page 1 of 1

Need Help with quaternions in libogc

Posted: Fri Feb 06, 2015 3:13 am
by psycorpse
I am trying to use quaternions and they do not appear to be working for me (Its probably me).

Here is some of the code that I am trying and its not giving me the results that I was expecting and I don't really know how to troubleshoot this.

Code: Select all

        guMtxIdentity(q);
	c_guMtxQuat(q, &cubeQuat);

        guVector axis = {0,1,0};
	guMtxRotAxisDeg(QuatMatrix, &axis, rot);
	
	// MtxQuat should take a matrix and turn it into a quat
	c_guMtxQuat(QuatMatrix, &cubeQuat);

        c_guQuatMtx(&cubeQuat, TempQuatMatrix);

	// Multiply the Rotation (QuatMatrix) with the ModelMatrix into TempModelMatrix
	guMtxConcat(TempQuatMatrix, ModelMatrix, TempModelMatrix);

When I do this, the cube that was in my view, is no longer in my view. If I took out the Quat stuff and just left the RotAxisDeg the cube would be spinning in the view.

If someone has an example that I could read and learn from that would be the best option but I will take any advice/knowledge that anyone has.