GamerSg
February 10, 2006, 9:55pm
1
I have the following data exported from Max:
<node id=“Bone01” sid=“Bone01” name=“Bone01” type=“JOINT”>
<translate sid=“Trans”>0.383142 -6.69906e-008 1.53257 </translate>
<rotate sid=“RotZ”>0 0 1 -0.000150564</rotate>
<rotate sid=“RotY”>0 1 0 -89.0036</rotate>
<rotate sid=“RotX”>1 0 0 90.0002</rotate>
</node>
I am trying to get a qauternion for the rotation part instead of storing multiple rotate values.
Im using the Collada DOM and doing this
Quat Final;
//for every rotate array
for(PInt oiu = 0;oiu<dn->getRotate_array().getCount();++oiu)
{
Quat q1;
q1.x = dn->getRotate_array().get(oiu)->getValue().get(0);
q1.y = dn->getRotate_array().get(oiu)->getValue().get(1);
q1.z = dn->getRotate_array().get(oiu)->getValue().get(2);
q1.w = dn->getRotate_array().get(oiu)->getValue().get(3);
q1 = q1.convertToQuat();
//muliply the converted quaternion with the earlier result
Final = q1*Final;
}
But i appear to be getting an incorrect result by doing this.(Different from the quaternion value i get in Max using MaxScript)
marcus
February 23, 2006, 5:04pm
2
GamerSg:
I have the following data exported from Max:
<node id="Bone01" sid="Bone01" name="Bone01" type="JOINT">
<translate sid="Trans">0.383142 -6.69906e-008 1.53257 </translate>
<rotate sid="RotZ">0 0 1 -0.000150564</rotate>
<rotate sid="RotY">0 1 0 -89.0036</rotate>
<rotate sid="RotX">1 0 0 90.0002</rotate>
</node>
The element is a normalized axis and an angle. The equation to convert that to a quaternion is:
qx = axis_x * sin(angle/2)
qy = axis_y * sin(angle/2)
qz = axis_z * sin(angle/2)
qw = cos(angle/2)
GamerSg:
I have the following data exported from Max:
Quat q1;
q1.x = dn->getRotate_array().get(oiu)->getValue().get(0);
q1.y = dn->getRotate_array().get(oiu)->getValue().get(1);
q1.z = dn->getRotate_array().get(oiu)->getValue().get(2);
q1.w = dn->getRotate_array().get(oiu)->getValue().get(3);
q1 = q1.convertToQuat();
What does Quat::convertToQuat() do for you? It’s likely that you must assign the correct values using the formula above. You can’t just get() them from the rotate array.
GamerSg
February 23, 2006, 8:45pm
3
I already got it working, the problem was that i wasnt converting the degrees to radian.
In my code, i read in the values as angle-axis. The convertToQuat assumes that the contents are in angle-axis form cinverts the angle-axis to a quaternion. It is a bit misleading that i used the Quat structure to store the values from the COllada document.