private void SetSpatialInteractionSourceLocation(SpatialInteractionSourceLocation location)
 {
     currentPosition        = location.Position?.ToVector3() ?? currentPosition;
     currentRotation        = location.Orientation?.ToQuaternion() ?? currentRotation;
     currentLinearVelocity  = location.Velocity?.ToVector3() ?? currentLinearVelocity;
     currentAngularVelocity = location.AngularVelocity?.ToVector3() ?? currentAngularVelocity;
 }
Example #2
0
        private void sourceUpdate(SpatialInteractionManager manager, SpatialInteractionSourceEventArgs args)
        {
            SpatialCoordinateSystem          currentCoordinateSystem = referenceFrame.CoordinateSystem;
            SpatialInteractionSourceLocation pos = args.State.Properties.TryGetLocation(currentCoordinateSystem);

            HolographicFrame holographicFrame = holographicSpace.CreateNextFrame();

            // Get a prediction of where holographic cameras will be when this frame
            // is presented.
            HolographicFramePrediction prediction = holographicFrame.CurrentPrediction;
            // Get the gaze direction relative to the given coordinate system.
            Vector3            headPosition = (Vector3)pos.Position;
            SpatialPointerPose pose         = SpatialPointerPose.TryGetAtTimestamp(currentCoordinateSystem, prediction.Timestamp);

            SpatialInteractionSource source = args.State.Source;

            Vector3 headDirection = pose.Head.ForwardDirection;

            // The hologram is positioned two meters along the user's gaze direction.
            float   distanceFromUser = 0.1f; // meters
            Vector3 gazeAtTwoMeters  = headPosition + (distanceFromUser * headDirection);

            // This will be used as the translation component of the hologram's
            // model transform.
            this.position = gazeAtTwoMeters;
        }
        public void Update(PerceptionTimestamp timeStamp, SpatialCoordinateSystem coordinateSystem)
        {
            var states = interactionManager.GetDetectedSourcesAtTimestamp(timeStamp);

            foreach (SpatialInteractionSourceState state in states)
            {
                if (state.Source.Handedness == hand)
                {
                    SpatialInteractionSourceLocation location = state.Properties.TryGetLocation(coordinateSystem);

                    if (location != null)
                    {
                        SetSpatialInteractionSourceLocation(location);
                    }

                    previousState = currentState;
                    currentState  = state;

                    internalState = previousState != null ? DeviceState.Valid : DeviceState.Invalid;
                }
            }
        }