/// <summary> /// Transfers the gun information from a robot to a Polymodel instance. /// </summary> /// <param name="robot">The robot to read the guns from.</param> private void BuildModelAnimation(Robot robot) { if (robot.ModelNum == -1) { return; } Polymodel model = Models[robot.ModelNum]; List <FixAngles> jointlist = new List <FixAngles>(); model.NumGuns = robot.NumGuns; for (int i = 0; i < Polymodel.MaxGuns; i++) { model.GunPoints[i] = robot.GunPoints[i]; model.GunDirs[i] = FixVector.FromRawValues(65536, 0, 0); model.GunSubmodels[i] = robot.GunSubmodels[i]; } int[,] jointmapping = new int[10, 5]; for (int m = 0; m < Polymodel.MaxSubmodels; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { jointmapping[m, f] = -1; } } int basejoint = 0; for (int m = 0; m < Polymodel.MaxGuns + 1; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { Robot.JointList robotjointlist = robot.AnimStates[m, f]; basejoint = robotjointlist.Offset; for (int j = 0; j < robotjointlist.NumJoints; j++) { JointPos joint = Joints[basejoint]; jointmapping[joint.JointNum, f] = basejoint; model.IsAnimated = true; basejoint++; } } } for (int m = 1; m < Polymodel.MaxSubmodels; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { int jointnum = jointmapping[m, f]; if (jointnum != -1) { JointPos joint = Joints[jointnum]; model.AnimationMatrix[m, f].P = joint.Angles.P; model.AnimationMatrix[m, f].B = joint.Angles.B; model.AnimationMatrix[m, f].H = joint.Angles.H; } } } }
private void BuildModelAnimation(Robot robot) { //this shouldn't happen? if (robot.ModelNum == -1) { return; } //If the robot is referring to a base HAM file model, reject it if (robot.ModelNum < VHAMFile.NumDescent2Polymodels) { return; } Polymodel model = Models[robot.ModelNum - VHAMFile.NumDescent2Polymodels]; List <FixAngles> jointlist = new List <FixAngles>(); model.NumGuns = robot.NumGuns; for (int i = 0; i < Polymodel.MaxGuns; i++) { model.GunPoints[i] = robot.GunPoints[i]; model.GunDirs[i] = FixVector.FromRawValues(65536, 0, 0); model.GunSubmodels[i] = robot.GunSubmodels[i]; } int[,] jointmapping = new int[10, 5]; for (int m = 0; m < Polymodel.MaxSubmodels; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { jointmapping[m, f] = -1; } } int basejoint = 0; for (int m = 0; m < Polymodel.MaxGuns + 1; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { Robot.JointList robotjointlist = robot.AnimStates[m, f]; basejoint = robotjointlist.Offset; for (int j = 0; j < robotjointlist.NumJoints; j++) { JointPos joint = GetJoint(basejoint); jointmapping[joint.JointNum, f] = basejoint; model.IsAnimated = true; basejoint++; } } } for (int m = 1; m < Polymodel.MaxSubmodels; m++) { for (int f = 0; f < Robot.NumAnimationStates; f++) { int jointnum = jointmapping[m, f]; if (jointnum != -1) { JointPos joint = GetJoint(jointnum); model.AnimationMatrix[m, f].P = joint.Angles.P; model.AnimationMatrix[m, f].B = joint.Angles.B; model.AnimationMatrix[m, f].H = joint.Angles.H; } } } }