Example #1
0
        /// <summary>
        /// Creates an empty packet with a specific task type.
        /// </summary>
        public static HeadTrackingRequest CreateEmptyPacketByType(Task type)
        {
            var packet = new HeadTrackingRequest()
            {
                Version    = CurrentVersion,
                TaskType   = (byte)type,
                Data       = new byte[64],
                DataLength = 0
            };

            return(packet);
        }
Example #2
0
        /// <summary>
        /// Creates a packet that will store an offset on VRidge side that will be applied to each phone rotation.
        /// Rotation is stored indefinitely. It can be reset with <see cref="Task.ResetAsyncOffset"/> packet.
        /// </summary>
        public static HeadTrackingRequest CreateAsyncOffsetPacket(float yaw, float pitch, float roll)
        {
            var packet = new HeadTrackingRequest()
            {
                Version    = CurrentVersion,
                TaskType   = (int)Task.ProvideAsyncRotationOffsetAsVector,
                Data       = new byte[64],
                DataLength = 12
            };

            Buffer.BlockCopy(new[] { pitch, yaw, roll }, 0, packet.Data, 0, 12);

            return(packet);
        }
Example #3
0
        /// <summary>
        /// Creates a packet that overrides VRidge data with full pose (rotation and position).
        /// Rotation uses radians.
        /// </summary>
        /// <returns></returns>
        public static HeadTrackingRequest CreateRotationPositionVectorPacket(float yaw, float pitch, float roll, float x, float y, float z)
        {
            var packet = new HeadTrackingRequest()
            {
                Version    = CurrentVersion,
                TaskType   = (int)Task.SendRadRotationAndPosition,
                Data       = new byte[64],
                DataLength = 24
            };

            Buffer.BlockCopy(new[] { pitch, yaw, roll, x, y, z }, 0, packet.Data, 0, 24);

            return(packet);
        }
Example #4
0
        /// <summary>
        /// Creates a packet that overrides VRidge data with full pose (rotation and position).
        /// Matrix is stored as column-major float flat array.
        /// </summary>
        public static HeadTrackingRequest CreateFullPoseMatrixPacket(float[] poseMatrix)
        {
            var packet = new HeadTrackingRequest()
            {
                Version    = CurrentVersion,
                TaskType   = (int)Task.SendPoseMatrixFull,
                Data       = new byte[64],
                DataLength = 64
            };

            Buffer.BlockCopy(poseMatrix, 0, packet.Data, 0, 64);

            return(packet);
        }
Example #5
0
        /// <summary>
        /// Creates a packet that sets VR position at specific location.
        /// This position is then combined with phone-provided rotation.
        /// </summary>
        public static HeadTrackingRequest CreatePositionPacket(float x, float y, float z)
        {
            var packet = new HeadTrackingRequest()
            {
                Version    = CurrentVersion,
                TaskType   = (int)Task.SendPositionOnly,
                Data       = new byte[64],
                DataLength = 12
            };

            Buffer.BlockCopy(new[] { x, y, z }, 0, packet.Data, 0, 12);

            return(packet);
        }