Where We Are So Far (Version 2.1)
Ray Tracing Tools:
Classes:
- Point
- Vector - add method:
Vector cross(Vector other)- returns the cross product of this vector with other vectorVector operator - (Vector other)- returns the result of other vector from this vector- Color3
- Ray
- Matrix_4x4
SphereInfono longer needed
- Primitive - keeps info about each generic primitive in our scene. This info includes:
string prim_type- the type of generic primitive (sphere, cube, plane, square, tapered_cylinder)Color3 color- the RGB color of the primitive (emissive color, no lighting)Matrix_4x4 M- the current inverse transformation matrix for the primitiveand these methods:
- default constructor - initializes current transformation matrix to the identity matrix
Ray inverseTransform(Ray ray)- returns the "inverse transformation" of the ray.void translate(GLdouble trans_x, GLdouble trans_y, GLdouble trans_z)- changes M, to indicate the object has been translatedvoid scale(GLdouble scale_x, GLdouble scale_y, GLdouble scale_z)- changes M, to indicate the object has been scaledvoid rotate(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)- changes M, to indicate the object has been rotated counterclockwise angle degrees, about the axis <x,y,z>
- Sphere - this class has do data! It only has one method, a method to find the hit time(s) of the current ray with the generic sphere. If the ray hit the sphere, this is recorded in a HitInfo object, which is then added toIntersection. If there were 2 hits, then both hits are added.
- Plane - this class has do data! It only has one method, a method to find the hit time of the current ray with the generic plane. If the ray hit the plane, this is recorded in a HitInfo object, which is then added toIntersection. For example:
bool hit(int which_one, Ray it_ray, Intersection &inter)- which_one is the index of the primitive, it_ray is the inversed transformed ray to be tested. If object was hit inter now contains the record of the intersection and true was returned; otherwise false returned.
- Square - this class has do data! It only has one method, a method to find the hit time of the current ray with the generic square. If the ray hit the square, this is recorded in a HitInfo object, which is then added toIntersection.
- HitInfo - keeps info about a hit by the current ray. Each hit is recorded for later comparison to determine a winner. This means that if the ray hit the primitive more than once, each is recorded. If the ray hit more than one primitive, each is recorded. This info includes
GLdouble hit_timeint which_obj- index of the primitive on the list of primitivesPoint generic_hit_point- the hit point on the generic primitiveIts only method is a default constructor, used to initialize values.
- Intersection - basically, this is the collection of all the hits made by the current ray. It includes
GLdouble num_hits- how many hits produced by this rayvector<HitInfo> hit- all the information about all the hits produced by this ray, in array form.In addition to the default constructor, used to initialize values, it has his method:
void set(Intersection source)- sets its data (num_hits and hit) to the values in source's data fieldsNote: to speed up the process of finding the "best" hit, you might want to include a data field for the "best" time, as well as an index to the hit that has the best time. Then you can update as hits are added, rather than searching through after all the hits have been recorded.
Scene Tools:
Classes:
- Scene - which has the following data:
- Ray ray - the current ray
- Intersection best -
- methods:
- default constructor - initializes window size, number of columns and rows, aspect ratio of the scene
void readScene- reads in information about
- the camera, and uses this to assign values to variables
- primitives
- type
- color
- translate?
- scale?
- rotate?
as each primitive is read in, values are assigned to something of type Primitive. Translate, scale, and rotate cause the object to call appropriate methods associated with Primitive. At the conclusion of the the primitive's info (#), the object is added to the list of primitives.
void shadePixel(GLint x, GLint y, Color3 pixelColor)- shades pixel at (x,y) with pixelColor
voidrayTracer()for each pixel in the window
determine direction of the current ray
for each primitive in the scene
calculate hit time(s) with the current ray and record info
get the best hit
determine the "color"
shade the pixel with this colorvoid getFirstHit()
Color3 shader()
void setup()- assign values for camera and scene that do not change.