Ray Tracing, Version 3.0
Day #5

Goal: Ray trace a scene where

  • the only objects in the scene are generic spheres
  • the spheres may have been translated, scaled, and/or rotated with respect to an axis
  • in addition to color, the attributes of each object may include material coefficients for diffuse, specular, ambient color
  • a positional light may be placed in the scene
  • the light has a diffuse, specular, and ambient component
  • a value for global ambient light may be assigned
  • descriptions of the objects, lights, and camera are read in from a file, using SDL

Ray Tracing Tools:

Add the following methods to class GLdoublePoint and thoroughly test each:

GLdoublePoint set(Ray3D r, double t);
      which returns the point given by ray r at time t.

GLdoubleVector operator - (GLdoublePoint secondPoint) ;
      which returns the vector going from this point to second point.

 

Add to class GLdoubleVector and thoroughly test :

GLdoubleVector multiplyByMatrixTranspose( Matrix_4x4 M);
      which returns the product of the transpose of M postmultiplied by this vector

GLdoubleVector operator + (GLdoubleVector other);
      which returns the sum of this vector and other vector

 

Add to class Object:

//data
bool isMaterial;
which is false if only using emissive color, true otherwise.

and change the constructor to initialize isMaterial to true.

Add these new classes and thoroughly test:

class Light
{

  public:

//methods:
Constructor, which initializes values

//data:
Color3 ambient, diffuse, specular;
GLdoublePoint pos; //position of light

}

class Material
{

  public:

//methods:
Constructor, which initializes values
void set(Material source);

//data:
Color3 ambient, diffuse, specular, emissive;
float specularExponent;

}

Test Files:

These test files are available, which show the red and blue spheres, now lighted, from various positions:

lookingfront.scn
lookingback.scn
lookingright.scn
lookingdown.scn

All files are located in /classes/cs3114/Advanced_Graphics/files directory