CS 4810: Introduction to Computer Graphics
|
As an alternative for assignment 3, you can implement a final project which uses OpenGL for a task of your choosing (note the different due date of the final project).
This assignment serves as an introduction to the OpenGL graphics library. You will be required to generate a room scene which can be navigated in a walk-through fashion. You will begin the project by implementing the OpenGL analogs of many of the methods that you have implemented for the last ray-tracer assignment. Emphasis is placed both upon the implemention of OpenGL's basic capabilities (e.g. shading. lighting, transparency, materials properties, etc.) and their use in generating more involved effects (e.g. shadows, reflections.)
For this assignment you will continue with the code base from the previous assignment, implementing the OpenGL related methods. There are some small modifications that you will need to make to your code described in the Code Modifications section below. It is highly recommended that you make a copy of your old code before you start working on the new methods (use git!).
An overview of the code you will be using can be found here.
An overview of the
.ray
file syntax can be found here.A (Win32) compiled version of the renderer implementing some of the basic features can be found here. (If the previous executable does not work, try this one.)
The OpenGL programming Guide is an invaluable resource in assisting with OpenGL implementation. You can find a link to the guide here and here.
main.cpp
file.
Ray/rayWindow.h
file has been modified by adding the keyword public
at the beginning of the class definition. (Without this modification, the necessary code will not compile.)
The program takes in as a mandatory arguments the input (.ray
) .ray file name. Additionally, you can also pass in the dimensions of the viewing window and the complexity of the tesselation for objects like the sphere, the cylinder, and the cone. It is invoked from the command line with:Feel free to add new arguments to deal with the new functionalities you are implementing. Just make sure they are documented.% Assignment3 --in in.ray --width w --height h --cplx c
The assignment is worth 30 points. The following is a list of features that you may implement. The number in parentheses corresponds to how many points it is worth.
The assignment will be graded out of 30 points. In addition to implementing these features, there are several other ways to get more points:
- (1) Implement the RayCamera::drawOpenGL (in
Ray/rayCamera.todo.cpp
) to draw the camera.- (1) Implement the RayGroup::drawOpenGL (in
Ray/rayGroup.todo.cpp
) to draw the scene-graph nodes. For now ignore the local transformation information and simply draw all the RayShapes associated to the RayGroup.- (1) Implement the RaySphere::drawOpenGL (in
Ray/raySphere.todo.cpp
) method to draw a sphere at the appropriate tesselation. For now, you can ignore the inputmaterialIndex
parameter and have the method return -1. (You may want to consider using thegluSphere
function from the GLU library to assist you with this.)- (2) Implement the RayTriangle::drawOpenGL (in
Ray/rayTriangle.todo.cpp
) method to draw a triangle with per-vertex normals. For now, ignore the texture coordinates and the inputmaterialIndex
parameter, and have the method return -1.- (2) Impelement the RayMaterial::drawOpenGL (in
Ray/rayScene.todo.cpp
) method to draw the material properties.- (3) To draw the light sources, implement:
The input
- RayDirectionalLight::drawOpenGL (in
Ray/rayDirectionalLight.todo.cpp
);- RayPointLight::drawOpenGL (in
Ray/rayPointLight.todo.cpp
); and- RaySpotLight::drawOpenGL (in
Ray/raySpotLight.todo.cpp
)index
parameter specifies which of the OpenGL lights you are using and should be used for specifying the light parameters in theRayLight::drawOpenGL
method:glLightfv(GL_LIGHT0+index, ...);
glEnable(GL_LIGHT0+index);- (2) Modify the implementation of RayGroup::drawOpenGL (in
Ray/rayGroup.todo.cpp
) to take into account the local transformation returned by the call: RayGroup::getMatrix. You can do this by pushing the appropriate matrix onto the stack prior to rendering and then popping it off after you are done.- (2) Accelerate OpenGL rendering by using call-lists. To do this you will have to:
- Implement RayGroup::getOpenGLCallList (in
Ray/rayGroup.todo.cpp
) to generate a single call list for all of the children of the RayGroup.- Modify the implementation of RayGroup::drawOpenGL (in
Ray/rayGroup.todo.cpp
) so that if the value ofopenGLCallListID
is zero, you simply draw the shapes as you had previously. Otherwise, invoke the OpenGL command to draw the call-list using the call-list ID. (Note that the initialization will take care of actually calling RayGroup::getOpenGLCallList so you don't have to.)- (3) Implement triangle texture mapping. To do this you will have to:
- Modify the implementation of RayTriangle::drawOpenGL (in
Ray/rayTriangle.todo.cpp
) to specify the texture coordinates prior to specifying the vertex positions.- Modify the implementation of RayMaterial::drawOpenGL (in
Ray/RayScene.todo.cpp
) method to enable and bind the texture if it is present.- Modify the implementation of RayTexture::setUpOpenGL (in
Ray/RayScene.todo.cpp
) method to generate the texture handle.- (1) Implement the RayBox::drawOpenGL (in
Ray/rayBox.todo.cpp
) method to draw a box.- (1) Implement the RayCylinder::drawOpenGL (in
Ray/rayCylinder.todo.cpp
) method to draw a cylinder with bottom and top caps at the appropriate tesselation. (You may want to consider using thegluCylinder
andgluDisk
functions from the GLU library to assist you with this.)- (1) Implement the RayCone::drawOpenGL (in
Ray/rayCone.todo.cpp
) method to draw a cone capped off at the bottom at the appropriate tesselation. (You may want to consider using thegluCylinder
andgluDisk
functions from the GLU library to assist you with this.)- (2) Implement mouse control to facilitate moving about the interior of the scene. As a minimum, you should implement a crystal-ball system in which dragging the left mouse button rotates the viewer around the model, rotating either about the up-direction or the right-direction. To do this you will have to modify:
- RayCamera::rotateUp (in
Ray/rayCamera.todo.cpp
) to implement a rotation ofangle
degrees, around the up-axis, about the pointcenter
.- RayCamera::rotateRight (in
Ray/rayCamera.todo.cpp
) to implement a rotation ofangle
degrees, around the right-axis, about the pointcenter
.- (2) Implement full scene anti-aliasing using the accumulation buffer. Hint: See the OpenGL Programming Guide for information about jittering.
- Generate a
.ray
file describing a room scene with:
- (1) Four walls, a floor and ceiling.
- (3) A table, several chairs, etc. You may choose more interesting furnishings.
- (1) At least one transparent surface, perhaps the table top.
- (1) At least three texture mapped surfaces, each with a different texture.
- (1) At least three point or spot light sources.
- (2) A Luxo Jr. style lamp with keyboard and/or mouse controls for manipulating the joints of the lamp interactively while the spot light representing the bulb moves accordingly. Hint: see the robotic arm example in the OpenGL Programming Guide.
- (2) A mirror. Hint: Reflect the world about the mirror and render it again through a stencil buffer.
- (2) Shadows on at least one surface (such as the floor or table). Hint: See the OpenGL Programming Guide for the transformation which renders objects onto a plane.
- (2) An object that responds to user mouse clicks (such as a light switch which turns on/off a light when clicked on by the user).
- (1) In general, making a call to OpenGL's
glMaterial*
commands can be somewhat expensive. Rather than calling these functions before you draw everyRayShape
, modify the RayShape::drawOpenGL of the different subclasses so that:
- You first test if the if the index of the material associated to the primitive is the same as the input
materialIndex
paramter and only call theRayMaterial::drawOpenGL
method if they differ.- Return the index of the last material used.
- (2) Modify the OpenGL renderer to allow the user to ray-trace the scene from the same perspective as the
RayCamera
.- (?) Impress us with something we hadn't considered...
- (1) Submitting one or more images for the art contests.
- (1) Submitting one or more .ray files for the art contests.
- (2) winning the regular art contest,
- (2) winning the .ray file art contest,
It is possible to get more than 30 points. However, after 30 points, each point is divided by 2, and after 32 points, each point is divided by 4. If your raw score is 29, your final score will be 29. If the raw score is 33, you'll get 31.25. For a raw score of 36, you'll get 32.