private void FillControllerState(PlayerState outState)
        {
            for (int index = 0; index < PlayerState.Bones.BoneCount; ++index)
            {
                FinchBone bone = PlayerState.Bones[index];
                switch (bone)
                {
                case FinchBone.LeftUpperArm:
                case FinchBone.LeftLowerArm:
                case FinchBone.LeftHand:
                case FinchBone.LeftHandCenter:
                case FinchBone.RightUpperArm:
                case FinchBone.RightLowerArm:
                case FinchBone.RightHand:
                case FinchBone.RightHandCenter:
                {
                    outState.Rotations[index]    = GetBoneRotation(bone);
                    outState.Positions[index]    = GetBoneCoordinate(bone);
                    outState.Available[index]    = true;
                    outState.BonesLengths[index] = FinchCore.GetBoneLength(bone);
                    break;
                }

                default:
                {
                    outState.Rotations[index]    = FinchCore.GetBoneRotation(bone);
                    outState.Positions[index]    = FinchCore.GetBoneCoordinate(bone);
                    outState.Available[index]    = FinchCore.IsBoneAvailable(bone);
                    outState.BonesLengths[index] = FinchCore.GetBoneLength(bone);
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        public override void ReadState(PlayerState outState)
        {
            base.ReadState(outState);

            for (int i = 0; i < PlayerState.Bones.BoneCount; ++i)
            {
                FinchBone bone = PlayerState.Bones[i];
                outState.Rotations[i]    = FinchCore.GetBoneRotation(bone);
                outState.Positions[i]    = FinchCore.GetBoneCoordinate(bone);
                outState.Available[i]    = FinchCore.IsBoneAvailable(bone);
                outState.BonesLengths[i] = FinchCore.GetBoneLength(bone);
            }

            outState.Positions[PlayerState.Bones[FinchBone.Head]] = outState.Positions[PlayerState.Bones[FinchBone.Neck]]
                                                                    + outState.Rotations[PlayerState.Bones[FinchBone.Hips]] * Vector3.up * outState.BonesLengths[PlayerState.Bones[FinchBone.Neck]];

            outState.Positions[PlayerState.Bones[FinchBone.RightEye]] = outState.Positions[PlayerState.Bones[FinchBone.Head]]
                                                                        + outState.Rotations[PlayerState.Bones[FinchBone.Head]] * Vector3.up * outState.BonesLengths[PlayerState.Bones[FinchBone.Head]]
                                                                        + outState.Rotations[PlayerState.Bones[FinchBone.Head]] * Vector3.forward * eyeForwardShift;
        }
        private Vector3 GetBoneCoordinate(FinchBone bone)
        {
            switch (bone)
            {
            case FinchBone.LeftUpperArm:
                return(FinchCore.GetBoneCoordinate(FinchBone.LeftUpperArm));

            case FinchBone.LeftLowerArm:
                return(elbowPositions[0]);

            case FinchBone.LeftHandCenter:
                return(wristPositions[0]);

            case FinchBone.LeftHand:
                return(GetHandPositionByControllerPosition(wristPositions[0], wristOrientations[0], Vector3.left, FinchCore.GetBoneLength(FinchBone.LeftHand)));

            case FinchBone.RightUpperArm:
                return(FinchCore.GetBoneCoordinate(FinchBone.RightUpperArm));

            case FinchBone.RightLowerArm:
                return(elbowPositions[1]);

            case FinchBone.RightHand:
                return(GetHandPositionByControllerPosition(wristPositions[1], wristOrientations[1], Vector3.right, FinchCore.GetBoneLength(FinchBone.RightHand)));

            case FinchBone.RightHandCenter:
                return(wristPositions[1]);

            default:
                return(Vector3.zero);
            }
        }