diff options
Diffstat (limited to 'src/Skeleton.cpp')
-rw-r--r-- | src/Skeleton.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp index 23892b8..62861b4 100644 --- a/src/Skeleton.cpp +++ b/src/Skeleton.cpp @@ -48,7 +48,7 @@ void Joint::DoConstraint() void Muscle::DoConstraint(int broken) { oldlength=length; - relaxlength=findDistance(parent1->position,parent2->position); + relaxlength = len(parent1->position - parent2->position); if(type==boneconnect)strength=1; if(type==constraint)strength=0; @@ -131,7 +131,7 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) offset = true; if (whichtri != -1 && collide->normals[whichtri].y <= 0.8) { - normalrotated = DoRotation(collide->normals[whichtri], 0, rotation, 0); + normalrotated = rotate(collide->normals[whichtri], 0, rotation, 0); pos = impact + normalrotated * offset; reflect(&joints[i].velocity, normalrotated); joints[i].velocity *= 0.3; @@ -264,11 +264,12 @@ void Skeleton::FindRotationJoint(int which) temppoint1=joints[which].position; temppoint2=joints[which].parent->position; - distance=findDistance(temppoint1,temppoint2); + distance = len(temppoint1 - temppoint2); joints[which].rotate2=asin((temppoint1.y-temppoint2.y)/distance)*rad2deg; temppoint1.y=0; temppoint2.y=0; - joints[which].rotate1=acos((temppoint1.z-temppoint2.z)/findDistance(temppoint1,temppoint2))*rad2deg; + joints[which].rotate1 = rad2deg * acos((temppoint1.z - temppoint2.z) + / len(temppoint1 - temppoint2)); if(temppoint1.x>temppoint2.x)joints[which].rotate1=360-joints[which].rotate1; if(joints[which].label==head)tempforward=specialforward[0]; else if(joints[which].label==rightshoulder||joints[which].label==rightelbow||joints[which].label==rightwrist||joints[which].label==righthand)tempforward=specialforward[1]; @@ -277,8 +278,8 @@ void Skeleton::FindRotationJoint(int which) else if(joints[which].label==lefthip||joints[which].label==leftknee||joints[which].label==leftankle)tempforward=specialforward[4]; else if(!joints[which].lower)tempforward=forward; else if(joints[which].lower)tempforward=lowforward; - tempforward=DoRotation(tempforward,0,joints[which].rotate1-90,0); - tempforward=DoRotation(tempforward,0,0,joints[which].rotate2-90); + tempforward=rotate(tempforward,0,joints[which].rotate1-90,0); + tempforward=rotate(tempforward,0,0,joints[which].rotate2-90); tempforward.y=0; tempforward = normalize(tempforward); joints[which].rotate3=acos(0-tempforward.z)*rad2deg; @@ -292,12 +293,12 @@ void Skeleton::FindRotationMuscle(int which) temppoint1=muscles[which].parent1->position; temppoint2=muscles[which].parent2->position; - distance=findDistance(temppoint1,temppoint2); + distance = len(temppoint1 - temppoint2); muscles[which].rotate2=asin((temppoint1.y-temppoint2.y)/distance)*rad2deg; temppoint1.y=0; temppoint2.y=0; - muscles[which].rotate1=acos((temppoint1.z-temppoint2.z)/findDistance(temppoint1,temppoint2)); - muscles[which].rotate1*=360/6.28; + muscles[which].rotate1 = rad2deg * acos((temppoint1.z - temppoint2.z) + / len(temppoint1 - temppoint2)); if(temppoint1.x>temppoint2.x)muscles[which].rotate1=360-muscles[which].rotate1; if(muscles[which].parent1->label==head)tempforward=specialforward[0]; else if(muscles[which].parent1->label==rightshoulder||muscles[which].parent1->label==rightelbow||muscles[which].parent1->label==rightwrist)tempforward=specialforward[1]; @@ -306,8 +307,8 @@ void Skeleton::FindRotationMuscle(int which) else if(muscles[which].parent1->label==lefthip||muscles[which].parent1->label==leftknee||muscles[which].parent1->label==leftankle)tempforward=specialforward[4]; else if(!muscles[which].parent1->lower)tempforward=forward; else if(muscles[which].parent1->lower)tempforward=lowforward; - tempforward=DoRotation(tempforward,0,muscles[which].rotate1-90,0); - tempforward=DoRotation(tempforward,0,0,muscles[which].rotate2-90); + tempforward=rotate(tempforward,0,muscles[which].rotate1-90,0); + tempforward=rotate(tempforward,0,0,muscles[which].rotate2-90); tempforward.y=0; tempforward = normalize(tempforward); muscles[which].rotate3=acos(0-tempforward.z)*rad2deg; |