pub struct Camera { /* private fields */ }Implementations§
Source§impl Camera
Basic creation and mutation.
impl Camera
Basic creation and mutation.
Sourcepub fn new(options: GraphicsOptions, viewport: Viewport) -> Camera
pub fn new(options: GraphicsOptions, viewport: Viewport) -> Camera
Create a camera which has
- options and viewport as given,
- a view transform of
ViewTransform::identity(), and - an exposure determined based on the graphics options.
Sourcepub fn set_options(&mut self, options: GraphicsOptions)
pub fn set_options(&mut self, options: GraphicsOptions)
Replace the GraphicsOptions stored in this camera with
options.repair().
Sourcepub fn options(&self) -> &GraphicsOptions
pub fn options(&self) -> &GraphicsOptions
Returns the GraphicsOptions value last provided to
Camera::new() or Camera::set_options() (possibly with
adjusted values).
Sourcepub fn set_viewport(&mut self, viewport: Viewport)
pub fn set_viewport(&mut self, viewport: Viewport)
Sets the contained viewport value, and recalculates matrices to be suitable for the new viewport’s aspect ratio.
Sourcepub fn viewport(&self) -> Viewport
pub fn viewport(&self) -> Viewport
Returns the viewport last provided to Camera::new() or Camera::set_viewport().
Sourcepub fn set_view_transform(
&mut self,
eye_to_world_transform: RigidTransform3D<f64, Eye, Cube>,
)
pub fn set_view_transform( &mut self, eye_to_world_transform: RigidTransform3D<f64, Eye, Cube>, )
Sets the view transform and recalculates matrices appropriately.
Note that this is specified as the eye-to-world transform; that is, the given transform’s translation should be equal to the view point in world coordinates.
Besides controlling rendering, this is used to determine world coordinates for purposes
of view_position() and
project_ndc_into_world().
Sourcepub fn look_at_y_up(
&mut self,
eye: Point3D<f64, Cube>,
target: Point3D<f64, Cube>,
)
pub fn look_at_y_up( &mut self, eye: Point3D<f64, Cube>, target: Point3D<f64, Cube>, )
Sets the view transform like Camera::set_view_transform(), but in “look at” fashion.
Sourcepub fn view_transform(&self) -> RigidTransform3D<f64, Eye, Cube>
pub fn view_transform(&self) -> RigidTransform3D<f64, Eye, Cube>
Returns the last eye-to-world transform set by Camera::set_view_transform().
Sourcepub fn set_measured_exposure(&mut self, value: f32)
pub fn set_measured_exposure(&mut self, value: f32)
Sets the exposure value that should have been determined by average scene brightness.
This may or may not affect Self::exposure() depending on the current
graphics options.
Source§impl Camera
Values derived from the basic parameters, and
functions for applying this camera’s characteristics to points and colors.
impl Camera
Values derived from the basic parameters, and functions for applying this camera’s characteristics to points and colors.
Sourcepub fn fov_y(&self) -> f64
pub fn fov_y(&self) -> f64
Returns the field of view, expressed in degrees on the vertical axis (that is, the horizontal field of view depends on the viewport’s aspect ratio).
Sourcepub fn view_distance(&self) -> PositiveSign<f64>
pub fn view_distance(&self) -> PositiveSign<f64>
Returns the view distance; the far plane of the view frustum, or the distance at which rendering may be truncated.
Sourcepub fn near_plane_distance(&self) -> PositiveSign<f64>
pub fn near_plane_distance(&self) -> PositiveSign<f64>
Returns the position of the near plane of the view frustum. This is not currently configurable.
Sourcepub fn projection_matrix(&self) -> Transform3D<f64, Eye, Ndc>
pub fn projection_matrix(&self) -> Transform3D<f64, Eye, Ndc>
Returns a perspective projection matrix based on the configured FOV and view distance,
It maps coordinates in “eye” space into the Normalized Device Cooordinate space whose range is from -1 to 1 in X and Y, and 0 to 1 in Z. (This is DirectX and WebGPU style NDC, rather than OpenGL style which has a range of -1 to 1 in Z.)
Sourcepub fn view_matrix(&self) -> Transform3D<f64, Cube, Eye>
pub fn view_matrix(&self) -> Transform3D<f64, Cube, Eye>
Returns a matrix which maps coordinates in world space to coordinates in eye space.
It is the inverse of the current Camera::view_transform().
Sourcepub fn view_position(&self) -> Point3D<f64, Cube>
pub fn view_position(&self) -> Point3D<f64, Cube>
Returns the eye position in world coordinates, as set by Camera::set_view_transform().
Sourcepub fn project_ndc_into_world(&self, ndc: Point2D<f64, Ndc>) -> Ray
pub fn project_ndc_into_world(&self, ndc: Point2D<f64, Ndc>) -> Ray
Converts a screen position in normalized device coordinates (as produced by
Viewport::normalize_nominal_point()) into a ray in world space.
Uses the view transformation given by set_view_transform.
The input coordinates should be within the range -1 to 1, inclusive. If they are not, the result may be a ray whose components are NaN.
The ray’s origin’s distance along the view direction axis is equal to
Camera::near_plane_distance().
The ray’s Ray::unit_endpoint() along the view direction axis is equal to
Camera::view_distance().
Sourcepub fn view_direction_mask(&self) -> OctantMask
pub fn view_direction_mask(&self) -> OctantMask
Returns an OctantMask which includes all directions (in world space) visible in
images rendered as specified by this camera.
This information may be used as a fast initial culling step, avoiding iterating over content behind the camera.
Sourcepub fn aab_in_view(&self, aab: Aab) -> bool
pub fn aab_in_view(&self, aab: Aab) -> bool
Determine whether the given Aab is visible in this projection+view.
Sourcepub fn exposure(&self) -> PositiveSign<f32>
pub fn exposure(&self) -> PositiveSign<f32>
Returns the current exposure value for scaling luminance.
Renderers should use this value, not the fixed exposure value in the GraphicsOptions.
It may or may not be equal to the last
set_measured_exposure(),
depending on the graphics options.
Sourcepub fn post_process_color(&self, color: Rgba) -> Rgba
pub fn post_process_color(&self, color: Rgba) -> Rgba
Apply postprocessing steps determined by this camera to convert a HDR “scene” color into a SDR “image” color. Specifically:
- Multiply the input by this camera’s
exposure()value. - Apply the tone mapping operator specified in
Camera::options().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnsafeUnpin for Camera
impl UnwindSafe for Camera
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more