Beispiel #1
0
        private bool TryGetInteractionSourcePoseRay(InteractionSourcePose pose, out Ray ray)
        {
            Vector3 forward;
            Vector3 position;

            if (pose.TryGetForward(out forward) &&
                pose.TryGetPosition(out position))
            {
                ray = new Ray(position, forward);
                return(true);
            }
            ray = new Ray();
            return(false);
        }
    // estimates hand position and direction from the source pose
    private void GetHandPosAndDir(InteractionSourcePose sourcePose, bool bControllerInput)
    {
        sourcePose.TryGetPosition(out handPosition);
        if (!bControllerInput)
        {
            handPosition.y += 0.05f;
        }

        if (bControllerInput)
        {
            sourcePose.TryGetForward(out handDirection);
        }
        else
        {
            handDirection = (handPosition - mainCamera.transform.position).normalized;
        }
    }
Beispiel #3
0
        void updatePose(InteractionSourcePose pose)
        {
            Vector3    angularVelocity, gripPosition, pointerPosition, pointerForward, gripForward;
            Quaternion gripRotation, pointerRotation;

            if (pose.TryGetPosition(out gripPosition, InteractionSourceNode.Grip))
            {
                _currentState.GripPosition = gripPosition;
            }

            if (pose.TryGetPosition(out pointerPosition, InteractionSourceNode.Pointer))
            {
                _currentState.PointerPosition = pointerPosition;
            }

            if (pose.TryGetRotation(out pointerRotation, InteractionSourceNode.Pointer))
            {
                _currentState.PointerRotation = pointerRotation;
            }


            if (pose.TryGetRotation(out gripRotation, InteractionSourceNode.Grip))
            {
                _currentState.GripRotation = gripRotation;
            }

            if (pose.TryGetForward(out pointerForward, InteractionSourceNode.Pointer))
            {
                _currentState.PointerForward = pointerForward;
            }

            if (pose.TryGetAngularVelocity(out angularVelocity))
            {
                _currentState.AngularVelocity = angularVelocity;
            }
        }