pub struct StandardCameras { /* private fields */ }Expand description
Bundle of inputs specifying the “standard” configuration of Cameras and other
things to render an All is Cubes scene and user interface.
All of its data is provided through listen::DynSources, and consists of:
GraphicsOptions.- A
Viewportspecifying the dimensions of image to render. - A
Handleto theCharacterwhose eyes we look through to render the “world”Space. - A
Handleto the UI/HUDSpaceoverlaid on the world, if any.
When StandardCameras::update() is called, all of these data sources are read
and used to update the Camera data. Those cameras, and copies of the input
data, are then available for use while rendering.
Because every input is a listen::DynSource, it is never necessary to call a setter.
Every StandardCameras which was created with the same sources will have the same
results (after update()).
Design note: The sense in which this is “standard” is that if an application wished
to, for example, have multiple views into the same Space, it would need to create
additional Cameras (or multiple StandardCameras) and update them itself.
Implementations§
Source§impl StandardCameras
impl StandardCameras
Sourcepub fn update(&mut self, read_tickets: Layers<ReadTicket<'_>>) -> bool
pub fn update(&mut self, read_tickets: Layers<ReadTicket<'_>>) -> bool
Updates camera state from data sources.
This should be called at the beginning of each frame or as needed when the cameras are to be used.
Returns whether any values actually changed. (This does not include tracking changes to space content — only which part of which spaces are being looked at.)
Sourcepub fn graphics_options(&self) -> &GraphicsOptions
pub fn graphics_options(&self) -> &GraphicsOptions
Returns current graphics options as of the last update().
These options are to be used for the world and not the UI.
Sourcepub fn graphics_options_source(&self) -> DynSource<Arc<GraphicsOptions>>
pub fn graphics_options_source(&self) -> DynSource<Arc<GraphicsOptions>>
Returns a clone of the source of graphics options that this StandardCameras
was created with.
These options are to be used for the world and not the UI.
Sourcepub fn cameras(&self) -> &Layers<Camera>
pub fn cameras(&self) -> &Layers<Camera>
Returns Cameras appropriate for drawing each graphical layer.
Sourcepub fn character(&self) -> Option<&StrongHandle<Character>>
pub fn character(&self) -> Option<&StrongHandle<Character>>
Returns the character’s viewpoint to draw in the world layer.
May be None if there is no current character.
Sourcepub fn world_space(&self) -> DynSource<Option<Handle<Space>>>
pub fn world_space(&self) -> DynSource<Option<Handle<Space>>>
Returns the space that should be drawn as the game world, using self.cameras().world.
This is a listen::DynSource to make it simple to cache the Space rendering data and
follow space transitions.
It updates when Self::update() is called.
Sourcepub fn ui_space(&self) -> Option<&Handle<Space>>
pub fn ui_space(&self) -> Option<&Handle<Space>>
Returns the UI space, that should be drawn on top of the world using self.cameras().ui.
This implements GraphicsOptions::show_ui by returning None when the option is
false.
TODO: Make this also a listen::DynSource
Sourcepub fn viewport(&self) -> Viewport
pub fn viewport(&self) -> Viewport
Returns the current viewport.
This is always equal to the viewports of all managed Cameras,
and only updates when StandardCameras::update() is called.
Sourcepub fn viewport_source(&self) -> DynSource<Viewport>
pub fn viewport_source(&self) -> DynSource<Viewport>
Returns a clone of the viewport source this is following.
Sourcepub fn project_cursor(
&self,
read_tickets: Layers<ReadTicket<'_>>,
ndc_pos: NdcPoint2,
) -> Result<Option<Cursor>, HandleError>
pub fn project_cursor( &self, read_tickets: Layers<ReadTicket<'_>>, ndc_pos: NdcPoint2, ) -> Result<Option<Cursor>, HandleError>
Perform a raycast through these cameras to find what the cursor hits.
Make sure to call StandardCameras::update first so that the cameras are
up to date with game state.
Sourcepub fn clone_unupdated(&self) -> Self
pub fn clone_unupdated(&self) -> Self
Returns a StandardCameras which tracks the same data sources (graphics
options, scene sources, viewport) as self, but whose local state (such as
the last updated camera state) is independent.
The local state is also not updated; you must call StandardCameras::update()
on the clone before reading anything from it.
Trait Implementations§
Source§impl Debug for StandardCameras
impl Debug for StandardCameras
Auto Trait Implementations§
impl !RefUnwindSafe for StandardCameras
impl !UnwindSafe for StandardCameras
impl Freeze for StandardCameras
impl Send for StandardCameras
impl Sync for StandardCameras
impl Unpin for StandardCameras
impl UnsafeUnpin for StandardCameras
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>
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