Scene class

Main scene data structure.

This class aggregates all the surfaces and materials along with the camera. It provides convenience functions for querying materials by name.

Base classes

class Surface
This is the abstract superclass for all surfaces.

Constructors, destructors, conversion operators

Scene(const json& j)
Construct a new scene from a json object.
~Scene() virtual
Release all memory.

Public functions

void parse(const json& j)
Parser a scene from a json object.
void add_child(shared_ptr<Surface> surface) override
Add a child surface.
auto intersect(const Ray3f& ray, HitInfo& hit) const -> bool override
Ray-Surface intersection test.
auto bounds() const -> Box3f override
Return the surface's world-space AABB.
auto background(const Ray3f& ray) const -> Color3f
Return the background color.
auto camera() const -> shared_ptr<const Camera>
Return the camera.
auto recursive_color(const Ray3f& ray, int depth) const -> Color3f
Sample the color along a ray.
auto raytrace() const -> Image3f
Generate the entire image by ray tracing.

Function documentation

void Scene::add_child(shared_ptr<Surface> surface) override

Add a child surface.

This function will become useful once we create groups of objects. The base class implementation just throws an error.

This function should only be used before build() is called.

bool Scene::intersect(const Ray3f& ray, HitInfo& hit) const override

Ray-Surface intersection test.

Parameters
ray A 3-dimensional ray data structure with minimum/maximum extent information
hit A detailed intersection record, which will be filled by the intersection query
Returns true if an intersection was found

Intersect a ray against this surface and return detailed intersection information.

Color3f Scene::recursive_color(const Ray3f& ray, int depth) const

Sample the color along a ray.

Parameters
ray The ray in question
depth The current recursion depth
Returns An estimate of the color from this direction