Delphi - сбориник статей

       

List


//Для всех частей тела for i := 0 to numBodyParts -1 do begin //Начать поиск ключевых кадров KeyFrameIndex:=-1; for j := 0 to BodyParts[i, CurrentActions[i]].KeyFrameCount-1 do if Timers[i]=BodyParts[i, CurrentActions[i]].KeyFrames[j].KFTimer then KeyFrameIndex:=j; if keyFrameIndex=-1 then begin //Допустим, что кадр не найден MaxLower:=0; MinUpper:=BodyParts[i, CurrentActions[i]].Duration+1; for j := 0 to BodyParts[i, CurrentActions[i]].KeyFrameCount-1 do begin if BodyParts[i, CurrentActions[i]].KeyFrames[j].KFTimer>Timers[i] then begin if Bodyparts[i, CurrentActions[i]].KeyFrames[j].KFTimer<MinUpper then MinUpper:=Bodyparts[i, CurrentActions[i]].KeyFrames[j].KFTimer; end else if BodyParts[i, CurrentActions[i]].KeyFrames[j].KFTimer>MaxLower then MaxLower:=BodyParts[i, CurrentActions[i]].KeyFrames[j].KFTimer; end; //Взять значения углов поворота из этих кадров for j := 0 to BodyParts[i, CurrentActions[i]].KeyFrames[0].BoneCount-1 do begin for k:= 0 to Bodyparts[i, CurrentActions[i]].KeyframeCount-1 do begin if MaxLower=BodyParts[i, CurrentActions[i]].KeyFrames[k].KFTimer then begin Anglex1:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleYOZ; Angley1:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleXOZ; Anglez1:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleXOY; end; if MinUpper=BodyParts[i, CurrentActions[i]].KeyFrames[k].KFTimer then begin Anglex2:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleYOZ; Angley2:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleXOZ; Anglez2:=Bodyparts[i, CurrentActions[i]].keyFrames[k].BoneState[j].AngleXOY; end; end; //Вычислить значения углов поворота в данный момент времени anglex:=(Anglex2-anglex1)/(minUpper-maxLower)*Timers[i]+anglex1- (Anglex2-anglex1)/(minUpper-maxLower)*maxlower; angley:=(Angley2-angley1)/(minUpper-maxLower)*Timers[i]+angley1- (Angley2-angley1)/(minUpper-maxLower)*maxlower; anglez:=(Anglez2-anglez1)/(minUpper-maxLower)*Timers[i]+anglez1- (Anglez2-anglez1)/(minUpper-maxLower)*maxlower; //Записать эти значения в массив подобъекта Body Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[0].BoneIndexes[j]].AngleYOZ:=anglex; Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[0].BoneIndexes[j]].AngleXOZ:=angley; Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[0].BoneIndexes[j]].AngleXOY:=anglez; end; end else begin //Если же ключевой кадр найден, просто переписать из него значения for j := 0 to BodyParts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneCount-1 do begin Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneIndexes[j]].AngleYOZ:= Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneState[j].AngleYOZ; Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneIndexes[j]].AngleXOZ:= Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneState[j].AngleXOZ; Body.DeformationBoneState[Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneIndexes[j]].AngleXOY:= Bodyparts[i, CurrentActions[i]].KeyFrames[KeyFrameIndex].BoneState[j].AngleXOY; end; end; end; end;



Содержание раздела