pub struct Projection<Kind> { /* private fields */ }Expand description
Configuration for a 3D projection.
See specific Kind implementations for constructors, e.g.
Projection::perspective and Projection::orthographic.
To use the resulting projection, convert it to a Matrix4 with [From]/[Into].
Implementations§
Source§impl<Kind> Projection<Kind>
impl<Kind> Projection<Kind>
Sourcepub fn coordinates(self, orientation: CoordinateOrientation) -> Self
pub fn coordinates(self, orientation: CoordinateOrientation) -> Self
Set the coordinate system’s orientation for the projection.
See CoordinateOrientation for more details.
§Example
let clip_planes = ClipPlanes {
near: 0.1,
far: 100.0,
};
let mtx: Matrix4 = Projection::perspective(40.0, AspectRatio::TopScreen, clip_planes)
.coordinates(CoordinateOrientation::LeftHanded)
.into();Sourcepub fn screen(self, orientation: ScreenOrientation) -> Self
pub fn screen(self, orientation: ScreenOrientation) -> Self
Set the screen rotation for the projection.
See ScreenOrientation for more details.
§Example
let clip_planes = ClipPlanes {
near: 0.1,
far: 100.0,
};
let mtx: Matrix4 = Projection::perspective(40.0, AspectRatio::TopScreen, clip_planes)
.screen(ScreenOrientation::None)
.into();Source§impl Projection<Perspective>
impl Projection<Perspective>
Sourcepub fn perspective(
vertical_fov_radians: f32,
aspect_ratio: AspectRatio,
clip_planes: ClipPlanes,
) -> Self
pub fn perspective( vertical_fov_radians: f32, aspect_ratio: AspectRatio, clip_planes: ClipPlanes, ) -> Self
Construct a projection matrix suitable for projecting 3D world space onto the 3DS screens.
§Parameters
vertical_fov: the vertical field of view, measured in radiansaspect_ratio: the aspect ratio of the projectionclip_planes: the near and far clip planes of the view frustum.ClipPlanesare always defined by near and far values, regardless of the projection’sCoordinateOrientation.
§Examples
let clip_planes = ClipPlanes {
near: 0.01,
far: 100.0,
};
let bottom: Matrix4 =
Projection::perspective(PI / 4.0, AspectRatio::BottomScreen, clip_planes).into();
let top: Matrix4 =
Projection::perspective(PI / 4.0, AspectRatio::TopScreen, clip_planes).into();Sourcepub fn stereo_matrices(
self,
left_eye: StereoDisplacement,
right_eye: StereoDisplacement,
) -> (Matrix4, Matrix4)
pub fn stereo_matrices( self, left_eye: StereoDisplacement, right_eye: StereoDisplacement, ) -> (Matrix4, Matrix4)
Helper function to build both eyes’ perspective projection matrices
at once. See StereoDisplacement for details on how to configure
stereoscopy.
let (left, right) = StereoDisplacement::new(0.5, 2.0);
let (left_eye, right_eye) = Projection::perspective(
PI / 4.0,
AspectRatio::TopScreen,
ClipPlanes {
near: 0.01,
far: 100.0,
},
)
.stereo_matrices(left, right);Source§impl Projection<Orthographic>
impl Projection<Orthographic>
Sourcepub fn orthographic(
clip_planes_x: Range<f32>,
clip_planes_y: Range<f32>,
clip_planes_z: ClipPlanes,
) -> Self
pub fn orthographic( clip_planes_x: Range<f32>, clip_planes_y: Range<f32>, clip_planes_z: ClipPlanes, ) -> Self
Construct an orthographic projection. The X and Y clip planes are passed as ranges because their coordinates are always oriented the same way (+X right, +Y up).
The Z ClipPlanes, however, are always defined by
near and far values, regardless of the projection’s CoordinateOrientation.
§Example
let mtx: Matrix4 = Projection::orthographic(
0.0..240.0,
0.0..400.0,
ClipPlanes {
near: 0.0,
far: 100.0,
},
)
.into();Trait Implementations§
Source§impl<Kind: Clone> Clone for Projection<Kind>
impl<Kind: Clone> Clone for Projection<Kind>
Source§fn clone(&self) -> Projection<Kind>
fn clone(&self) -> Projection<Kind>
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Kind: Debug> Debug for Projection<Kind>
impl<Kind: Debug> Debug for Projection<Kind>
Source§impl From<Projection<Orthographic>> for Matrix4
impl From<Projection<Orthographic>> for Matrix4
Source§fn from(projection: Projection<Orthographic>) -> Self
fn from(projection: Projection<Orthographic>) -> Self
Source§impl From<Projection<Perspective>> for Matrix4
impl From<Projection<Perspective>> for Matrix4
Source§fn from(projection: Projection<Perspective>) -> Self
fn from(projection: Projection<Perspective>) -> Self
Auto Trait Implementations§
impl<Kind> Freeze for Projection<Kind>where
Kind: Freeze,
impl<Kind> RefUnwindSafe for Projection<Kind>where
Kind: RefUnwindSafe,
impl<Kind> Send for Projection<Kind>where
Kind: Send,
impl<Kind> Sync for Projection<Kind>where
Kind: Sync,
impl<Kind> Unpin for Projection<Kind>where
Kind: Unpin,
impl<Kind> UnwindSafe for Projection<Kind>where
Kind: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)