Ejemplo n.º 1
0
        /// <summary>
        /// Write out any error details received from the Oculus SDK, into the debug output window.
        /// 
        /// Please note that writing text to the debug output window is a slow operation and will affect performance,
        /// if too many messages are written in a short timespan.
        /// </summary>
        /// <param name="oculus">OculusWrap object for which the error occurred.</param>
        /// <param name="result">Error code to write in the debug text.</param>
        /// <param name="message">Error message to include in the debug text.</param>
        public void WriteErrorDetails(OculusWrap.Wrap oculus, OculusWrap.OVR.ovrResult result, string message)
        {
            if (result >= OculusWrap.OVR.ovrResult.Success)
            return;

            // Retrieve the error message from the last occurring error.
            OculusWrap.OVR.ovrErrorInfo errorInformation = oculus.GetLastError();

            string formattedMessage = string.Format("{0}. Message: {1} (Error code={2})", message, errorInformation.ErrorString, errorInformation.Result);
            Trace.WriteLine(formattedMessage);

            throw new Exception(formattedMessage);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Converts an ovrQuatf to a SharpDX Quaternion.
 /// </summary>
 public static Quaternion ToQuaternion(OculusWrap.OVR.Quaternionf ovrQuatf)
 {
     return new Quaternion(ovrQuatf.X, ovrQuatf.Y, ovrQuatf.Z, ovrQuatf.W);
 }
Ejemplo n.º 3
0
        void UpdateTransform(OculusWrap.OVR.Posef eye_pose, OculusWrap.OVR.FovPort fov)
        {
            // Retrieve the eye rotation quaternion and use it to calculate the LookAt direction and the LookUp direction.
            Camera camera = new Camera()
            {
            Position = main_camera.Position + Vector3.Transform(eye_pose.Position.ToVector3(), main_camera.Rotation),
            Rotation = main_camera.Rotation * SharpDXHelpers.ToQuaternion(eye_pose.Orientation),
            };

            world_matrix = Matrix.Scaling(ocu_config.Scale);
            Transform_View = camera.GetViewMatrix();
            Transform_Projection = OculusWrap.OVR.ovrMatrix4f_Projection(fov, ocu_config.Znear, ocu_config.Zfar, OculusWrap.OVR.ProjectionModifier.RightHanded).ToMatrix();
            Transform_Projection.Transpose();

            Matrix world_view_matrix = world_matrix * Transform_View;
            world_view_projection_matrix = world_view_matrix * Transform_Projection;

            World_variable.SetMatrix(world_matrix);
            WorldView_variable.SetMatrix(world_view_matrix);
            WorldViewProjection_variable.SetMatrix(world_view_projection_matrix);
            /* for HUD */
            Projection_variable.SetMatrix(Transform_Projection);
        }