I was implementing some quaternion rotations in too my infant 3d game engine and the rotations were really strange? Excuses my cluelessness.
Anyways this is what I have:
static XMVECTOR XMConvertToQuaternion(XMFLOAT3 axis, float radian)
{
axis = XMNormalize3(axis);
XMVECTOR tempAxis = XMVectorSet(axis.x, axis.y, axis.z, 1);
XMVECTOR q = XMQuaternionRotationAxis(tempAxis, radian);
return q;
}
Then later on down when I apply the quaternion to the world matrix I have:
XMMATRIX scaling = XMMatrixScaling(scale.x, scale.y, scale.z);
XMMATRIX rotateX = XMMatrixRotationX(radianRotation.x);
XMMATRIX rotateY = XMMatrixRotationY(radianRotation.y);
XMMATRIX rotateZ = XMMatrixRotationZ(radianRotation.z);
XMMATRIX rotateQX = XMMatrixRotationQuaternion(MathHelper::XMConvertToQuaternion(axis, radianRotation.x));
XMMATRIX rotateQY = XMMatrixRotationQuaternion(MathHelper::XMConvertToQuaternion(axis, radianRotation.y));
XMMATRIX rotateQZ = XMMatrixRotationQuaternion(MathHelper::XMConvertToQuaternion(axis, radianRotation.z));
XMMATRIX translate = XMMatrixTranslation(translation.x, translation.y, translation.z);
XMStoreFloat4x4(&mWorld, scaling*rotateQX*rotateQY*rotateQZ*translate);
I did get a rotation. However, the character is rotating very strangely.