#[repr(C)]pub struct Camera {
pub entity: Entity,
}Expand description
Camera implements most of the functionality related to cameras. It deals with processing of mouse events and with moving the camera in an orbit like manner. It contains a reference to the entity in the world so that changes done by the camera object will directly affect the entity.
Fields§
§entity: EntityImplementations§
Source§impl Camera
impl Camera
pub fn new(name: &str, scene: &mut Scene, initialize: bool) -> Self
pub fn from_entity(entity: Entity) -> Self
pub fn is_initialized(&self, scene: &Scene) -> bool
Sourcepub fn view_matrix(&self, scene: &Scene) -> Matrix4<f32>
pub fn view_matrix(&self, scene: &Scene) -> Matrix4<f32>
§Panics
Will panic if the PosLookat component does not exist for this entity
Sourcepub fn proj_matrix(&self, scene: &Scene) -> Matrix4<f32>
pub fn proj_matrix(&self, scene: &Scene) -> Matrix4<f32>
§Panics
Will panic if the Projection component does not exist for this
entity
Sourcepub fn proj_matrix_reverse_z(&self, scene: &Scene) -> Matrix4<f32>
pub fn proj_matrix_reverse_z(&self, scene: &Scene) -> Matrix4<f32>
§Panics
Will panic if the Projection component does not exist for this
entity
Sourcepub fn two_axis_rotation(
cam_axis_x: Vector3<f32>,
viewport_size: Vector2<f32>,
speed: f32,
prev_mouse: Vector2<f32>,
current_mouse: Vector2<f32>,
) -> (Rotation3<f32>, Rotation3<f32>)
pub fn two_axis_rotation( cam_axis_x: Vector3<f32>, viewport_size: Vector2<f32>, speed: f32, prev_mouse: Vector2<f32>, current_mouse: Vector2<f32>, ) -> (Rotation3<f32>, Rotation3<f32>)
Performs a two-axis rotation of the camera by mapping the xy coordianates of the mouse to rotation around the Y axis of the world and the X axis of the camera.
Sourcepub fn project(
&self,
point_world: Point3<f32>,
view: Matrix4<f32>,
proj: Matrix4<f32>,
viewport_size: Vector2<f32>,
) -> Vector3<f32>
pub fn project( &self, point_world: Point3<f32>, view: Matrix4<f32>, proj: Matrix4<f32>, viewport_size: Vector2<f32>, ) -> Vector3<f32>
Projects from 3D world to 2D screen coordinates in the range [0,
viewport_width] and [0, viewport_height]
Sourcepub fn unproject(
&self,
win: Point3<f32>,
view: Matrix4<f32>,
proj: Matrix4<f32>,
viewport_size: Vector2<f32>,
) -> Vector3<f32>
pub fn unproject( &self, win: Point3<f32>, view: Matrix4<f32>, proj: Matrix4<f32>, viewport_size: Vector2<f32>, ) -> Vector3<f32>
Unprojects from 2D screen coordinates in range [0, viewport_width] and
[0, viewport_height] to 3D world # Panics
Will panic if the proj*view matrix is not invertable
Sourcepub fn clear_click(&self, scene: &mut Scene)
pub fn clear_click(&self, scene: &mut Scene)
Clear the click state once processed, so this doesnt keep running
pub fn is_click(&self, scene: &Scene) -> bool
Sourcepub fn touch_pressed(&mut self, touch_event: &Touch, scene: &mut Scene)
pub fn touch_pressed(&mut self, touch_event: &Touch, scene: &mut Scene)
Handle the event of touching with a finger
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn touch_released(&mut self, touch_event: &Touch, scene: &mut Scene)
pub fn touch_released(&mut self, touch_event: &Touch, scene: &mut Scene)
Handle the event of pressing mouse
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn reset_all_touch_presses(&mut self, scene: &mut Scene)
pub fn reset_all_touch_presses(&mut self, scene: &mut Scene)
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn process_touch_move(
&mut self,
touch_event: &Touch,
viewport_width: u32,
viewport_height: u32,
scene: &mut Scene,
)
pub fn process_touch_move( &mut self, touch_event: &Touch, viewport_width: u32, viewport_height: u32, scene: &mut Scene, )
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn mouse_pressed(&mut self, mouse_button: &MouseButton, scene: &mut Scene)
pub fn mouse_pressed(&mut self, mouse_button: &MouseButton, scene: &mut Scene)
Handle the event of pressing mouse
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn mouse_released(&mut self, scene: &mut Scene)
pub fn mouse_released(&mut self, scene: &mut Scene)
Handle the event of releasing mouse
§Panics
Will panic if the CamController component does not exist for this
entity
Sourcepub fn process_mouse_move(
&mut self,
position_x: f64,
position_y: f64,
viewport_width: u32,
viewport_height: u32,
scene: &mut Scene,
)
pub fn process_mouse_move( &mut self, position_x: f64, position_y: f64, viewport_width: u32, viewport_height: u32, scene: &mut Scene, )
Handle the event of dragging the mouse on the window
§Panics
Will panic if the PosLookat, Projection, CamController
component does not exist for this entity
Sourcepub fn process_mouse_scroll(
&mut self,
delta: &MouseScrollDelta,
scene: &mut Scene,
)
pub fn process_mouse_scroll( &mut self, delta: &MouseScrollDelta, scene: &mut Scene, )
Handle event of scrolling the mouse wheel. It performs a zoom.
§Panics
Will panic if the PosLookat, CamController component does not
exist for this entity
Sourcepub fn set_aspect_ratio(&mut self, val: f32, scene: &mut Scene)
pub fn set_aspect_ratio(&mut self, val: f32, scene: &mut Scene)
Resizing the window means that the projection matrix of the camera has
to change accordingly so as to not squish the scene # Panics
Will panic if the Projection component does not exist for this
entity
Sourcepub fn set_aspect_ratio_maybe(&mut self, val: f32, scene: &mut Scene)
pub fn set_aspect_ratio_maybe(&mut self, val: f32, scene: &mut Scene)
Resizing the window means that the projection matrix of the camera has to change accordingly so as to not squish the scene
pub fn near_far(&self, scene: &mut Scene) -> (f32, f32)
Sourcepub fn set_target_res(&mut self, width: u32, height: u32, scene: &mut Scene)
pub fn set_target_res(&mut self, width: u32, height: u32, scene: &mut Scene)
Unconditionally sets the target res, regardless of the update mode
Sourcepub fn on_window_resize(&mut self, width: u32, height: u32, scene: &mut Scene)
pub fn on_window_resize(&mut self, width: u32, height: u32, scene: &mut Scene)
Sets the target res on window resizing, only updates if the updatemode
is WindowSize
pub fn get_target_res(&self, scene: &Scene) -> (u32, u32)
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 UnwindSafe for Camera
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.