Пример #1
0
    void Update()
    {
        bool needRedraw = false;

        if (Input.GetButton("XBoxBt7") || Input.GetKeyDown(KeyCode.Q))
        {
            rotationObject = RotationStruct.Next();
            needRedraw     = true;
        }
        else if (Input.GetButton("XBoxBt8") || Input.GetKeyDown(KeyCode.W))
        {
            rotationObject = RotationStruct.Previous();
            needRedraw     = true;
        }


        if (Input.GetKey(KeyCode.Equals))
        {
            RotateObject(rotationObject, 1);
            needRedraw = true;
        }
        else if (Input.GetKey(KeyCode.Minus))
        {
            RotateObject(rotationObject, -1);
            needRedraw = true;
        }

        if (needRedraw && rotationObject != null)
        {
            needRedraw = false;
            UnColorObjects();
            DrawAxisAndColorObjects(rotationObject);
            DrawUI(rotationObject);
        }
    }
Пример #2
0
    private int FindRotationObjectPosition(RotationObject rot)
    {
        int i = 0;

        foreach (RotationObject aRot in RotationStruct.RotationObjectsValues())
        {
            if (aRot.name.Equals(rot.name))
            {
                return(i);
            }
            i++;
        }
        return(-1);
    }
Пример #3
0
    void Awake()
    {
        if (control == null)
        {
            DontDestroyOnLoad(gameObject);
        }
        else if (control != this)
        {
            Destroy(gameObject);
        }

        FindGameObjects();

        FindAngleUI();

        RotationStruct.Add(CreateRotationObject("Head & Shoulders around belly", belly, betweenShoulders, Vector3.right, Vector3.forward, Vector3.up, head, betweenShoulders, leftShoulder, leftElbow, leftHand, rightShoulder, rightElbow, rightHand));
        RotationStruct.Add(CreateRotationObject("Hips and legs around belly", belly, betweenHips, Vector3.right, Vector3.back, Vector3.up, betweenHips, leftHip, leftKnee, leftFoot, rightHip, rightKnee, rightFoot));
        RotationStruct.Add(CreateRotationObject("Left shoulder around spine", betweenShoulders, leftShoulder, Vector3.forward, Vector3.left, Vector3.up, leftShoulder, leftElbow, leftHand));
        RotationStruct.Add(CreateRotationObject("Right shoulder around spine", betweenShoulders, rightShoulder, Vector3.forward, Vector3.right, Vector3.up, rightShoulder, rightElbow, rightHand));
        RotationStruct.Add(CreateRotationObject("Shoulders around Y axis", betweenShoulders, head, Vector3.up, Vector3.forward, Vector3.right, head, leftShoulder, leftElbow, leftHand, rightShoulder, rightElbow, rightHand));

        RotationStruct.Add(CreateRotationObject("Left Elb around shoulders X", leftShoulder, leftElbow, Vector3.right, Vector3.forward, Vector3.up, leftElbow, leftHand));
        RotationStruct.Add(CreateRotationObject("Right Elb around shoulders X", rightShoulder, rightElbow, Vector3.right, Vector3.forward, Vector3.up, rightElbow, rightHand));
        RotationStruct.Add(CreateRotationObject("Left Elb around shoulders Y", leftShoulder, leftElbow, Vector3.up, Vector3.forward, Vector3.right, leftElbow, leftHand));
        RotationStruct.Add(CreateRotationObject("Right Elb around shoulders Y", rightShoulder, rightElbow, Vector3.up, Vector3.forward, Vector3.right, rightElbow, rightHand));
        RotationStruct.Add(CreateRotationObject("Left Hand around Elb X", leftElbow, leftHand, Vector3.right, Vector3.forward, Vector3.up, leftHand));
        RotationStruct.Add(CreateRotationObject("Right Hand around Elb X", rightElbow, rightHand, Vector3.right, Vector3.forward, Vector3.up, rightHand));
        RotationStruct.Add(CreateRotationObject("Left Hand around Elb Y", leftElbow, leftHand, Vector3.up, Vector3.forward, Vector3.right, leftHand));
        RotationStruct.Add(CreateRotationObject("Right Hand around Elb Y", rightElbow, rightHand, Vector3.up, Vector3.forward, Vector3.right, rightHand));

        RotationStruct.Add(CreateRotationObject("Hips around X axis", betweenHips, leftHip, Vector3.forward, Vector3.left, Vector3.up, leftHip, leftKnee, leftFoot, rightHip, rightKnee, rightFoot));
        RotationStruct.Add(CreateRotationObject("Hips around Y axis", betweenHips, leftHip, Vector3.up, Vector3.left, Vector3.forward, leftHip, leftKnee, leftFoot, rightHip, rightKnee, rightFoot));
        RotationStruct.Add(CreateRotationObject("Left knee around hips Y", leftHip, leftKnee, Vector3.up, Vector3.back, Vector3.left, leftKnee, leftFoot));
        RotationStruct.Add(CreateRotationObject("Right knee around hips Y", rightHip, rightKnee, Vector3.up, Vector3.back, Vector3.right, rightKnee, rightFoot));
        RotationStruct.Add(CreateRotationObject("Left knee around hips X", leftHip, leftKnee, Vector3.right, Vector3.back, Vector3.up, leftKnee, leftFoot));
        RotationStruct.Add(CreateRotationObject("Right knee around hips X", rightHip, rightKnee, Vector3.right, Vector3.back, Vector3.up, rightKnee, rightFoot));
        RotationStruct.Add(CreateRotationObject("Left foot around knee Y", leftKnee, leftFoot, Vector3.up, Vector3.back, Vector3.left, leftFoot));
        RotationStruct.Add(CreateRotationObject("Right foot around knee Y", rightKnee, rightFoot, Vector3.up, Vector3.back, Vector3.right, rightFoot));
        RotationStruct.Add(CreateRotationObject("Left foot around knee X", leftKnee, leftFoot, Vector3.right, Vector3.back, Vector3.up, leftFoot));
        RotationStruct.Add(CreateRotationObject("Right foot around knee X", rightKnee, rightFoot, Vector3.right, Vector3.back, Vector3.up, rightFoot));
    }
Пример #4
0
    public void Rotate(RotationStruct rotationToDo)
    {
        //if is running a skippable rotation, skip every skippable rotation
        if (rotatingWorld_Coroutine != null && rotationsToDo.Peek().canSkipAnimation)
        {
            skippingRotations = true;

            //add to list rotations waiting skip
            rotationsWaitingSkip.Enqueue(rotationToDo);
        }
        else
        {
            //add to list
            rotationsToDo.Enqueue(rotationToDo);

            //if there is no rotation running, start rotation
            if (rotatingWorld_Coroutine == null)
            {
                DoRotation();
            }
        }
    }
Пример #5
0
    void DoRotation()
    {
        RotationStruct rotation = rotationsToDo.Peek();

        //set variables
        coordinatesToRotate = rotation.coordinates;
        cellsToRotate.Clear();
        cellsKeys.Clear();

        //every coordinates can be only on the same face
        EFace startFace = coordinatesToRotate[0].face;

        //rotate row
        if (rotation.rotateDirection == ERotateDirection.right || rotation.rotateDirection == ERotateDirection.left)
        {
            bool forward = rotation.rotateDirection == ERotateDirection.right;

            if (startFace == EFace.up || startFace == EFace.down)
            {
                //if face up or face down, the inputs are differents based on the rotation of the camera
                switch (rotation.lookingFace)
                {
                case EFace.front:
                    RotateUpDownRow(startFace, forward);
                    break;

                case EFace.right:
                    if (startFace == EFace.up)
                    {
                        RotateFrontColumn(startFace, forward);
                    }
                    else
                    {
                        RotateFrontColumn(startFace, !forward);
                    }
                    break;

                case EFace.back:
                    RotateUpDownRow(startFace, !forward);
                    break;

                case EFace.left:
                    if (startFace == EFace.up)
                    {
                        RotateFrontColumn(startFace, !forward);
                    }
                    else
                    {
                        RotateFrontColumn(startFace, forward);
                    }
                    break;
                }
            }
            else
            {
                //else just rotate row lateral faces
                RotateLateralRow(forward);
            }
        }
        //rotate column
        else
        {
            bool forward = rotation.rotateDirection == ERotateDirection.up;

            //if face up or face down, the inputs are differents based on the rotation of the camera
            if (startFace == EFace.up || startFace == EFace.down)
            {
                switch (rotation.lookingFace)
                {
                case EFace.front:
                    RotateFrontColumn(startFace, forward);
                    break;

                case EFace.right:
                    if (startFace == EFace.up)
                    {
                        RotateUpDownRow(startFace, !forward);
                    }
                    else
                    {
                        RotateUpDownRow(startFace, forward);
                    }
                    break;

                case EFace.back:
                    RotateFrontColumn(startFace, !forward);
                    break;

                case EFace.left:
                    if (startFace == EFace.up)
                    {
                        RotateUpDownRow(startFace, forward);
                    }
                    else
                    {
                        RotateUpDownRow(startFace, !forward);
                    }
                    break;
                }
            }
            else
            {
                //else just rotate column
                if (startFace == EFace.right || startFace == EFace.left)
                {
                    //rotate column face right or left
                    RotateRightLeftColumn(startFace, forward);
                }
                else
                {
                    //rotate column front faces (front, up, back, down)
                    RotateFrontColumn(startFace, forward);
                }
            }
        }
    }