void GetValue()
 {
     acceleration.Value        = _nodeState.TryGetAcceleration(out _acceleration) ? _acceleration : Vector3.zero;
     velocity.Value            = _nodeState.TryGetVelocity(out _velocity) ? _velocity : Vector3.zero;
     angularAcceleration.Value = _nodeState.TryGetAngularAcceleration(out _angularAcceleration) ? _angularAcceleration : Vector3.zero;
     angularVelocity.Value     = _nodeState.TryGetAngularVelocity(out _angularVelocity) ? _angularVelocity : Vector3.zero;
 }
Esempio n. 2
0
    void Update()
    {
        if (NodeTitle_Text != null)
        {
            NodeTitle_Text.text = m_Node.ToString();
        }

        var nodeStates = new List <XRNodeState>();

        UnityEngine.XR.InputTracking.GetNodeStates(nodeStates);

        XRNodeState?state = null;

        foreach (XRNodeState nodeState in nodeStates)
        {
            if (nodeState.nodeType == m_Node)
            {
                state = nodeState;
                break;
            }
        }

        if (state.HasValue)
        {
            XRNodeState node = state.Value;
            Vector3     tempVector;
            Quaternion  tempQuaternion;

            // Translation Information
            SetImageColor(Position_Image, node.TryGetPosition(out tempVector));
            Position_Text.text = Vector3ToFieldText(tempVector);
            SetImageColor(Velocity_Image, node.TryGetVelocity(out tempVector));
            Velocity_Text.text = Vector3ToFieldText(tempVector);
            SetImageColor(Acceleration_Image, node.TryGetAcceleration(out tempVector));
            Acceleration_Text.text = Vector3ToFieldText(tempVector);

            // Rotation Information
            SetImageColor(Rotation_Image, node.TryGetRotation(out tempQuaternion));
            Rotation_Text.text = QuaternionToFieldText(tempQuaternion);
            SetImageColor(AngularVelocity_Image, node.TryGetAngularVelocity(out tempVector));
            AngularVelocity_Text.text = Vector3ToFieldText(tempVector);
            SetImageColor(AngularAcceleration_Image, node.TryGetAngularAcceleration(out tempVector));
            AngularAcceleration_Text.text = Vector3ToFieldText(tempVector);
        }
        else
        {
            // Translation Information
            SetImageColor(Position_Image, false);
            SetImageColor(Velocity_Image, false);
            SetImageColor(Acceleration_Image, false);

            // Rotation Information
            SetImageColor(Rotation_Image, false);
            SetImageColor(AngularVelocity_Image, false);
            SetImageColor(AngularAcceleration_Image, false);
        }
    }
Esempio n. 3
0
        public void Update(XRNodeState nodeState)
        {
            _position            = Vector3.zero;
            _rotation            = new Quaternion();
            _acceleration        = Vector3.zero;
            _angularAcceleration = Vector3.zero;
            _velocity            = Vector3.zero;
            _angularVelocity     = Vector3.zero;

            isTracked = nodeState.tracked;

            if (nodeState.TryGetPosition(out _position))
            {
                position = _position;
            }

            if (nodeState.TryGetRotation(out _rotation))
            {
                rotation = _rotation;
            }

            if (nodeState.TryGetVelocity(out _velocity))
            {
                velocity = _velocity;
            }

            if (nodeState.TryGetAngularVelocity(out _angularVelocity))
            {
                angularVelocity = _angularVelocity;
            }

            if (nodeState.TryGetAcceleration(out _acceleration))
            {
                acceleration = _acceleration;
            }

            if (nodeState.TryGetAngularAcceleration(out _angularAcceleration))
            {
                angularAcceleration = _angularAcceleration;
            }
        }