/*---------------------------------------------------------------------- GetScale() Purpose: gets the scale of an animated object with a certain name In parameters: al - the linked list of Animations name - the name of the Animation time - the time of the wanted scale Out parameters: Sout - the scale in the x-, y-, and z-directions at time Returns: TRUE if there was a scale with "name", else FALSE (and the scale is then (1,1,1) Note: this routine does not check if the object is visible or not. ----------------------------------------------------------------------*/ int GetScale(Stack<Animation*> *al,char* name, double time, double Sout[3]) { Animation* a = FindAnimation(name,al); if(a) { _GetScale(a, time, Sout); return TRUE; } Sout[0]=Sout[1]=Sout[2]=1.0; return FALSE; }
void _GetMatrix(Animation* animation, double time, double m[4][4]) { Animation* a = (Animation*) animation; /* m = translation * rotation * scale */ /* Rotation. */ if(a->rotations) { double drot[4]; _GetRotation(a, time, drot); Rotation3 RR; RR.x = drot[0]; RR.y = drot[1]; RR.z = drot[2]; RR.angle = drot[3]; Quaternion q; FromAngleAxis(&q, RR.angle, RR.x, RR.y, RR.z); QuatToMatrix(&q, m); /* Also sets bottom row to 0 0 0 1 */ } else { m[0][0] = 1; m[0][1] = 0; m[0][2] = 0; m[0][3] = 0; m[1][0] = 0; m[1][1] = 1; m[1][2] = 0; m[1][3] = 0; m[2][0] = 0; m[2][1] = 0; m[2][2] = 1; m[2][3] = 0; m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1; } /* Concatenate with scaling. */ if(a->scales) { double S[3]; _GetScale(a, time, S); m[0][0] *= S[0]; m[0][1] *= S[1]; m[0][2] *= S[2]; m[1][0] *= S[0]; m[1][1] *= S[1]; m[1][2] *= S[2]; m[2][0] *= S[0]; m[2][1] *= S[1]; m[2][2] *= S[2]; } /* Translation. */ if(a->translations) { double P[3]; _GetTranslation(a, time, P); m[0][3] = P[0]; m[1][3] = P[1]; m[2][3] = P[2]; } }
int GetScale(struct AnimationList *al, char* name, double time, double Sout[3]) { void* a = FindAnimation(name, al); Animation* anim = (Animation*) a; if(a) { _GetScale(anim, time, Sout); return TRUE; } Sout[0] = Sout[1] = Sout[2] = 1.0; return FALSE; }