[][src]Struct all_is_cubes::camera::ProjectionHelper

pub struct ProjectionHelper {
    pub cursor_ndc_position: Vector2<FreeCoordinate>,
    // some fields omitted
}

Tool for setting up and using a projection matrix. Stores viewport dimensions and aspect ratio, and derives a projection matrix.

Also stores an externally-provided view matrix (world space to camera space). If not needed, can be ignored.

Fields

cursor_ndc_position: Vector2<FreeCoordinate>

Position of mouse pointer or other input device in normalized device coordinates (range -1 to 1 upward and rightward). If there is no such input device, zero will be the center of the screen.

Implementations

impl ProjectionHelper[src]

pub fn new(pixel_aspect_ratio: FreeCoordinate, viewport: Vector2<usize>) -> Self[src]

pixel_aspect_ratio is the width divided by the height

pub fn viewport(&self) -> Vector2<usize>[src]

pub fn set_viewport(&mut self, viewport: Vector2<usize>)[src]

pub fn set_cursor_position(&mut self, position: Point2<usize>)[src]

Set the current cursor position. In the same pixel units as set_viewport.

pub fn set_view_matrix(&mut self, view: Matrix4<FreeCoordinate>)[src]

pub fn normalize_pixel_x(&self, x: usize) -> FreeCoordinate[src]

As per OpenGL normalized device coordinates, output ranges from -1 to 1.

pub fn normalize_pixel_y(&self, y: usize) -> FreeCoordinate[src]

As per OpenGL normalized device coordinates, output ranges from -1 to 1.

pub fn projection(&self) -> Matrix4<FreeCoordinate>[src]

Returns a projection matrix suitable for OpenGL use.

pub fn project_ndc_into_world(
    &self,
    ndc_x: FreeCoordinate,
    ndc_y: FreeCoordinate
) -> Ray
[src]

Convert a screen position in normalized device coordinates (as produced by normalize_pixel_x & normalize_pixel_y) into a ray in world space. Uses the view transformation given by set_view_matrix.

pub fn project_cursor_into_world(&self) -> Ray[src]

Convert the cursor position into a ray in world space. Uses the view transformation given by set_view_matrix.

Trait Implementations

impl Clone for ProjectionHelper[src]

impl Copy for ProjectionHelper[src]

impl Debug for ProjectionHelper[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> Erased for T[src]

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

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

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>,