pub struct Camera<Tf> {
pub transform: Tf,
pub dims: Dims,
pub project: Mat4x4<ViewToProj>,
pub viewport: Mat4x4<NdcToScreen>,
}Expand description
Type to manage the world-to-viewport transformation.
Fields§
§transform: TfWorld-to-view transform.
dims: DimsViewport width and height.
project: Mat4x4<ViewToProj>Projection matrix.
viewport: Mat4x4<NdcToScreen>Viewport matrix.
Implementations§
Source§impl<T> Camera<T>
impl<T> Camera<T>
Sourcepub fn viewport(self, bounds: impl Into<Rect<u32>>) -> Self
pub fn viewport(self, bounds: impl Into<Rect<u32>>) -> Self
Sets the viewport bounds of this camera.
Sourcepub fn perspective(self, fov: Fov, near_far: Range<f32>) -> Self
pub fn perspective(self, fov: Fov, near_far: Range<f32>) -> Self
Sets up perspective projection with the given field of view and near–far range.
The endpoints of near_far denote the distance of the near and far
clipping planes.
§Panics
- If any parameter value is non-positive.
- If
near_faris an empty range.
Sourcepub fn orthographic(self, bounds: Range<Point3>) -> Self
pub fn orthographic(self, bounds: Range<Point3>) -> Self
Sets up orthographic projection.
Source§impl<T: Transform> Camera<T>
impl<T: Transform> Camera<T>
Sourcepub fn world_to_project(&self) -> Mat4x4<RealToProj<World>>
pub fn world_to_project(&self) -> Mat4x4<RealToProj<World>>
Returns the composed camera and projection matrix.
Sourcepub fn render<B, Prim, Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>(
&self,
prims: impl AsRef<[Prim]>,
verts: impl AsRef<[Vtx]>,
to_world: &Mat4x4<RealToReal<3, B, World>>,
shader: &Shd,
uniform: Uni,
target: &mut impl Target,
ctx: &Context,
)
pub fn render<B, Prim, Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>( &self, prims: impl AsRef<[Prim]>, verts: impl AsRef<[Vtx]>, to_world: &Mat4x4<RealToReal<3, B, World>>, shader: &Shd, uniform: Uni, target: &mut impl Target, ctx: &Context, )
Renders the given geometry from the viewpoint of this camera.
Trait Implementations§
impl<Tf: Copy> Copy for Camera<Tf>
Auto Trait Implementations§
impl<Tf> Freeze for Camera<Tf>where
Tf: Freeze,
impl<Tf> RefUnwindSafe for Camera<Tf>where
Tf: RefUnwindSafe,
impl<Tf> Send for Camera<Tf>where
Tf: Send,
impl<Tf> Sync for Camera<Tf>where
Tf: Sync,
impl<Tf> Unpin for Camera<Tf>where
Tf: Unpin,
impl<Tf> UnwindSafe for Camera<Tf>where
Tf: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more