Ejemplo n.º 1
0
            // Updates the position and rotation of the eye
            // Optionally, update the viewer associated with this eye
            public void UpdateEyePoses()
            {
                OSVR.ClientKit.Pose3 eyePose0 = RenderManager.GetRenderManagerEyePose((byte)0);
                OSVR.ClientKit.Pose3 eyePose1 = RenderManager.GetRenderManagerEyePose((byte)1);


                // Convert from OSVR space into Unity space.
                Vector3    pos0 = OSVR.Unity.Math.ConvertPosition(eyePose0.translation);
                Quaternion rot0 = OSVR.Unity.Math.ConvertOrientation(eyePose0.rotation);

                Vector3    pos1 = OSVR.Unity.Math.ConvertPosition(eyePose1.translation);
                Quaternion rot1 = OSVR.Unity.Math.ConvertOrientation(eyePose1.rotation);

                if (stereoRigSetup == StereoRigSetup.OneCameraBothEyes)
                {
                    Quaternion slerpedRot = Quaternion.Slerp(rot0, rot1, 0.5f);
                    Vector3    pos        = new Vector3((pos0.x + pos1.x) * 0.5f, (pos0.y + pos1.y) * 0.5f, (pos0.z + pos1.z) * 0.5f);

                    // Invert the transformation
                    _camera0CachedTransform.localRotation = Quaternion.Inverse(slerpedRot);
                    Vector3 invPos = -pos;
                    _camera0CachedTransform.localPosition = Quaternion.Inverse(slerpedRot) * invPos;
                }
                else //two-camera setup
                {
                    //this script is attached to the left eye, with a right-eye sibling gameobject
                    _camera0CachedTransform.localRotation = Quaternion.Inverse(rot0);
                    Vector3 invPos = -pos0;
                    _camera0CachedTransform.localPosition = Quaternion.Inverse(rot0) * invPos;

                    _camera1CachedTransform.localRotation = Quaternion.Inverse(rot1);
                    invPos = -pos1;
                    _camera1CachedTransform.localPosition = Quaternion.Inverse(rot1) * invPos;
                }
            }
Ejemplo n.º 2
0
 // Updates the position and rotation of the eye
 // Optionally, update the viewer associated with this eye
 public void UpdateEyePose(OSVR.ClientKit.Pose3 eyePose)
 {
     cachedTransform.localPosition = Math.ConvertPosition(eyePose.translation);
     //cachedTransform.localRotation = Viewer.DisplayController.UseRenderManager ? Math.ConvertOrientationFromRenderManager(eyePose.rotation) : Math.ConvertOrientation(eyePose.rotation);
     //@todo use DisplayConfig path until RenderManager EyePose bug is fixed
     cachedTransform.localRotation = Math.ConvertOrientation(eyePose.rotation);
 }
Ejemplo n.º 3
0
Archivo: Math.cs Proyecto: sjb8100/C3DE
 public static XnaPose ConvertPose(OSVR.ClientKit.Pose3 pose)
 {
     return(new XnaPose
     {
         Position = Math.ConvertPosition(pose.translation),
         Rotation = Math.ConvertOrientation(pose.rotation),
     });
 }
Ejemplo n.º 4
0
            // Updates the position and rotation of the eye
            // Optionally, update the viewer associated with this eye
            public void UpdateEyePose(OSVR.ClientKit.Pose3 eyePose)
            {
                // Convert from OSVR space into Unity space.
                Vector3    pos = Math.ConvertPosition(eyePose.translation);
                Quaternion rot = Math.ConvertOrientation(eyePose.rotation);

                // RenderManager produces the eyeFromSpace matrix, but
                // Unity wants the inverse of that.
                if (Viewer.DisplayController.UseRenderManager)
                {
                    // Invert the transformation
                    cachedTransform.localRotation = Quaternion.Inverse(rot);
                    Vector3 invPos = -pos;
                    cachedTransform.localPosition = Quaternion.Inverse(rot) * invPos;
                }
                else
                {
                    cachedTransform.localPosition = pos;
                    cachedTransform.localRotation = rot;
                }
            }
Ejemplo n.º 5
0
            // Updates the position and rotation of the head
            // Optionally, update the viewer associated with this head
            public void UpdateHeadPose()
            {
                OSVR.ClientKit.Pose3 eyePose0 = RenderManager.GetRenderManagerEyePose((byte)0);
                OSVR.ClientKit.Pose3 eyePose1 = RenderManager.GetRenderManagerEyePose((byte)1);


                // Convert from OSVR space into Unity space.
                Vector3    pos0 = OSVR.Unity.Math.ConvertPosition(eyePose0.translation);
                Quaternion rot0 = OSVR.Unity.Math.ConvertOrientation(eyePose0.rotation);

                Vector3    pos1 = OSVR.Unity.Math.ConvertPosition(eyePose1.translation);
                Quaternion rot1 = OSVR.Unity.Math.ConvertOrientation(eyePose1.rotation);

                Quaternion slerpedRot = Quaternion.Slerp(rot0, rot1, 0.5f);
                Vector3    pos        = new Vector3((pos0.x + pos1.x) * 0.5f, (pos0.y + pos1.y) * 0.5f, (pos0.z + pos1.z) * 0.5f);

                // Invert the transformation
                _camera0CachedTransform.localRotation = Quaternion.Inverse(slerpedRot);
                Vector3 invPos = -pos;

                _camera0CachedTransform.localPosition = Quaternion.Inverse(slerpedRot) * invPos;
            }
Ejemplo n.º 6
0
 //Updates the position and rotation of the head
 public void UpdateViewerHeadPose(OSVR.ClientKit.Pose3 headPose)
 {
     cachedTransform.localPosition = Math.ConvertPosition(headPose.translation);
     cachedTransform.localRotation = Math.ConvertOrientation(headPose.rotation);
 }
Ejemplo n.º 7
0
 public static Matrix4x4 ConvertPose(OSVR.ClientKit.Pose3 pose)
 {
     return(Matrix4x4.TRS(Math.ConvertPosition(pose.translation), Math.ConvertOrientation(pose.rotation), Vector3.zero));
 }
Ejemplo n.º 8
0
 // Updates the position and rotation of the eye
 // Optionally, update the viewer associated with this eye
 public void UpdateEyePose(OSVR.ClientKit.Pose3 eyePose)
 {
     cachedTransform.localPosition = Math.ConvertPosition(eyePose.translation);
     cachedTransform.localRotation = Math.ConvertOrientation(eyePose.rotation);
 }