Struct gl_utils::camera3d::Camera3d [−][src]
pub struct Camera3d { pub position: Point3<f32>, pub yaw: Rad<f32>, pub pitch: Rad<f32>, pub orientation: Basis3<f32>, pub transform_mat_world_to_view: Matrix4<f32>, pub projection3d: Projection3d, }
Represents a camera ("view") positioned and oriented in a 3D scene with a 3D transformation and a 3D projection.
Fields
position: Point3<f32>
Position in 3D world space
yaw: Rad<f32>
Yaw represents a clockwise rotation restricted to the range $[0, 2\pi)$.
pitch: Rad<f32>
Pitch represents a rotation up or down restricted to the range $[-\pi/2, \pi/2]$.
orientation: Basis3<f32>
Basis derived from yaw
and pitch
.
transform_mat_world_to_view: Matrix4<f32>
Transforms points from world space to camera (view, eye) space as specified by the camera position and orientation.
Note that world space is assumed to have 'up' vector Z while in OpenGL the negative Z axis is 'into' the screen so this matrix performs the required transform mapping positive Y to negative Z and positive Z to positive Y.
projection3d: Projection3d
Methods
impl Camera3d
[src]
impl Camera3d
pub fn new(viewport_width: u16, viewport_height: u16) -> Self
[src]
pub fn new(viewport_width: u16, viewport_height: u16) -> Self
Create a new camera centered at the origin looking down the positive Y axis with 'up' vector aligned with the Z axis.
pub fn with_pose(
viewport_width: u16,
viewport_height: u16,
pose: Pose3d<f32>
) -> Self
[src]
pub fn with_pose(
viewport_width: u16,
viewport_height: u16,
pose: Pose3d<f32>
) -> Self
Create a new 3D camera with the given viewport, position, and orientation.
pub fn set_viewport_dimensions(
&mut self,
viewport_width: u16,
viewport_height: u16
)
[src]
pub fn set_viewport_dimensions(
&mut self,
viewport_width: u16,
viewport_height: u16
)
Should be called when the screen resolution changes.
pub fn set_position(&mut self, position: &Point3<f32>)
[src]
pub fn set_position(&mut self, position: &Point3<f32>)
pub fn rotate(&mut self, dyaw: Rad<f32>, dpitch: Rad<f32>)
[src]
pub fn rotate(&mut self, dyaw: Rad<f32>, dpitch: Rad<f32>)
pub fn move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
[src]
pub fn move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
Moves the view position relative to the X/Y plane with X and Y direction determined by heading and Z always aligned with the Z axis, i.e. the translated position is only determined by the current yaw not the pitch.
pub fn view_mats(&self) -> (&[[f32; 4]; 4], &[[f32; 4]; 4])
[src]
pub fn view_mats(&self) -> (&[[f32; 4]; 4], &[[f32; 4]; 4])
Returns the raw world to view transform and view to clip projection matrix data, suitable for use as shader uniforms.