Project6Fall11
Contents |
Project 6: Bezier Curves
In this project you will create geometry with Bezier curves and patches. This project is due on Friday, November 18th. The assignment will be introduced in the lab by Jorge on Monday, November 7th.
1. Create a TV Tower with Bezier Curves (60 points)
A TV tower is a tall, skinny tower which was erected to send radio, TV, and other wireless signals over a long distance. Many TV towers have been built with observation decks high above ground. Here are a few examples:
You have been tasked by UCSD's administration to design a TV tower for UCSD. It is supposed to be the tallest in the world, have an observation deck (or multiple), and a tall antenna on top.
Use your knowledge about surfaces of revolution and Bezier curves to create a design for the TV tower. You need to texture the surface of the TV tower at least with this [[Media::concrete.ppm | concrete texture]]. Use the following settings for your texture after your first glBindTexture:
// Select GL_MODULATE to mix texture with color for shading: glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Use bilinear filtering: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Wrap texture over at the edges: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
Use at least one directional light source in the world coordinate system, and integrate your trackball rotation function to spin the tower around its origin, which should be at the top of it. Make sure that rotations of the tower do not rotate the light source.
Note:Do not use any of the curve generating OpenGL routines for this assignment (i.e., glMap, glEvalCoord, glMapGrid, glEvalMesh, gluNurbsCurve).
Instructions for Creating a Surface of Revolution with Bezier Curves
Implement a function that generates a surface of revolution using a Bezier curve. You can read up on surfaces of revolution at | Mathworld or at | Wikipedia. The main idea to generate a surface of revolution is to define a 2D curve in the x/y plane, called the generatrix, which is then rotated around the y axis to produce the surface. You should use a piecewise cubic Bezier curve as the generatrix. To produce a mesh of triangles or quads:
- Create a set of control points for the cubic Bezier generatrix that will create the object outline. Depending on how continuous you can make the curve you will get different numbers of points: C0 continuous: 5 points; C1 continuous: 10 points.
- Evaluate a number of sample points along the curve in the x/y plane. (15 points)
- Rotate the points around the y axis at a set of angles, and connect the resulting points to a mesh of triangles or quads (10 points). The mesh needs to be closed (no gaps) (5 points).
- Generate normals and texture coordinates at the mesh vertices. The texture coordinates should cover a range much greater than 0 to 1 so that the texture gets repeated many times. (15 points)
You can compute normals as follows: Given the generatrix curve (x(t),y(t),0) in the x/y plane, you first compute the tangent vector (x'(t),y'(t),0). The corresponding 3D normal vector is then (-y'(t),x'(t),0), which you rotate around the y axis similar to the vertices. Don't forget to normalize the normal vectors. For the texture coordinates u/v, you can use the curve parameter t at each vertex as the u parameter. The v parameter at each vertex is proportional to the rotation angle around the y axis you applied to get the vertex.
Your function to produce the surface of revolution should have the following input and output parameters:
Input:
- Number n of Bezier segments
- Array of Bezier control points in the x/y plane, i.e. (xi, yi, 0). For n cubic segments, you will need (n-1)*3+4 control points.
- Number of points to evaluate along the curve.
- Angle increment for a full 360 degree rotation.
Output:
- Array of vertices
- Array of normal vectors
- Array of texture coordinates
- Index array for triangle/quad vertices
Tip: Try this interactive Java applet which will let you set control points and show the curves they generate. You can even turn on the C1 continuity hint to see where your next control point should go to have C1 continuity (i.e., a smooth connection between two curves).
==2. Add a Flag (40 points)
You decide that your TV tower would look even better if it had a flag attached to its antenna mast, above the top most observation deck. You can use this flag texture, or create your own.
Approach
Create a textured cubic Bezier surface patch for the flag:
- Create a cubic Bezier patch with a square surface area and uniform tessellation to produce a triangle mesh of sufficiently high resolution for the expected curvature. (15 points)
- Compute the normals as the cross product of the partial derivatives at each vertex. (10 points)
- Assign texture coordinates to the mesh vertices using the parameter values and map the texture to the Bezier patch. (10 points)
- Tweak the control points and the position of the light source(s), so that the curvature of the patch is clearly visible. (5 points)
3. Optional: Add Wind (10 points)
Make the flag look like it waves in the wind.
- Add another Bezier patch to the right of the previous one and connect it seamlessly to the first, to allow for more interesting waving patterns. (3 points)
- Use a custom flag texture which is wider than the given UCSD logo to match the larger size of the Bezier patches. (2 points)
- Wave the flag in the wind: Use simple functions (e.g., sin, cos) to move the control points in order to make the flag appear to wave in wind. Use random numbers where appropriate to make the motion less repetitive. Do not move the two interpolating control points at the end where the flag is attached to the antenna mast. (3 points)
- Support the number keys (1-9) to change the wind speed from slow to fast, which should at the least speed up the waving, but could even change your waving function. (2 points)