コード例 #1
0
    /// <summary>
    /// This method checks if a relative movement was started by the user.
    /// If started, the relative quaternion start value is set and the gain function reseted.
    /// </summary>
    public void CheckStartOfRelativeMovement()
    {
        Vector3    angularVelocity;
        Quaternion rotation;

        if (HandManager.IsRayRelativeUp())
        {
            foreach (GameObject part in partsVisualRay)
            {
                part.GetComponent <Renderer>().material = rayInactiveMaterial;
            }
        }

        if (HandManager.IsRayRelativeDown())
        {
            if (HandManager.CurrentHand.TryGetRotation(out rotation))
            {
                currentRelativeRotation = Quaternion.identity;
                lastRelativeRotation    = rotation;
                startRelativeQuat       = rotation;
                foreach (GameObject part in partsVisualRay)
                {
                    part.GetComponent <Renderer>().material = rayActiveMaterial;
                }
                if (HandManager.CurrentHand.TryGetAngularVelocity(out angularVelocity))
                {
                    GainFunction.ResetFunction(angularVelocity);
                }
                else
                {
                    GainFunction.ResetFunction(startRelativeQuat, Time.time);
                }
            }
            else
            {
                startRelativeQuat = Quaternion.identity;
                GainFunction.ResetFunction(startRelativeQuat, Time.time);
                Debug.LogError("No start rotation data avaiable.");
                return;
            }
        }

        if (HandManager.IsRayRelative() || HandManager.IsRayRelativeUp())
        {
            if (HandManager.CurrentHand.TryGetAngularVelocity(out angularVelocity))
            {
                GainFunction.Instance.UpdateFunction(Mathf.Rad2Deg * angularVelocity.magnitude);
            }
            else if (HandManager.CurrentHand.TryGetRotation(out rotation))
            {
                GainFunction.Instance.UpdateFunction(rotation, Time.time);
            }
            else
            {
                Debug.LogError("No velocity and rotation data avaiable");
            }
        }
    }
コード例 #2
0
 private void Awake()
 {
     Instance = this;
 }