EXERCISES FOR WEEK 11

week11-1

Select the file /classes/cs3014/files/Textures/birchtree.ppm, or any of the others.  Or, use one of your own.  Write a small program that will draw a rectangle and texture it with birchtree.ppm.


  • First, map the entire image to the entire rectangle. Name the program tex1.cpp.
  • Next, map part of the image to the entire rectangle.   Name the program tex2.cpp
  • Now, change the rectangle to a triangle and map the entire image to it.  Name the program tex3.cpp
  • Finally, map a nearly identical trianglular region of the texture map to the triangle.  Name the program tex4.cpp
Dropbox all four versions of the program, along with the image file you used and any supporting files to subfolder TexMapping of your homework directory.

 

week11-2 Create your own texture by designing your initial(s) in a bitmap image. Apply the image to an object.
week11-3 Apply a texture to a sphere. Use glu quadrics for the sphere instead of glutsphere so that the texturemapping will be more or less automated.

 

week11-4 Refer to the Orientation of the Quadric Sphere page and use this information from the OpenGL Programming Guide:

void gluSphere(GLUquadricObj *qobj, GLdouble radius, GLint slices, GLint stacks);
Draws a sphere of the given radius, centered around the origin. The sphere is subdivided around the z-axis into a number of slices (similar to longitude) and along the z-axis into a number of stacks (latitude).

If texture coordinates are also generated by the quadrics facility, the t-coordinate ranges from 0.0 at z = -radius to 1.0 at z=radius, with t increasing linearly along longitudinal lines. Meanwhile, s ranges from 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75 at the -x axis, and back to 1.0 at the +y axis.

Sketch the sphere and label the points on the sphere that these texels get mapped to:

  1. (s,t) = (0,0)
  2. s=0.25, t = 0.25
  3. s = 0.5, t = 0.5;
  4. s = 0.75, t = 0.75;
  5. (s,t) = (1.0, 1.0)

Assume lower left corner of texel map is (s,t) = (0,0) and upper right corner is (s,t) = (1,1).