Exemple #1
0
	public void Awake()
	{
		int jointCount = Enum.GetNames(typeof(SkeletonJoint)).Length + 1; // Enum starts at 1
		
		transforms = new Transform[jointCount];
		initialRotations = new Quaternion[jointCount];
		jointData = new SkeletonJointTransformation[jointCount];
		
		transforms[(int)SkeletonJoint.Head] = Head;
		transforms[(int)SkeletonJoint.Neck] = Neck;
		transforms[(int)SkeletonJoint.Torso] = Torso;
		transforms[(int)SkeletonJoint.Waist] = Waist;
		transforms[(int)SkeletonJoint.LeftCollar] = LeftCollar;
		transforms[(int)SkeletonJoint.LeftShoulder] = LeftShoulder;
		transforms[(int)SkeletonJoint.LeftElbow] = LeftElbow;
		transforms[(int)SkeletonJoint.LeftWrist] = LeftWrist;
		transforms[(int)SkeletonJoint.LeftHand] = LeftHand;
		transforms[(int)SkeletonJoint.LeftFingertip] = LeftFingertip;
		transforms[(int)SkeletonJoint.RightCollar] = RightCollar;
		transforms[(int)SkeletonJoint.RightShoulder] = RightShoulder;
		transforms[(int)SkeletonJoint.RightElbow] = RightElbow;
		transforms[(int)SkeletonJoint.RightWrist] = RightWrist;
		transforms[(int)SkeletonJoint.RightHand] = RightHand;
		transforms[(int)SkeletonJoint.RightFingertip] = RightFingertip;
		transforms[(int)SkeletonJoint.LeftHip] = LeftHip;
		transforms[(int)SkeletonJoint.LeftKnee] = LeftKnee;
		transforms[(int)SkeletonJoint.LeftAnkle] = LeftAnkle;
		transforms[(int)SkeletonJoint.LeftFoot] = LeftFoot;
		transforms[(int)SkeletonJoint.RightHip] = RightHip;
		transforms[(int)SkeletonJoint.RightKnee] = RightKnee;
	    transforms[(int)SkeletonJoint.RightAnkle] = RightAnkle;
		transforms[(int)SkeletonJoint.RightFoot] = RightFoot;
		
    }
Exemple #2
0
    public void Awake()
    {
        int jointCount = Enum.GetNames(typeof(SkeletonJoint)).Length + 1; // Enum starts at 1

        transforms = new Transform[jointCount];
        initialRotations = new Quaternion[jointCount];
        jointData = new SkeletonJointTransformation[jointCount];

        transforms[(int)SkeletonJoint.Head] = Head;
        transforms[(int)SkeletonJoint.Neck] = Neck;
        transforms[(int)SkeletonJoint.Torso] = Torso;
        transforms[(int)SkeletonJoint.Waist] = Waist;
        transforms[(int)SkeletonJoint.LeftCollar] = LeftCollar;
        transforms[(int)SkeletonJoint.LeftShoulder] = LeftShoulder;
        transforms[(int)SkeletonJoint.LeftElbow] = LeftElbow;
        transforms[(int)SkeletonJoint.LeftWrist] = LeftWrist;
        transforms[(int)SkeletonJoint.LeftHand] = LeftHand;
        transforms[(int)SkeletonJoint.LeftFingertip] = LeftFingertip;
        transforms[(int)SkeletonJoint.RightCollar] = RightCollar;
        transforms[(int)SkeletonJoint.RightShoulder] = RightShoulder;
        transforms[(int)SkeletonJoint.RightElbow] = RightElbow;
        transforms[(int)SkeletonJoint.RightWrist] = RightWrist;
        transforms[(int)SkeletonJoint.RightHand] = RightHand;
        transforms[(int)SkeletonJoint.RightFingertip] = RightFingertip;
        transforms[(int)SkeletonJoint.LeftHip] = LeftHip;
        transforms[(int)SkeletonJoint.LeftKnee] = LeftKnee;
        transforms[(int)SkeletonJoint.LeftAnkle] = LeftAnkle;
        transforms[(int)SkeletonJoint.LeftFoot] = LeftFoot;
        transforms[(int)SkeletonJoint.RightHip] = RightHip;
        transforms[(int)SkeletonJoint.RightKnee] = RightKnee;
        transforms[(int)SkeletonJoint.RightAnkle] = RightAnkle;
        transforms[(int)SkeletonJoint.RightFoot] = RightFoot;

        // save all initial rotations
        // NOTE: Assumes skeleton model is in "T" pose since all rotations are relative to that pose
        foreach (SkeletonJoint j in Enum.GetValues(typeof(SkeletonJoint)))
        {
            if (transforms[(int)j])
            {
                // we will store the relative rotation of each joint from the gameobject rotation
                // we need this since we will be setting the joint's rotation (not localRotation) but we
                // still want the rotations to be relative to our game object
                initialRotations[(int)j] = Quaternion.Inverse(transform.rotation) * transforms[(int)j].rotation;
            }
        }
    }