Difference between revisions of "Project1Fall12"
(→3. Tessellated Object (optional, 10 points)) |
(→3. Tessellated Object (optional, 10 points)) |
||
Line 79: | Line 79: | ||
Write code to tessellate your own circularly symmetrical object, for example a sphere, cylinder, cone or torus. Your object should use OpenGL to draw a number of triangles or quads to form the shape. You need to compute the vertices and build the quads/triangles. (7 points) | Write code to tessellate your own circularly symmetrical object, for example a sphere, cylinder, cone or torus. Your object should use OpenGL to draw a number of triangles or quads to form the shape. You need to compute the vertices and build the quads/triangles. (7 points) | ||
− | Your algorithm needs to have at least one parameter to control the tessellation level (ie, the number of quads/triangles used for the object), and you need to be able to change this parameter during the homework presentation (2 points) | + | Your algorithm needs to have at least one parameter to control the tessellation level (ie, the number of quads/triangles used for the object), and you need to be able to change this parameter during the homework presentation. (2 points) |
− | Your quads/triangles need to be either shaded, or have different colors so that they can be distinguished (1 point) | + | Your quads/triangles need to be either shaded, or have different colors so that they can be distinguished. (1 point) |
In this exercise you are not allowed to use OpenGL or GLUT utility functions, such as gluSphere. | In this exercise you are not allowed to use OpenGL or GLUT utility functions, such as gluSphere. |
Revision as of 06:01, 28 September 2012
Contents |
Project 1: Vectors, Matrices, and Coordinate Transformations
Your project should build on the provided base code. Before you start with this project, you will need to look through the base code and get familiar with it.
This project has three parts, but only the first two are mandatory to get full credit (100 points). The number of points you can get for each part is indicated below. In the first part you will create classes for vectors and matrices. You will use this functionality in the remaining projects throughout the quarter. In the second part of this project you will construct an animated object that consists of several parts that move with respect to each other.
The third part is optional. We make suggestions for how to extend your solution with some additional features. You will get extra credit for completing those.
Note that in this project you are not allowed to use OpenGL or GLUT matrix routines, such as glRotate, glTranslate, or glScale, because we want you to use your own matrix routines.
This project is due on Friday, October 5th. You will need to present your project in the lab starting at 1:30pm that day, or during one of the TA/tutors' office hours before that day. For this project you are allowed to work in teams of two. In this case both team members need to be present during the homework presentation.
The TA, Sid Vijay, is going to introduce this homework assignment in lab 260 on Monday, October 1st at 2:30pm in lab 260.
1. Vectors and Matrices
Implement a basic matrix and vector library by extending the classes in the base code. You can use the C++ class shown below as a basis. Create separate classes for a Vector3 and a Vector4 type, with three or four components, respectively. The Vector4 type describes points. The matrix class should be for 4x4 matrices.
1a. Vectors (Two points for each method for a total of 30 points)
Implement the following methods in your Vector3 class:
- A constructor with three parameters being the components of the vector
- Element access 'set': set the components of the vector
- Element access 'get': return a specific element of the vector
- Overload operator '[]' for 'get' access
- Vector addition
- Overload operator '+' for addition
- Vector subtraction
- Overload operator '-' for subtraction
- Negation
- Scale (multiplication with scalar value)
- Dot product
- Cross product
- Magnitude (length of vector)
- Normalize
- Print (display the vector's components numerically on the screen)
Implement the following methods in your Vector4 class:
- A constructor with three parameters being the components of the point
- Element access 'set': set the (four) components of the point
- Element access 'get': return one of the four components of the point
- Overload operator '[]' for 'get' access
- Vector addition
- Overload operator '+' for addition
- Vector subtraction
- Overload operator '-' for subtraction
- Dehomogenize (make fourth component equal to 1)
- Print (display the point's components numerically on the screen)
1b. Matrices (Two points for each method for a total of 20 points)
Implement the following methods in your Matrix4 class:
- Constructor with 16 parameters to set the values of the matrix
- Multiply (matrix-times-matrix)
- Multiply (matrix-times-vector): if multiplying with a point, dehomogenize the result after the multiplication
- Make rotation matrix about x axis
- Make rotation matrix about y axis
- Make rotation matrix about z axis
- Make rotation matrix about arbitrary (unit) axis
- Make non-uniform scaling matrix
- Make translation matrix
- Print (display all 16 matrix components numerically on the screen in a 4x4 array)
2. Animated Scene (50 points)
Construct an animated 3D scene with at least three separately moving objects. You can use simple rectangular boxes and transform them appropriately, or you can use OpenGL and GLUT geometry creation functions, such as gluSphere, glutSolidCone, glutSolidTorus, glutSolidSphere, or glutWireSphere. The motion of the three objects needs to depend on one another. For example:
- A car with spinning "wheels" (made of boxes), moving in a circle on a ground plane.
- A helicopter with spinning rotor blades, flying in a circle.
- An industrial robot moving its arm which holds a rotating saw blade.
- A moon rotating about a planet, which rotates about its sun.
You will get full credit if you have a moving object (15 points), and another one whose motion depends on it (rotating rotor blades, wheels, etc.) (25 points). To make the shapes look more interesting and distinguishable, use different colors for them (10 points).
3. Tessellated Object (optional, 10 points)
Write code to tessellate your own circularly symmetrical object, for example a sphere, cylinder, cone or torus. Your object should use OpenGL to draw a number of triangles or quads to form the shape. You need to compute the vertices and build the quads/triangles. (7 points)
Your algorithm needs to have at least one parameter to control the tessellation level (ie, the number of quads/triangles used for the object), and you need to be able to change this parameter during the homework presentation. (2 points)
Your quads/triangles need to be either shaded, or have different colors so that they can be distinguished. (1 point)
In this exercise you are not allowed to use OpenGL or GLUT utility functions, such as gluSphere.
Helpful link: