[][src]Struct amethyst_rendy::Camera

pub struct Camera {
    pub matrix: Matrix4<f32>,
    pub inverse: Matrix4<f32>,
}

Camera struct.

Contains a projection matrix to convert from world/eye-space into normalized device coordinates. For rendy/gfx-hal these are y-down, x-right and y-away in range [0; 1]

World Coordinate system +y | +z | / |/___+x

NDC system -z / |¯¯¯+x | +y

The camera also stores the inverse transformation in order to avoid recomputing it.

If you change matrix you must also change inverse so that they stay in sync. You should probably use from_matrix instead.

Fields

matrix: Matrix4<f32>

The projection matrix

inverse: Matrix4<f32>

Its inverse

Implementations

impl Camera[src]

pub fn standard_2d(width: f32, height: f32) -> Self[src]

Create a normalized camera for 2D.

Will use an orthographic projection centered around (0, 0) of size (width, height) Bottom left corner is (-width/2.0, -height/2.0) View transformation will be multiplicative identity.

pub fn orthographic(
    left: f32,
    right: f32,
    bottom: f32,
    top: f32,
    z_near: f32,
    z_far: f32
) -> Self
[src]

An appropriate orthographic projection for the coordinate space used by Amethyst. Because we use vulkan coordinates internally and within the rendering engine, normal nalgebra projection objects (Orthographic3 are incorrect for our use case.

The projection matrix is right-handed and depth goes from 1 to 0.

Arguments

  • left - The x-coordinate of the cuboid leftmost face parallel to the yz-plane.

  • right - The x-coordinate of the cuboid rightmost face parallel to the yz-plane.

  • top - The upper y-coordinate of the cuboid leftmost face parallel to the xz-plane.

  • bottom - The lower y-coordinate of the cuboid leftmost face parallel to the xz-plane.

  • z_near - The distance between the viewer (the origin) and the closest face of the cuboid parallel to the xy-plane. If used for a 3D rendering application, this is the closest clipping plane.

  • z_far - The distance between the viewer (the origin) and the furthest face of the cuboid parallel to the xy-plane. If used for a 3D rendering application, this is the furthest clipping plane.

  • panics if left equals right, bottom equals top or z_near equals z_far

pub fn standard_3d(width: f32, height: f32) -> Self[src]

Create a standard camera for 3D.

Will use a perspective projection with aspect from the given screen dimensions and a field of view of π/3 radians (60 degrees). View transformation will be multiplicative identity.

pub fn perspective(aspect: f32, fov: f32, z_near: f32) -> Self[src]

An appropriate perspective projection for the coordinate space used by Amethyst. Because we use vulkan coordinates internally and within the rendering engine, normal nalgebra projection objects (Perspective3) are incorrect for our use case.

The projection matrix is right-handed and depth goes from 1 to 0.

Arguments

  • aspect - Aspect Ratio represented as a f32 ratio.

  • fov - Field of View represented in radians

  • z_near - Near clip plane distance

  • panics when matrix is not invertible

pub fn from_matrix(matrix: Matrix4<f32>) -> Self[src]

Makes a camera with the matrix provided.

  • panics if the matrix is not invertible

pub fn screen_ray(
    &self,
    screen_position: Point2<f32>,
    screen_diagonal: Vector2<f32>,
    camera_transform: &Transform
) -> Ray<f32>
[src]

Returns a Ray going out form the camera through provided screen position. The ray origin lies on camera near plane.

The screen coordinate (0, 0) is the top-left corner of the top-left pixel. screen_diagonal is the bottom-right corner of the bottom-right pixel.

pub fn screen_to_world_point(
    &self,
    screen_position: Point3<f32>,
    screen_diagonal: Vector2<f32>,
    camera_transform: &Transform
) -> Point3<f32>
[src]

Transforms the provided (X, Y, Z) screen coordinate into world coordinates. This method fires a ray from the camera in its view direction, and returns the Point at screen_position.z world space distance from the camera origin.

pub fn world_to_screen(
    &self,
    world_position: Point3<f32>,
    screen_diagonal: Vector2<f32>,
    camera_transform: &Transform
) -> Point2<f32>
[src]

Translate from world coordinates to screen coordinates

The screen coordinate (0, 0) is the top-left corner of the top-left pixel. screen_diagonal is the bottom-right corner of the bottom-right pixel.

Trait Implementations

impl Clone for Camera[src]

impl Component for Camera[src]

type Storage = HashMapStorage<Self>

Associated storage type for this component.

impl Debug for Camera[src]

impl<'de> Deserialize<'de> for Camera[src]

impl PartialEq<Camera> for Camera[src]

impl Serialize for Camera[src]

Auto Trait Implementations

impl RefUnwindSafe for Camera

impl Send for Camera

impl Sync for Camera

impl Unpin for Camera

impl UnwindSafe for Camera

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clone for T where
    T: Clone
[src]

impl<T> Config for T where
    T: for<'a> Deserialize<'a> + Serialize
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Event for T where
    T: Send + Sync + 'static, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: Any + Send + Sync

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> SetParameter for T

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> Supports<T> for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,