Game Development Reference
In-Depth Information
+ parent->forward.z*forward.z;
forward.x = t1; forward.y = t2; forward.z = t3;
pos.x = parent->length * parent->right.x + parent->pos.x;
pos.y = parent->length * parent->right.y + parent->pos.y;
pos.z = parent->length * parent->right.z + parent->pos.z;
}
for (int i=0; i<4; i++){
dispts[i].x = orgpts[i].x * right.x + orgpts[i].y * up.x
+ orgpts[i].z * forward.x + pos.x;
dispts[i].y = orgpts[i].x * right.y + orgpts[i].y * up.y
+ orgpts[i].z * forward.y + pos.y;
dispts[i].z = orgpts[i].x * right.z + orgpts[i].y * up.z
+ orgpts[i].z * forward.z + pos.z;
}
}
To solve the double link problem the demo uses the following function:
void CIKDemoDoc::SolveDoubleLink()
{
double sin2, cos2, totallength, x, y, tan1;
CLink *link1, *link2;
if (links.next->next){
link1 = links.next;
link2 = link1->next;
}else{
return;
}
//Check solution is possible
x = target.x - link1->pos.x;
y = -target.y - link1->pos.y;
totallength = sqrt(x*x + y*y);
if (totallength < (link1->length + link2->length)){
cos2 = (x * x +y *y - link1->length * link1->length -
link2->length * link2->length)/
(2 * link1->length * link2->length);
link2->rot.z = acos(cos2);
sin2 = sin(link2->rot.z);
tan1 = (-(link2->length * sin2 * x) + ((link1->length +
(link2->length * cos2)) *y))/
Search Nedrilad ::




Custom Search