Terrain

Struct Terrain 

Source
pub struct Terrain<M: Material> { /* private fields */ }
Expand description

A terrain geometry based on a height map and with an applied material.

Implementations§

Source§

impl<M: Material + Clone> Terrain<M>

Source

pub fn new( context: &Context, material: M, height_map: Arc<dyn Fn(f32, f32) -> f32 + Send + Sync>, side_length: f32, vertex_distance: f32, center: Vec2, ) -> Self

Creates a new Terrain. The height map is a function of the (x, z) coordinates which returns the height of the terrain y.

Source

pub fn height_at(&self, position: Vec2) -> f32

Returns the height at the given position.

Source

pub fn set_lod(&mut self, lod: Arc<dyn Fn(f32) -> Lod + Send + Sync>)

Set the function that specifies when a certain level of detail Lod is uses. The input to the function is the distance from the current camera to the center of a part of the terrain.

Source

pub fn set_center(&mut self, center: Vec2)

Set the center of the terrain. To be able to move the terrain with the camera, thereby simulating infinite terrain.

Trait Implementations§

Source§

impl<'a, M: Material> IntoIterator for &'a Terrain<M>

Source§

type Item = &'a dyn Object

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<&'a dyn Object>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<M> Freeze for Terrain<M>
where M: Freeze,

§

impl<M> !RefUnwindSafe for Terrain<M>

§

impl<M> Send for Terrain<M>
where M: Send,

§

impl<M> Sync for Terrain<M>
where M: Sync,

§

impl<M> Unpin for Terrain<M>
where M: Unpin,

§

impl<M> !UnwindSafe for Terrain<M>

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> 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, 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.
Source§

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