Struct rustic_zen::scene::Scene

source ·
pub struct Scene { /* private fields */ }
Expand description

Holds scene Configuration and logic

Implementations§

source§

impl Scene

source

pub fn new(resolution_x: usize, resolution_y: usize) -> Self

Creates new Renderer ready for defining a scene.

source

pub fn add_light(&mut self, light: Light<Pcg64Mcg>)

Adds a light to the scene

source

pub fn with_light(self, light: Light<Pcg64Mcg>) -> Self

Adds a light to the scene - Chainable variant

source

pub fn add_object<A>(&mut self, object: A)
where A: Into<Object<Pcg64Mcg>>,

Adds an object to the scene. Object is an internal representation used by the raytracer, A should be anything that implements Into<Object> currently only Segment provides this.

§Example Usage:
use rustic_zen::prelude::*;
let a = (0.0, 0.0);
let b = (10.0, 10.0);
// Or other math to construct your scene here,
let line = Segment::line_from_points(a, b, material::hqz_legacy_default());

let mut s = Scene::new(1920,1080);
s.add_object(line); //Segment automatically converted to hidden object type here.
source

pub fn with_object<A>(self, object: A) -> Self
where A: Into<Object<Pcg64Mcg>>,

Adds an object to the scene - Chainable Variant. Object is an internal representation used by the raytracer, A should be anything that implements Into<Object> currently only Segment provides this.

§Example Usage:
use rustic_zen::prelude::*;
let a = Point::new(0.0, 0.0);
let b = Point::new(10.0, 10.0);
// Or other math to construct your scene here,
let line = Segment::line_from_points(a, b, material::hqz_legacy_default());

//Segment automatically converted to hidden object type here.
let s = Scene::new(1920,1080).with_object(line);
source

pub fn render<C>( self, constraint: C, threads: usize, image: &mut Arc<impl RenderImage + 'static> ) -> usize

Starts the ray tracing process

Naturally this call is very expensive. It also consumes the Renderer and populates the provided Image with the rendered image data. The total number of rays cast into the scene is returned.

§Parameters:

constraint: A RenderConstraint object, which defines the condition to stop rendering. threads: the number of cpu threads the render will use. The renderer will automatically spawn this many threads. image: a Image to be populated with image data.

The renderer will automatically use the GPU if a VulkanImage is passed into the image slot, otherwise the image will be rendered solely in software..

§Returns:

usize The first value is the number of rays added to the scene. This is needed for some image export functions. The second value is the resulting image as an Image object, which has serveral export functions.

Trait Implementations§

source§

impl Clone for Scene

source§

fn clone(&self) -> Scene

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl !RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl !UnwindSafe for Scene

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V