LibTrace

Programming - The Scene class

The scene class holds all the informatio required to draw a single image. The functions are:
Scene::Scene(List* objects, List* lights)

void Scene::set_objects(List* objects)
void Scene::set_lights(List* lights)
void Scene::set_anti_aliasing(bool all)
void Scene::set_resolution(int x, int y)
void Scene::set_xres(int x)
void Scene::set_yres(int y)
void Scene::render(void)
void Scene::save_to_file(char *filename)
void Scene::set_position(Vector cp)
void Scene::set_direction(Vector dir)
void Scene::set_up(Vector u)
void Scene::set_aspect(double asp)
void Scene::set_bg_color(rgb bg_col)
void Scene::set_ray_threshold(double rt)
void Scene::set_brightness(double b)
void Scene::set_gamma(double g)

Vector Scene::get_position(void)
List* Scene::get_objects(void)
List* Scene::get_lights(void)
bool Scene::get_anti_aliasing(void)
int Scene::get_xres(void)
int Scene::get_yres(void)
PPM* Scene::get_image(void)

void destroy_scene(Scene *s)



Scene::Scene(List* objects, List* lights)
This function is used to set the list of objects and list of lights that the scene should use when the "render()" function is called. Overwrites any pre-existing objects and lights.
void Scene::set_objects(List* objects)
This function is used to set the list of objects that the scene should use when the "render()" function is called. Overwrites any pre-existing objects.
void Scene::set_lights(List* lights)
This function is used to set the list of lights that the scene should use when the "render()" function is called. Overwrites and pre-existing lights.
void Scene::set_anti_aliasing(bool all)
This function turns anti-aliasing on or off.
void Scene::set_resolution(int x, int y)
This function sets the image resolution of the final "render()".
void Scene::set_xres(int x)
This function sets the image width of the final "render()".
void Scene::set_yres(int y)
This function sets the image height of the final "render()".
void Scene::render(void)
This function uses the lights and objects specified by "Scene()", "set_objects()" and "set_lights()" to render the image. A status is reported to "cout".
void Scene::save_to_file(char *filename)
This function will save the image produced by "render()" to the file specified by *filename.
void Scene::set_position(Vector cp)
This function sets the position of the camera.
void Scene::set_direction(Vector dir)
This function sets the direction that the camera will be pointing.
void Scene::set_up(Vector u)
This functions sets which way is up for the camera. The length of this vector and the length of the one given for "set_direction()" matter. The point dir+up is the point in the center top of the camera's vision. So by adjusting the lengths of dir and up you can set the FOV of the camera.
void Scene::set_aspect(double asp)
This function sets the aspect ratio of the camera. This is simply how many times wider the view is than it is high. To avoid distortion in the image then ensure that the resolution has the same aspect ratio. Note that the FOV will be affected by this setting since the "set_up()" function sets the up vector and not the along.
void Scene::set_bg_color(rgb bg_col)
This function sets the background color for the image.
void Scene::set_ray_threshold(double rt)
When the raytracer is rendering multiple reflections and things it needs to know how far to recurse before it just cuts off the ray. It keeps a track of the significance of the ray by tracking how much this ray would effect the final pixel and when this significance value drops below the value set by this function, the raytracer cuts it off.
void Scene::set_brightness(double b)
This simply sets the brightness of the final image. The color value of each pixel is multiplied by this before gamma correction is applied.
void Scene::set_gamma(double g)
This sets the gamma correction value for the image. This is applied after the brightness.
Vector Scene::get_position(void)
This simply returns the value set by "set_position()".
List* Scene::get_objects(void)
This returns the value set by "set_objects()".
List* Scene::get_lights(void)
This returns the value set by "set_lights()".
bool Scene::get_anti_aliasing(void)
This returns the value set by "set_anti_aliasing()".
int Scene::get_xres(void)
This returns the value set by "set_xres()".
int Scene::get_yres(void)
This returns the value set by "set_yres()".
PPM* Scene::get_image(void)
This returns a pointer to the image that has been rendered.
void destroy_scene(Scene *s)
This will remove the scene, objects and lights from memory. Usefull for clearing up a whole scene. Note that this function doesn't delete textures or any objects within modifier classes.