Ray Tracer  2020
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Object Class Referenceabstract

Abstract base class for Objects. More...

#include <Object.h>

Inheritance diagram for Object:
Cube Cylinder Plane Sphere Tube

Public Member Functions

virtual std::vector< RayIntersectionintersect (const Ray &ray) const =0
 Object-Ray intersection computation. More...
 

Public Attributes

Transform transform
 A 3D transformation to apply to this Object. More...
 
Material material
 The colour and reflectance properties of the Object. More...
 

Protected Member Functions

 Object ()
 Object default constructor. More...
 
 Object (const Object &object)
 Object copy constructor. More...
 
virtual ~Object ()
 Object destructor. More...
 
Objectoperator= (const Object &object)
 Object assignment operator. More...
 

Detailed Description

Abstract base class for Objects.

An Object is a geometric entity that can be seen in a camera, such as a Sphere. The term 'Object' is commonly used, but creates a bit of tension with the 'object' in 'object-oriented programming'. For this documentation a 'big-O' Object is a thing that can be seen by a camera, and a 'little-o' object is a data structure with members and methods etc. Hopefully this will be clear from context anyway.

Different types of Object are distinguished primarily by their intersect() functions, which determine how a given Ray intersects the surface of the Object. An Object is usually created at the origin with some standard dimensions. They can then me moved, rotated, and resized through their transform member.

As an abstract base class, you cannot create an Object directly. Instead one of its concrete subclasses must be created.

Constructor & Destructor Documentation

◆ Object() [1/2]

Object::Object ( )
protected

Object default constructor.

◆ Object() [2/2]

Object::Object ( const Object object)
protected

Object copy constructor.

Parameters
objectThe Object to copy to this.

◆ ~Object()

Object::~Object ( )
protectedvirtual

Object destructor.

Member Function Documentation

◆ intersect()

virtual std::vector<RayIntersection> Object::intersect ( const Ray ray) const
pure virtual

Object-Ray intersection computation.

Given a Ray in space, this finds the point(s) of intersection with the surface of the Object. Note that there may be 0, 1, or more intersection points, and so a std::vector of RayIntersections is returned.

The details of this depend on the geometry of the particular Object, so this is a pure virtual method.

Parameters
rayThe Ray to intersect with this Object.
Returns
A list (std::vector) of intersections, which may be empty.

Implemented in Tube, Sphere, Plane, Cylinder, and Cube.

◆ operator=()

Object & Object::operator= ( const Object object)
protected

Object assignment operator.

Parameters
objectThe Object to assign to this.
Returns
A reference to this to allow for chaining of assignment.

Member Data Documentation

◆ material

Material Object::material

The colour and reflectance properties of the Object.

◆ transform

Transform Object::transform

A 3D transformation to apply to this Object.


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