pub fn calculate_mvp(
        &self,
        overlay_transform: &Matrix4<f64>,
        camera_calib: &crate::steam::StereoCamera,
        (fov_left, fov_right): (&[f64; 2], &[f64; 2]),
        ivrsystem: &crate::openvr::VRSystem,
        hmd_transform: &Matrix4<f64>,
    ) -> (Matrix4<f32>, Matrix4<f32>) {
        let left_eye: Matrix4<_> = ivrsystem
            .pin_mut()
            .GetEyeToHeadTransform(openvr_sys::EVREye::Eye_Left)
            .into();
        let right_eye: Matrix4<_> = ivrsystem
            .pin_mut()
            .GetEyeToHeadTransform(openvr_sys::EVREye::Eye_Right)
            .into();

        // Camera space to HMD space transform, based on physical measurements
        let left_cam: Matrix4<_> = matrix![
            1.0, 0.0, 0.0, -camera_calib.left.extrinsics.position[0];
            0.0, 1.0, 0.0, -camera_calib.left.extrinsics.position[1];
            0.0, 0.0, 1.0, -camera_calib.left.extrinsics.position[2];
            0.0, 0.0, 0.0, 1.0;
        ];
        let right_cam: Matrix4<_> = matrix![
            1.0, 0.0, 0.0, -camera_calib.right.extrinsics.position[0];
            0.0, 1.0, 0.0, -camera_calib.right.extrinsics.position[1];
            0.0, 0.0, 1.0, -camera_calib.right.extrinsics.position[2];
            0.0, 0.0, 0.0, 1.0;
        ];

        let (left_eye, right_eye) = match self.mode {
            ProjectionMode::FromEye => (hmd_transform * left_eye, hmd_transform * right_eye),
            ProjectionMode::FromCamera => (hmd_transform * left_cam, hmd_transform * right_cam),
        };
        let left_view = left_eye
            .try_inverse()
            .expect("HMD transform not invertable?");
        let right_view = right_eye
            .try_inverse()
            .expect("HMD transform not invertable?");

        // X gets fov / 2.0 because the source texture is a side-by-side stereo texture
        // X translation element is used to map them to left/right side of the texture,
        // respectively.
        //
        let camera_projection_left = matrix![
            fov_left[0] / 2.0, 0.0, 0.0, 0.0;
            0.0, fov_left[1], 0.0, 0.0;
            0.0, 0.0, -1.0, 0.0;
            0.0, 0.0, 0.0, 1.0;
        ];
        let camera_projection_right = matrix![
            fov_right[0] / 2.0, 0.0, 0.0, 0.0;
            0.0, fov_right[1] , 0.0, 0.0;
            0.0, 0.0, -1.0, 0.0;
            0.0, 0.0, 0.0, 1.0;
        ];
        (
            (camera_projection_left * left_view * overlay_transform).cast(),
            (camera_projection_right * right_view * overlay_transform).cast(),
        )
    }
/// Calculate the _physical_ camera's MVP, for each eye.
/// camera_calib = camera calibration data.
/// fov_left/right = adjusted fovs, in ratio (not in pixels)
/// frame_time = how long after the first frame is the current frame taken
/// time_origin = instant when the first frame is taken
Calculate the _physical_ camera's MVP, for each eye.
camera_calib = camera calibration data.
fov_left/right = adjusted fovs, in ratio (not in pixels)
frame_time = how long after the first frame is the current frame taken
time_origin = instant when the first frame is taken
Calculate the _physical_ camera ' s MVP for each eye . camera_calib = camera calibration data . fov_left / right = adjusted fovs in ratio ( not in pixels ) frame_time = how long after the first frame is the current frame taken time_origin = instant when the first frame is taken
pub fn calculate_mvp(
        &self,
        overlay_transform: &Matrix4<f64>,
        camera_calib: &crate::steam::StereoCamera,
        (fov_left, fov_right): (&[f64; 2], &[f64; 2]),
        ivrsystem: &crate::openvr::VRSystem,
        hmd_transform: &Matrix4<f64>,
    ) -> (Matrix4<f32>, Matrix4<f32>) {
        let left_eye: Matrix4<_> = ivrsystem
            .pin_mut()
            .GetEyeToHeadTransform(openvr_sys::EVREye::Eye_Left)
            .into();
        let right_eye: Matrix4<_> = ivrsystem
            .pin_mut()
            .GetEyeToHeadTransform(openvr_sys::EVREye::Eye_Right)
            .into();
        // Camera space to HMD space transform, based on physical measurements
        let left_cam: Matrix4<_> = matrix![
            1.0, 0.0, 0.0, -camera_calib.left.extrinsics.position[0];
            0.0, 1.0, 0.0, -camera_calib.left.extrinsics.position[1];
            0.0, 0.0, 1.0, -camera_calib.left.extrinsics.position[2];
            0.0, 0.0, 0.0, 1.0;
        ];
        let right_cam: Matrix4<_> = matrix![
            1.0, 0.0, 0.0, -camera_calib.right.extrinsics.position[0];
            0.0, 1.0, 0.0, -camera_calib.right.extrinsics.position[1];
            0.0, 0.0, 1.0, -camera_calib.right.extrinsics.position[2];
            0.0, 0.0, 0.0, 1.0;
        ];
        let (left_eye, right_eye) = match self.mode {
            ProjectionMode::FromEye => (hmd_transform * left_eye, hmd_transform * right_eye),
            ProjectionMode::FromCamera => (hmd_transform * left_cam, hmd_transform * right_cam),
        };
        let left_view = left_eye
            .try_inverse()
            .expect("HMD transform not invertable?");
        let right_view = right_eye
            .try_inverse()
            .expect("HMD transform not invertable?");
        // X gets fov / 2.0 because the source texture is a side-by-side stereo texture
        // X translation element is used to map them to left/right side of the texture,
        // respectively.
        //
        let camera_projection_left = matrix![
            fov_left[0] / 2.0, 0.0, 0.0, 0.0;
            0.0, fov_left[1], 0.0, 0.0;
            0.0, 0.0, -1.0, 0.0;
            0.0, 0.0, 0.0, 1.0;
        ];
        let camera_projection_right = matrix![
            fov_right[0] / 2.0, 0.0, 0.0, 0.0;
            0.0, fov_right[1] , 0.0, 0.0;
            0.0, 0.0, -1.0, 0.0;
            0.0, 0.0, 0.0, 1.0;
        ];
        (
            (camera_projection_left * left_view * overlay_transform).cast(),
            (camera_projection_right * right_view * overlay_transform).cast(),
        )
    }
pub fn calculate_mvp ( & self , overlay_transform : & Matrix4 < f64 > , camera_calib : & crate :: steam :: StereoCamera , ( fov_left , fov_right ) : ( & [ f64 ; 2 ] , & [ f64 ; 2 ] ) , ivrsystem : & crate :: openvr :: VRSystem , hmd_transform : & Matrix4 < f64 > , ) -> ( Matrix4 < f32 > , Matrix4 < f32 > ) { let left_eye : Matrix4 < _ > = ivrsystem . pin_mut ( ) . GetEyeToHeadTransform ( openvr_sys :: EVREye :: Eye_Left ) . into ( ) ; let right_eye : Matrix4 < _ > = ivrsystem . pin_mut ( ) . GetEyeToHeadTransform ( openvr_sys :: EVREye :: Eye_Right ) . into ( ) ; // Camera space to HMD space transform, based on physical measurements let left_cam : Matrix4 < _ > = matrix ! [ 1.0 0.0 0.0 camera_calib left extrinsics position [ 0 ] 0.0 1.0 0.0 camera_calib left extrinsics position [ 1 ] 0.0 0.0 1.0 camera_calib left extrinsics position [ 2 ] 0.0 0.0 0.0 1.0 ] ; let right_cam : Matrix4 < _ > = matrix ! [ 1.0 0.0 0.0 camera_calib right extrinsics position [ 0 ] 0.0 1.0 0.0 camera_calib right extrinsics position [ 1 ] 0.0 0.0 1.0 camera_calib right extrinsics position [ 2 ] 0.0 0.0 0.0 1.0 ] ; let ( left_eye , right_eye ) = match self . mode { ProjectionMode :: FromEye => ( hmd_transform * left_eye , hmd_transform * right_eye ) , ProjectionMode :: FromCamera => ( hmd_transform * left_cam , hmd_transform * right_cam ) , } ; let left_view = left_eye . try_inverse ( ) . expect ( " " ) ; let right_view = right_eye . try_inverse ( ) . expect ( " " ) ; // X gets fov / 2.0 because the source texture is a side-by-side stereo texture // X translation element is used to map them to left/right side of the texture, // respectively. // let camera_projection_left = matrix ! [ fov_left [ 0 ] 2.0 0.0 0.0 0.0 0.0 fov_left [ 1 ] 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 ] ; let camera_projection_right = matrix ! [ fov_right [ 0 ] 2.0 0.0 0.0 0.0 0.0 fov_right [ 1 ] 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 ] ; ( ( camera_projection_left * left_view * overlay_transform ) . cast ( ) , ( camera_projection_right * right_view * overlay_transform ) . cast ( ) , ) }
Calculate the _physical_ camera's MVP, for each eye.
Calculate the _physical_ camera ' s MVP for each eye .
&self
overlay_transform
&Matrix4<f64>
camera_calib
(&[f64; 2], &[f64; 2])
ivrsystem
&crate::openvr::VRSystem
hmd_transform
&Matrix4<f64>
&self
overlay_transform
&Matrix4<f64>
camera_calib
(&[f64; 2], &[f64; 2])
ivrsystem
&crate::openvr::VRSystem
hmd_transform
&Matrix4<f64>