C++ / OpenCL Raytracer
RayTracer Class Reference

#include <ray_tracer.h>

Public Member Functions

 RayTracer ()
 
 RayTracer (const SDim &dims, const int iRaysPerPixel=100)
 
 RayTracer (const SDim &dims, const int iRaysPerPixel, Camera &cam)
 
virtual void SetCamera (Vector3D lookFrom, Vector3D lookAt=Vector3D(0), Vector3D viewUp=Vector3D(0, 1, 0), double aperture=.1, double Fov=40)
 
virtual void AddItem (Object *object)
 
virtual void RandomScene ()
 
virtual void ShowPerformance ()
 
virtual void OpenImage ()
 
virtual Vector3D Color (const Ray &r, int iDepth)
 
virtual void Render (const std::string &strFileName)
 
virtual int clRender (const std::string &strFileName)
 
virtual void ClearItems ()
 

Public Attributes

vList m_list
 Vector list of objects to be rendered.
 
const SDim m_dims
 Struct containing the dimensions of the desired output image {x, y} (in pixels)
 
int m_iRaysPerPixel
 Number of anti-aliasing samples to take per pixel.
 
Camera m_camera
 Camera object specifying the desired perspective of the output image.
 

Detailed Description

Ray Tracing wrapper; intialization and calculation functions.

Constructor & Destructor Documentation

◆ RayTracer() [1/3]

RayTracer::RayTracer ( )

Initiate a ray tracer instance

Example:

RayTracer();

◆ RayTracer() [2/3]

RayTracer::RayTracer ( const SDim dims,
const int  iRaysPerPixel = 100 
)
inline

Initiate a ray tracer instance

Example:

RayTracer(dimensions, 100);

◆ RayTracer() [3/3]

RayTracer::RayTracer ( const SDim dims,
const int  iRaysPerPixel,
Camera cam 
)
inline

Initiate a ray tracer instance

Example:

RayTracer(dimensions, 100, cam);

Member Function Documentation

◆ AddItem()

void RayTracer::AddItem ( Object object)
virtual

Link renderable objects to ray tracer instance

Example:

ray_tracer->AddItem(&Sphere(Vector3D(0), 1, new Lambertian(Vector3D(1)));

◆ ClearItems()

void RayTracer::ClearItems ( )
virtual

Remove all objects from ray tracer instance vector list

Example:

ray_tracer->ClearItems();

or

delete ray_tracer;

◆ clRender()

int RayTracer::clRender ( const std::string &  fileName)
virtual

Calculations and image output function for ray tracer instance.

Example:

ray_tracer->Render("image");

◆ Color()

Vector3D RayTracer::Color ( const Ray r,
int  iDepth 
)
virtual

Return Color Vector3D if ray intersects object.

Example:

Color(ray, vectorList, 0);

◆ OpenImage()

void RayTracer::OpenImage ( )
virtual

Open image in default image viewer after rendering (Windows Only)

Example:

ray_tracer->OpenImage();

◆ RandomScene()

void RayTracer::RandomScene ( )
virtual

Add a random set of objects to create a demo scene similar to the cover of Ray Tracing in One Weekend

Example:

ray_tracer->RandomScene();

◆ Render()

void RayTracer::Render ( const std::string &  fileName)
virtual

Calculations and image output function for ray tracer instance.

Example:

ray_tracer->Render("image");

◆ SetCamera()

void RayTracer::SetCamera ( Vector3D  lookFrom,
Vector3D  lookAt = Vector3D(0),
Vector3D  viewUp = Vector3D(0, 1, 0),
double  aperture = .1,
double  Fov = 40 
)
virtual

Specify the desired perspective of the output image for the instance. Only necessary if camera object not passed through inline initialization.

Example:

ray_tracer->SetCamera(Vector3D(10, 0, 0));

◆ ShowPerformance()

void RayTracer::ShowPerformance ( )
virtual

Print performance data to console after image finishes rendering.

Example:

ray_tracer->ShowPerformance();

The documentation for this class was generated from the following files: