Message 1 of 2
Silly Rotation Key Question

Not applicable
12-10-2008
02:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hola Folks,
I am using 3DSM 8. I am not using IGame (nor do I intend to). I have played with various conversion methods available in the SDK. None of the values appear to be correct. I am not sure if I am doing something incorrectly or not.
I would like to know the best way of getting the angle of rotation in degrees from a rotation key.
The objective is to create a description file that shows the time (seconds, ticks and frame) of a rotation key, the axis of rotation and the angle / amount of rotation in degrees. It does not help the reader of the file to see angle axis values or quaternion values.
The method I am using is shown below.
From the declaration section:
A snippet from the method that extracts the data from the key:
Thank You
-isdi-
I am using 3DSM 8. I am not using IGame (nor do I intend to). I have played with various conversion methods available in the SDK. None of the values appear to be correct. I am not sure if I am doing something incorrectly or not.
I would like to know the best way of getting the angle of rotation in degrees from a rotation key.
The objective is to create a description file that shows the time (seconds, ticks and frame) of a rotation key, the axis of rotation and the angle / amount of rotation in degrees. It does not help the reader of the file to see angle axis values or quaternion values.
The method I am using is shown below.
From the declaration section:
int i, numKeys;
Control* oControl;
Quat newQuat, prevQuat;
IKeyControl *ikeys;
ITCBRotKey tcbRotKey;
RotationValue oRotVal;
Point3 p3;
A snippet from the method that extracts the data from the key:
// --- Process the rotation keys ---
// Get the rotation controller
oControl = oNode->GetTMController()->GetRotationController();
// Get the key controller from the rotation controller
ikeys = GetKeyControlInterface(oControl);
if (!ikeys)
{
LogToFile(pObjLogStream, true, "@info", "KeyTest.", "Rotation Key. No rotation keys are available.");
} else {
// Get the number of rotation keys
numKeys = ikeys->GetNumKeys();
bRez += numKeys;
sprintf(sTmp1, "%d rotation key(s).", numKeys);
LogToFile(pObjLogStream, true, "Rotation Key Count", sTmp1);
if (oControl->ClassID() == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0))
{
for (i = 0; i < numKeys; i++)
{
ikeys->GetKey(i, &tcbRotKey);
lTimePosSeconds = lTimePosTicks / (float)TIME_TICKSPERSEC;
newQuat = QFromAngAxis(tcbRotKey.val.angle, tcbRotKey.val.axis);
if (i>0) {
newQuat = prevQuat * newQuat;
}
// Quick Test
AngAxis rval;
rval = AngAxis(newQuat/prevQuat);
// End Quick Test
prevQuat = newQuat;
// Write the key data
fprintf(pObjAnimStream, "\t\t%i %.6f %.6f %.6f %.6f\n",
lTimePosSeconds,
newQuat.x, newQuat.y, newQuat.z, newQuat.w
);
// Write Test Output Data
fprintf(pObjAnimStream, "#\t\t%i %.6f %.6f %.6f %.6f\n",
lTimePosSeconds,
tcbRotKey.val.axis.x, tcbRotKey.val.axis.y, tcbRotKey.val.axis.z, tcbRotKey.val.angle
);
oRotVal.Set(newQuat);
p3 = oRotVal.Euler();
fprintf(pObjAnimStream, "#\t\tP3: %.6f %.6f %.6f\n",
lTimePosSeconds,
p3.x, p3.y, p3.z
);
fprintf(pObjAnimStream, "#\t\tRVal: %.6f %.6f %.6f %.6f\n",
rval.angle, rval.axis.x, rval.axis.y, rval.axis.z
);
float fAngle = 0.0f;
QuatToEuler(newQuat, &fAngle);
fprintf(pObjAnimStream, "#\t\tfAngle: %f\n", fAngle);
}
} else if (oControl->ClassID() == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0)) {
...
} else if (oControl->ClassID() == Class_ID(LININTERP_ROTATION_CLASS_ID, 0)) {
...
} else {
...
}
}
Thank You
-isdi-