Difference between revisions of "Project6Fall12"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
Line 3: Line 3:
 
In this project you will need to create a flag that waves in the wind. The project is due on '''Friday, November 16th'''. The assignment will be introduced in the lab by Sid on Tuesday, November 13th, starting at 3:30pm.
 
In this project you will need to create a flag that waves in the wind. The project is due on '''Friday, November 16th'''. The assignment will be introduced in the lab by Sid on Tuesday, November 13th, starting at 3:30pm.
  
==1. Create a Flag with Bezier Patches ('''70 points''')==
+
==1. Create a Flag with Bezier Patches ('''60 points''')==
  
 
Create a single-colored flag based on two connected (along a horizontal or vertical edge) Bezier patches. You will need to accomplish the following things:
 
Create a single-colored flag based on two connected (along a horizontal or vertical edge) Bezier patches. You will need to accomplish the following things:
  
* Create a set of control points for two seamlessly connected Bezier patches with C1 continuity. [http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-96to97/anson/BezierPatchApplet/ This Java app] might help, but does not display the control points numerically. The control points are not all allowed to lie in one plane: the flag needs to have visible curvature. ('''10 points''')
+
* Create a set of control points for two seamlessly (C1 continuity) connected Bezier patches. [http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-96to97/anson/BezierPatchApplet/ This Java app] might help, but does not display the control points numerically. The control points are not allowed to all lie in one plane: the flag needs to have visible curvature. ('''10 points''')
 
* Use uniform tessellation to produce a uniformly colored (use a bright color of your choice) triangle or quad mesh with at least 100 triangles/quads per patch. ('''20 points''')
 
* Use uniform tessellation to produce a uniformly colored (use a bright color of your choice) triangle or quad mesh with at least 100 triangles/quads per patch. ('''20 points''')
 
* Compute the normals for the vertices of the mesh as the cross product of the partial derivatives at each vertex. ('''10 points''') You only need to compute normals for one side of the flag, the one the camera looks at.
 
* Compute the normals for the vertices of the mesh as the cross product of the partial derivatives at each vertex. ('''10 points''') You only need to compute normals for one side of the flag, the one the camera looks at.
* Place at least one light source that illuminates the flag. Tweak its position so that the curvature of the flag is clearly visible ('''5 points''').
+
* Illuminate the flag: set suitable ambient, diffuse and specular material reflection coefficients for the flag. Place a light source in your scene (in camera coordinates) that illuminates the flag. Tweak material and light source parameters so that the curvature of the flag is clearly visible ('''10 points''').
* Integrate your mouse control functions to spin the flag around its center. Rotations of the flag should not move the light source: the light source needs to remain fixed in camera space. ('''5 points''')
+
* Integrate your mouse control functions to spin the flag around its center. Rotations of the flag should not move the light source: the light source needs to remain fixed in camera space. ('''10 points''')
  
 
'''Notes:'''
 
'''Notes:'''
Line 18: Line 18:
  
  
==2. Add a Texture to the Flag ('''30 Points''')==
+
==2. Add a Texture to the Flag ('''40 Points''')==
  
Add a texture image to the flag, stretching across the entire area of the flag. You will get points for the following things:
+
Add a texture image to the flag, which stretches across its entire area. You will get points for the following things:
  
* [[Media:ucsd-logo.ppm | Download this flag texture for a UCSD logo]], or download or create a different image of your choice.
+
* Set the color of all your mesh polygons to bright white (<tt>glColor3f(1.0, 1.0, 1.0)</tt>), because this color will be multiplied with your texel colors. ('''5 points''')
  
* Compute texture coordinates in a range of 0 to 1 for the vertices of your mesh.
+
* Compute texture coordinates in a range of 0 to 1 for the vertices of your mesh. Note that this range needs to extend across both patches: the bottom left corner of your flag should have texture coordinates (0,0), the top right corner should be (1,1). ('''10 points''')
  
* Set the color of all your mesh polygons to bright white (<tt>glColor3f(1.0, 1.0, 1.0)</tt>), because this color will be multiplied with your texel colors. ('''5 points''')
+
* [[Media:ucsd-logo.ppm | Download this flag texture for a UCSD logo]], or download or create a different image of your choice, and texture-map it to the Bezier patch. ('''20 points''')
  
* Map the texture to the Bezier patch. ('''20 points''')
+
* Add support for the 't' key on the keyboard: hitting it should switch between the texture and the solid colored flag from part 1.
  
 
'''Note:'''
 
'''Note:'''
Use the following settings for your texture after your first <tt>glBindTexture</tt> for correct lighting, filtering, and to enable texture repeat mode:
+
Use the following settings for your texture after your first <tt>glBindTexture</tt> for correct lighting, filtering, and texture repeat mode settings:
  
 
<pre>
 
<pre>

Revision as of 22:23, 8 November 2012

Contents

Project 6: Bezier Curves

In this project you will need to create a flag that waves in the wind. The project is due on Friday, November 16th. The assignment will be introduced in the lab by Sid on Tuesday, November 13th, starting at 3:30pm.

1. Create a Flag with Bezier Patches (60 points)

Create a single-colored flag based on two connected (along a horizontal or vertical edge) Bezier patches. You will need to accomplish the following things:

  • Create a set of control points for two seamlessly (C1 continuity) connected Bezier patches. This Java app might help, but does not display the control points numerically. The control points are not allowed to all lie in one plane: the flag needs to have visible curvature. (10 points)
  • Use uniform tessellation to produce a uniformly colored (use a bright color of your choice) triangle or quad mesh with at least 100 triangles/quads per patch. (20 points)
  • Compute the normals for the vertices of the mesh as the cross product of the partial derivatives at each vertex. (10 points) You only need to compute normals for one side of the flag, the one the camera looks at.
  • Illuminate the flag: set suitable ambient, diffuse and specular material reflection coefficients for the flag. Place a light source in your scene (in camera coordinates) that illuminates the flag. Tweak material and light source parameters so that the curvature of the flag is clearly visible (10 points).
  • Integrate your mouse control functions to spin the flag around its center. Rotations of the flag should not move the light source: the light source needs to remain fixed in camera space. (10 points)

Notes:

  • Ignore what happens when the user rotates the flag to look at the other side of it: due to the normals pointing in the wrong direction, lighting will be wrong, and if back face culling is on, the back side will be invisible.
  • Do not use any of the curve generating OpenGL routines for this part of the assignment (i.e., glMap, glEvalCoord, glMapGrid, glEvalMesh, gluNurbsCurve). These are reserved for extra credit.


2. Add a Texture to the Flag (40 Points)

Add a texture image to the flag, which stretches across its entire area. You will get points for the following things:

  • Set the color of all your mesh polygons to bright white (glColor3f(1.0, 1.0, 1.0)), because this color will be multiplied with your texel colors. (5 points)
  • Compute texture coordinates in a range of 0 to 1 for the vertices of your mesh. Note that this range needs to extend across both patches: the bottom left corner of your flag should have texture coordinates (0,0), the top right corner should be (1,1). (10 points)
  • Add support for the 't' key on the keyboard: hitting it should switch between the texture and the solid colored flag from part 1.

Note: Use the following settings for your texture after your first glBindTexture for correct lighting, filtering, and texture repeat mode settings:

  // Select GL_MODULATE to mix texture with color for shading:
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  // Use bilinear filtering for higher visual quality:
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  // Set the wrap mode (but it doesn't make a difference in this project):
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

3. Extra Credit: Accelerate Rendering with OpenGL's NURBS Functionality (10 points)

Make the flag look like it waves in the wind by doing the following things:

  • Wave the flag in the wind: Use smooth mathematical 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 through 9 to change the wind speed from slow to fast, which should speed up the waving, but could even change your waving function to create an increasingly more dramatic effect with increasing wind speed. (2 points)

Animate the flag

Modify the control points with functions that make the flag look like it waves in the wind.

opengl commands

speedup measurement