Game Development Reference
In-Depth Information
void CLink::CreateMatrix()
{
//HPB
double ch,sh,cp,sp,cb,sb;
ch = cos(rot.x); sh = sin(rot.x);
cp = cos(rot.y); sp = sin(rot.y);
cb = cos(rot.z); sb = sin(rot.z);
right.x = ch*cb-sh*sp*sb;
right.y = -cp*sb;
right.z = -sh*cb-ch*sp*sb;
up.x = ch*sb+sh*sp*cb;
up.y = cp*cb;
up.z = -sh*sb+ch*sp*cb;
forward.x= sh*cp;
forward.y= -sp;
forward.z= ch*cp;
if (parent){
//Concatentate the parents rotation matrix which must already
//have been calculated, otherwise the positions will be in
//error
double t1,t2,t3;
t1 = parent->right.x*right.x + parent->up.x*right.y
+ parent->forward.x*right.z;
t2 = parent->right.y*right.x + parent->up.y*right.y
+ parent->forward.y*right.z;
t3 = parent->right.z*right.x + parent->up.z*right.y
+ parent->forward.z*right.z;
right.x = t1; right.y = t2; right.z = t3;
t1 = parent->right.x*up.x + parent->up.x*up.y
+ parent->forward.x*up.z;
t2 = parent->right.y*up.x + parent->up.y*up.y
+ parent->forward.y*up.z;
t3 = parent->right.z*up.x + parent->up.z*up.y
+ parent->forward.z*up.z;
up.x = t1; up.y = t2; up.z = t3;
t1 = parent->right.x*forward.x + parent->up.x*forward.y
+ parent->forward.x*forward.z;
t2 = parent->right.y*forward.x + parent->up.y*forward.y
+ parent->forward.y*forward.z;
t3 = parent->right.z*forward.x + parent->up.z*forward.y
Search Nedrilad ::




Custom Search