Struct rustic_zen::scene::Scene
source · pub struct Scene { /* private fields */ }
Expand description
Holds scene Configuration and logic
Implementations§
source§impl Scene
impl Scene
sourcepub fn new(resolution_x: usize, resolution_y: usize) -> Self
pub fn new(resolution_x: usize, resolution_y: usize) -> Self
Creates new Renderer ready for defining a scene.
sourcepub fn with_light(self, light: Light<Pcg64Mcg>) -> Self
pub fn with_light(self, light: Light<Pcg64Mcg>) -> Self
Adds a light to the scene - Chainable variant
sourcepub fn add_object<A>(&mut self, object: A)
pub fn add_object<A>(&mut self, object: A)
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.
sourcepub fn with_object<A>(self, object: A) -> Self
pub fn with_object<A>(self, object: A) -> Self
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);
sourcepub fn render<C>(
self,
constraint: C,
threads: usize,
image: &mut Arc<impl RenderImage + 'static>
) -> usizewhere
C: Into<RenderConstraint>,
pub fn render<C>(
self,
constraint: C,
threads: usize,
image: &mut Arc<impl RenderImage + 'static>
) -> usizewhere
C: Into<RenderConstraint>,
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.