Skip to main content

Camera

Struct Camera 

Source
pub struct Camera {
    pub view: Mat4,
    pub proj: Mat4,
    pub clear_color: [f32; 4],
}

Fields§

§view: Mat4§proj: Mat4§clear_color: [f32; 4]

RGBA, sRGB-0..1 wie im Szenen-Editor.

Implementations§

Source§

impl Camera

Source

pub fn perspective( eye: Vec3, target: Vec3, up: Vec3, fovy_rad: f32, aspect: f32, ) -> Self

Perspektive (rechtshändig, Blick von eye nach target).

Source

pub fn orthographic( eye: Vec3, target: Vec3, up: Vec3, height: f32, aspect: f32, ) -> Self

Orthografisch — Draufsicht fuer Maps und Minimap-Renderer.

Source

pub fn view_proj(&self) -> Mat4

View*Proj — die einzige Matrix, die die meisten Shader sehen.

Source

pub fn depth_range(&self) -> Option<(f32, f32)>

Lineare Tiefen-Spanne (near, far) einer Perspektiv-Projektion, aus der Matrix zurueckgewonnen — die Cluster-Scheiben brauchen sie, und der Renderer kennt nur die Matrix, nicht die Konstanten.

fuer perspective_rh (Depth 0..1) gilt: z_axis.z = f/(n-f), w_axis.z = n*f/(n-f), z_axis.w = -1. Daraus folgt n = w_axis.z / z_axis.z und f = w_axis.z / (z_axis.z + 1). near ist damit auf die Rundung der Division genau; far traegt eine Ausloeschung (nahe -1 plus 1) und erreicht nur ~1e-3 relative Genauigkeit — fuer logarithmische Cluster- Scheiben und konservatives Culling genuegend, weil CPU und GPU dieselben Werte teilen. Orthografische oder entartete Matrizen ergeben None.

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Camera

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Camera

Source§

impl Debug for Camera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.