use rubullet::image::RgbaImage;
use rubullet::nalgebra::Matrix4;
use rubullet::{CameraImageOptions, PhysicsClient};
use std::cell::RefCell;
use std::rc::Rc;
pub struct SimCamera {
view_matrix: Matrix4<f32>,
projection_matrix: Matrix4<f32>,
width: usize,
height: usize,
}
impl SimCamera {
pub fn new(
width: usize,
height: usize,
view_matrix: Matrix4<f32>,
projection_matrix: Matrix4<f32>,
) -> SimCamera {
SimCamera {
view_matrix,
projection_matrix,
width,
height,
}
}
pub fn get_image(&self, client: Rc<RefCell<PhysicsClient>>) -> RgbaImage {
client
.borrow_mut()
.get_camera_image(
self.width,
self.height,
CameraImageOptions {
view_matrix: Some(self.view_matrix),
projection_matrix: Some(self.projection_matrix),
..Default::default()
},
)
.unwrap()
.rgba
}
}