示例#1
0
    private void UpdateRotationEffect()
    {
        if (m_menuButton.GetButtonDown() && m_menuButton.GetGazeOver())
        {
            float      newAngle = (Input.mousePosition.x - m_touchXPosOnDown) * m_rotationalSwipeSenstivity;
            Quaternion newRot   = m_rotOnDown * Quaternion.AngleAxis(newAngle, Vector3.up);
            transform.localRotation = newRot;

            const float kSpeedDivisionFactor = 10.0f;
            float       diffInXFromLastFrame = Input.mousePosition.x - m_touchXPosLastFrame;
            m_touchXPosLastFrame      = Input.mousePosition.x;
            m_currRotationalSpeed     = (diffInXFromLastFrame * Time.fixedDeltaTime) + (m_currRotationalSpeed / kSpeedDivisionFactor); // always taking last speed slightly into account
            m_isBeingManuallyRotated |= Mathf.Abs(m_currRotationalSpeed) > kRotationEpsilon;

            m_rotationalSpeedOnRelease = m_currRotationalSpeed;
        }
        else
        {
            float      newAngle = m_currRotationalSpeed;
            Quaternion newRot   = transform.localRotation * Quaternion.AngleAxis(newAngle, Vector3.up);
            transform.localRotation = newRot;

            float absCurrSpeed = Mathf.Max(Mathf.Abs(m_currRotationalSpeed) - (Mathf.Abs(m_rotationalSpeedOnRelease) * (m_rotationalDamp * Time.fixedDeltaTime)), 0.0f);
            m_currRotationalSpeed = absCurrSpeed * (m_currRotationalSpeed > 0.0f ? 1.0f : -1.0f);

            m_isBeingManuallyRotated = false;
        }
    }
示例#2
0
    // **************************
    // Private/Helper functions
    // **************************

    private void UpdateRotationEffect()
    {
        if (m_currMenuButton != null && m_currMenuButton.GetButtonDown() && m_currMenuButton.GetGazeOver())
        {
            float movementInFrame = 0.0f;
            if (m_currSelectArrow.GetArrowType() == SelectArrow.ArrowType.kNext)
            {
                movementInFrame = -m_rotationalSwipeSenstivity;
            }
            else if (m_currSelectArrow.GetArrowType() == SelectArrow.ArrowType.kPrev)
            {
                movementInFrame = m_rotationalSwipeSenstivity;
            }

            /*
             * if (m_currSelectArrow.GetArrowType() == SelectArrow.ArrowType.kScroll)
             * {
             *  movementInFrame = (Input.mousePosition.x - m_touchXPosLastFrame) * m_rotationalSwipeSenstivity;
             * }
             */

            for (int i = 0; i < m_carouselItems.Length; i++)
            {
                m_carouselItems[i].SetDistAlongSpline(m_carouselItems[i].GetDistAlongSpline() + movementInFrame);
            }

            const float kSpeedDivisionFactor = 10.0f;
            float       diffInXFromLastFrame = Input.mousePosition.x - m_touchXPosLastFrame;
            m_touchXPosLastFrame      = Input.mousePosition.x;
            m_currRotationalSpeed     = (diffInXFromLastFrame * Time.fixedDeltaTime) + (m_currRotationalSpeed / kSpeedDivisionFactor); // always taking last speed slightly into account
            m_isBeingManuallyRotated |= Mathf.Abs(m_currRotationalSpeed) > kRotationEpsilon;

            m_rotationalSpeedOnRelease = m_currRotationalSpeed;
        }

        /*
         * else
         * {
         *  float newAngle = m_currRotationalSpeed;
         *  //TODO...
         *
         *  float absCurrSpeed = Mathf.Max(Mathf.Abs(m_currRotationalSpeed) - (Mathf.Abs(m_rotationalSpeedOnRelease) * (m_rotationalDamp * Time.fixedDeltaTime)), 0.0f);
         *  m_currRotationalSpeed = absCurrSpeed * (m_currRotationalSpeed > 0.0f ? 1.0f : -1.0f);
         *
         *  m_isBeingManuallyRotated = false;
         * }
         */
    }
示例#3
0
    // **************************
    // Private/Helper functions
    // **************************

    private void UpdateRotationEffect()
    {
        if (m_menuButton.GetButtonDown() && m_menuButton.GetGazeOver())
        {
            float      newXAngle = (Input.mousePosition.x - m_touchPosOnDown.x) * m_rotationalSwipeSenstivity;
            float      newYAngle = (Input.mousePosition.y - m_touchPosOnDown.y) * m_rotationalSwipeSenstivity;
            Quaternion newRot    = Quaternion.AngleAxis(newYAngle, Vector3.right) * m_rotOnDown * Quaternion.AngleAxis(newXAngle, Vector3.up); // world up, local right - this line took me way too long to figure out
            transform.localRotation = newRot;

            float diffInXFromLastFrame = Input.mousePosition.x - m_touchPosLastFrame.x;
            float diffInYFromLastFrame = Input.mousePosition.y - m_touchPosLastFrame.y;
            m_touchPosLastFrame.x = Input.mousePosition.x;
            m_touchPosLastFrame.y = Input.mousePosition.y;

            const float kSpeedDivisionFactor = 10.0f;
            m_currRotationalSpeed.x   = (diffInXFromLastFrame * Time.deltaTime) + (m_currRotationalSpeed.x / kSpeedDivisionFactor); // always taking last speed slightly into account
            m_currRotationalSpeed.y   = (diffInYFromLastFrame * Time.deltaTime) + (m_currRotationalSpeed.y / kSpeedDivisionFactor); // always taking last speed slightly into account
            m_isBeingManuallyRotated |= (Mathf.Abs(m_currRotationalSpeed.x) + Mathf.Abs(m_currRotationalSpeed.y) > kRotationEpsilon);

            m_rotationalSpeedOnRelease = m_currRotationalSpeed;
        }
        else
        {
            float      newXAngle = m_currRotationalSpeed.x;
            float      newYAngle = m_currRotationalSpeed.y;
            Quaternion newRot    = Quaternion.AngleAxis(newYAngle, Vector3.right) * transform.localRotation * Quaternion.AngleAxis(newXAngle, Vector3.up); // world up, local right - this line took me way too long to figure out
            transform.localRotation = newRot;

            float absCurrXSpeed = Mathf.Max(Mathf.Abs(m_currRotationalSpeed.x) - (Mathf.Abs(m_rotationalSpeedOnRelease.x) * (m_rotationalDamp * Time.deltaTime)), 0.0f);
            m_currRotationalSpeed.x = absCurrXSpeed * (m_currRotationalSpeed.x > 0.0f ? 1.0f : -1.0f);

            float absCurrYSpeed = Mathf.Max(Mathf.Abs(m_currRotationalSpeed.y) - (Mathf.Abs(m_rotationalSpeedOnRelease.y) * (m_rotationalDamp * Time.deltaTime)), 0.0f);
            m_currRotationalSpeed.y = absCurrYSpeed * (m_currRotationalSpeed.y > 0.0f ? 1.0f : -1.0f);

            m_isBeingManuallyRotated = false;
        }
    }