diff options
Diffstat (limited to 'src/Person.cpp')
-rw-r--r-- | src/Person.cpp | 98 |
1 files changed, 41 insertions, 57 deletions
diff --git a/src/Person.cpp b/src/Person.cpp index fb05907..888ea8f 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -218,8 +218,7 @@ void Person::DoAnimations(int who) if (targetanimation == zombieeatanim && targetframe == 3) { auto& joints = skeleton.joints; - auto& jointlabels = skeleton.jointlabels; - auto head_joint = joints[jointlabels[head]]; + auto head_joint = joints[head]; auto soundsrc = (DoRotation(head_joint.position, 0, playerrotation, 0) + playercoords - camera.position) / soundscalefactor; @@ -228,7 +227,7 @@ void Person::DoAnimations(int who) bleeding = 1; bleeddelay = 1; bjoint1 = &head_joint; - bjoint2 = joints + jointlabels[neck]; + bjoint2 = joints + neck; } currentanimation = targetanimation; @@ -247,8 +246,7 @@ void Person::DoAnimations(int who) && currentanimation == diveanim && targetframe == 0) { targetanimation = getupfrontanim; auto& joints = skeleton.joints; - auto& jointlabels = skeleton.jointlabels; - auto head_joint = joints[jointlabels[head]]; + auto head_joint = joints[head]; auto soundsrc = (DoRotation(head_joint.position, 0, playerrotation, 0) + playercoords - camera.position) / soundscalefactor; @@ -360,8 +358,8 @@ void Person::DoAnimations(int who) skeleton.joints[i].position = animation[rifleholdanim].position[i][0]; if (currentanimation == crouchanim || targetanimation == crouchanim) - skeleton.joints[i].position += skeleton.joints[skeleton.jointlabels[neck]].position - - animation[idleanim].position[skeleton.jointlabels[neck]][0]; + skeleton.joints[i].position += skeleton.joints[neck].position + - animation[idleanim].position[neck][0]; } } @@ -381,7 +379,7 @@ void Person::DoAnimations(int who) if(grenamount>0)grenamount-=multiplier*4; if(grenamount<0)grenamount=0; } - rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position; + rotatearound=skeleton.joints[neck].position; for (int i = 0; i < max_joints; ++i){ if(skeleton.joints[i].label!=righthand&&skeleton.joints[i].label!=rightelbow&&skeleton.joints[i].label!=rightwrist&&skeleton.joints[i].label!=lefthand&&skeleton.joints[i].label!=leftelbow&&skeleton.joints[i].label!=leftwrist){ }else{ @@ -389,7 +387,7 @@ void Person::DoAnimations(int who) oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[rifleaimanim].position[i][0]; if(currentanimation==crouchanim||targetanimation==crouchanim){ - skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); } skeleton.joints[i].position+=facingright*0.1; skeleton.joints[i].position=rotatearound+DoRotation(skeleton.joints[i].position-rotatearound,(playerrotation2/2-10)*aimamount,0,0); @@ -398,27 +396,27 @@ void Person::DoAnimations(int who) if(whichgun==shotgun){ oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[assaultrifleaimanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=rotatearound+DoRotation(skeleton.joints[i].position-rotatearound,(playerrotation2/2)*aimamount,0,0); if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position+=facingdown*.2; else skeleton.joints[i].position-=facingdown*.02; - if(skeleton.joints[i].label==righthand)skeleton.joints[i].position=skeleton.joints[skeleton.jointlabels[lefthand]].position-facinghalf*2; + if(skeleton.joints[i].label==righthand)skeleton.joints[i].position=skeleton.joints[lefthand].position-facinghalf*2; skeleton.joints[i].position=skeleton.joints[i].position*(aimamount)+oldpos*(1-aimamount); } if(whichgun==assaultrifle){ oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[assaultrifleaimanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=rotatearound+DoRotation(skeleton.joints[i].position-rotatearound,(playerrotation2/2)*aimamount,0,0); if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position+=facingdown*.2; else skeleton.joints[i].position-=facingdown*.02; - if(skeleton.joints[i].label==righthand)skeleton.joints[i].position=skeleton.joints[skeleton.jointlabels[lefthand]].position-facinghalf*2; + if(skeleton.joints[i].label==righthand)skeleton.joints[i].position=skeleton.joints[lefthand].position-facinghalf*2; skeleton.joints[i].position=skeleton.joints[i].position*(aimamount)+oldpos*(1-aimamount); } if(whichgun==handgun1){ oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[pistolaimanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=rotatearound+DoRotation(skeleton.joints[i].position-rotatearound,(playerrotation2/2)*aimamount,0,0); if(currentanimation==crouchanim||targetanimation==crouchanim){skeleton.joints[i].position+=facingright*.15;skeleton.joints[i].position+=facingdown*.3;} else skeleton.joints[i].position-=facingdown*.1; @@ -427,7 +425,7 @@ void Person::DoAnimations(int who) if(whichgun==handgun2){ oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[pistolaimanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=rotatearound+DoRotation(skeleton.joints[i].position-rotatearound,(playerrotation2/2)*aimamount,0,0); if(currentanimation==crouchanim||targetanimation==crouchanim){skeleton.joints[i].position+=facingright*.15;skeleton.joints[i].position+=facingdown*.3;} else skeleton.joints[i].position-=facingdown*.1; @@ -437,13 +435,13 @@ void Person::DoAnimations(int who) aimamount=1; oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[grenadeaimanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=skeleton.joints[i].position*(aimamount)+oldpos*(1-aimamount); } if(whichgun==grenade&&grenamount>0){ oldpos=skeleton.joints[i].position; skeleton.joints[i].position=animation[grenadechargeanim].position[i][0]; - if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); + if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[neck][0]-skeleton.joints[neck].position); skeleton.joints[i].position=skeleton.joints[i].position*(grenamount)+oldpos*(1-grenamount); } if(thirdperson||who!=0)skeleton.joints[i].position+=facingdown*.4; @@ -488,11 +486,11 @@ void Person::DoAnimations(int who) } if(attackframe==animation[grenadethrowanim].numframes-1&&ammo>0){ ammo=-1; - sprites.MakeSprite(grenadesprite, 1, 1, 1, 1, DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,playerrotation,0)+playercoords, DoRotation(facing,0,playerrotation,0)*30+velocity, 1); - sprites.MakeSprite(spoonsprite, 1, 1, 1, 1, DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,playerrotation,0)+playercoords, DoRotation(facing,0,playerrotation,0)*10+velocity, 1); - sprites.MakeSprite(pinsprite, 1, 1, 1, 1, DoRotation(skeleton.joints[skeleton.jointlabels[lefthand]].position,0,playerrotation,0)+playercoords, facing*.1+velocity, 1); + sprites.MakeSprite(grenadesprite, 1, 1, 1, 1, DoRotation(skeleton.joints[righthand].position,0,playerrotation,0)+playercoords, DoRotation(facing,0,playerrotation,0)*30+velocity, 1); + sprites.MakeSprite(spoonsprite, 1, 1, 1, 1, DoRotation(skeleton.joints[righthand].position,0,playerrotation,0)+playercoords, DoRotation(facing,0,playerrotation,0)*10+velocity, 1); + sprites.MakeSprite(pinsprite, 1, 1, 1, 1, DoRotation(skeleton.joints[lefthand].position,0,playerrotation,0)+playercoords, facing*.1+velocity, 1); - XYZ soundsrc = (DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position, 0, playerrotation, 0) + XYZ soundsrc = (DoRotation(skeleton.joints[righthand].position, 0, playerrotation, 0) + playercoords - camera.position) / soundscalefactor; ALfloat gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z}; alSourcefv(gSourceID[grenadethrowsound], AL_POSITION, gLoc); @@ -501,7 +499,7 @@ void Person::DoAnimations(int who) } } - rotatearound=skeleton.joints[skeleton.jointlabels[abdomen]].position; + rotatearound=skeleton.joints[abdomen].position; if (who == 0) { for (auto& joint : skeleton.joints) if (!joint.lower) @@ -509,9 +507,9 @@ void Person::DoAnimations(int who) + DoRotation(joint.position - rotatearound, playerrotation2 / 2, 0, 0); else if (joint.label != groin) joint.position = DoRotation(joint.position, 0, playerlowrotation - playerrotation, 0); - rotatearound = skeleton.joints[skeleton.jointlabels[neck]].position; - skeleton.joints[skeleton.jointlabels[head]].position = rotatearound - + DoRotation(skeleton.joints[skeleton.jointlabels[head]].position - rotatearound, playerrotation2 / 2, 0, 0); + rotatearound = skeleton.joints[neck].position; + skeleton.joints[head].position = rotatearound + + DoRotation(skeleton.joints[head].position - rotatearound, playerrotation2 / 2, 0, 0); } skeleton.DoConstraints(); @@ -582,8 +580,7 @@ void Person::DoAnimationslite(int who) if (targetanimation == zombieeatanim && targetframe == 3) { auto& joints = skeleton.joints; - auto& jointlabels = skeleton.jointlabels; - auto head_joint = joints[jointlabels[head]]; + auto head_joint = joints[head]; auto soundsrc = (DoRotation(head_joint.position, 0, playerrotation, 0) + playercoords - camera.position) / soundscalefactor; @@ -592,7 +589,7 @@ void Person::DoAnimationslite(int who) bleeding = 1; bleeddelay = 1; bjoint1 = &head_joint; - bjoint2 = joints + jointlabels[neck]; + bjoint2 = joints + neck; } currentanimation = targetanimation; @@ -830,12 +827,10 @@ void draw_muscle(Muscle& mus, int who, int whichcostume) int Person::DrawSkeleton(int who) { - auto& left_hand = skeleton.jointlabels[lefthand]; - auto& left_wrist = skeleton.joints[left_hand].position; - auto& right_hand = skeleton.jointlabels[righthand]; - auto& right_wrist = skeleton.joints[right_hand].position; - auto& head_pos = skeleton.joints[skeleton.jointlabels[head]].position; - auto& neck_pos = skeleton.joints[skeleton.jointlabels[neck]].position; + auto& left_wrist = skeleton.joints[lefthand].position; + auto& right_wrist = skeleton.joints[righthand].position; + auto& head_pos = skeleton.joints[head].position; + auto& neck_pos = skeleton.joints[neck].position; switch (whichgun) { case sniperrifle: @@ -920,7 +915,7 @@ int Person::DrawSkeleton(int who) glPopMatrix(); break; case knife: - auto& wrist = skeleton.joints[skeleton.jointlabels[righthand]]; + auto& wrist = skeleton.joints[righthand]; glPushMatrix(); glTranslatef(wrist.position.x, wrist.position.y, wrist.position.z); @@ -936,8 +931,7 @@ int Person::DrawSkeleton(int who) if (litup) { GLfloat LightAmbient[] {0, 0, 0, 1.0f}; GLfloat LightDiffuse[] {1, 1, 1, 1.0f}; - auto& hand = skeleton.jointlabels[lefthand]; - XYZ lightpoint = skeleton.joints[hand].position; + XYZ lightpoint = skeleton.joints[lefthand].position; GLfloat LightPosition[] {lightpoint.x, lightpoint.y, lightpoint.z, 0}; glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); @@ -994,17 +988,13 @@ int Person::DrawSkeleton(int who) auto specialfwd = skeleton.specialforward; *specialfwd++ = skeleton.forward; - auto& right_shoulder = skeleton.jointlabels[rightshoulder]; - auto& right_elbow = skeleton.jointlabels[rightelbow]; - *specialfwd = skeleton.joints[right_elbow].position - - skeleton.joints[right_shoulder].position / 2 + *specialfwd = skeleton.joints[rightelbow].position + - skeleton.joints[rightshoulder].position / 2 - right_wrist / 2 + skeleton.forward * 0.2; Normalise(specialfwd++); - auto& left_shoulder = skeleton.jointlabels[leftshoulder]; - auto& left_elbow = skeleton.jointlabels[leftelbow]; - *specialfwd = skeleton.joints[left_elbow].position - - skeleton.joints[left_shoulder].position / 2 + *specialfwd = skeleton.joints[leftelbow].position + - skeleton.joints[leftshoulder].position / 2 - left_wrist / 2 + skeleton.forward * 0.2; Normalise(specialfwd++); @@ -1022,21 +1012,15 @@ int Person::DrawSkeleton(int who) skeleton.specialforward[2] += facingdown * aimamount; } - auto& right_hip = skeleton.jointlabels[righthip]; - auto& right_ankle = skeleton.jointlabels[rightankle]; - auto& right_knee = skeleton.jointlabels[rightknee]; - *specialfwd = skeleton.joints[right_hip].position / 2 - + skeleton.joints[right_ankle].position / 2 - - skeleton.joints[right_knee].position + *specialfwd = skeleton.joints[righthip].position / 2 + + skeleton.joints[rightankle].position / 2 + - skeleton.joints[rightknee].position + skeleton.lowforward * 0.2; Normalise(specialfwd++); - auto& left_hip = skeleton.jointlabels[lefthip]; - auto& left_ankle = skeleton.jointlabels[leftankle]; - auto& left_knee = skeleton.jointlabels[leftknee]; - *specialfwd = skeleton.joints[left_hip].position / 2 - + skeleton.joints[left_ankle].position / 2 - - skeleton.joints[left_knee].position + *specialfwd = skeleton.joints[lefthip].position / 2 + + skeleton.joints[leftankle].position / 2 + - skeleton.joints[leftknee].position + skeleton.lowforward * 0.2; Normalise(specialfwd++); |