Assignment 2: Scaling, Rotation, Translation and Textures

GOAL

In this assignment you will practice texture mapping on 3D objects, and scaling, rotation and translation

Oct 24, 2013 11:55 pm


Basic grading:

The components of this assignment will be graded as follows:
  • 10% Properly turned in assignment
  • 30% Using OpenGL, render the complete triangles described in the obj file, in white
  • 40% Using OpenGL, render the complete triangles described in the obj file and apply the texture using an image selected by user
  • 20% Using keyboard and cursor keys (arrow keys) scale, rotate and translate the rendered object
  • Participation credit: You can receive participation credit (outside of this assignment) for posting your release, good or bad, on the class forum!

General notes (Read carefully):

The assignment asks you to do lot of small things, each of which will not take much time. However start early. We anticipate you to take most time in figuring out how to map a texel to a pixel, but once you understand that, rest should be fairly simple.
As before, we will test your program with the test cube, as well as several other obj files, some of which you can find here, others which you cannot. You can re-use the shell code for rendering obj using OpenGL for this assignment. For texturing we are providing additional sample code (see below).
This time you are free to choose your window size, position of eye, type of projection (perspective or orthographic), and light position and color.
In order to use an image as texture, you should read an image file (preferably a bitmap), store individual pixel information in a byte array and pass it to OpenGL. We are providing you a sample code which reads a 24-bit bitmap file and applies it to a randomly rotating cube. You may use this code to understand how texturing works and may also use this to get started with texturing (and rotation) for your assignment.

Part 0: Properly turned in assignment

Submit the following files:
  • texture.exe, a Windows 7 executable of your finished assignment
  • the image files you used
  • all associated source code files (these can be called anything you want)
  • a readme.txt file if there is any configurable behavior
  • if you wish to claim any extra credit, list those claims in the readme file, along with any needed details
Please DO NOT submit any supplemental development files, in particular Developer Studio solution or project files. The size of these files will quickly exceed the available space in the submit locker.
There is an important requirement that your assignment must satisfy.
  • Your program must be compiled to run on a Windows 7 PC equipped with OpenGL, GLUT, and the standard Visual Studio runtime libraries. If we cannot run your program, we will not be able to mark it.

Part 1: Using OpenGL render complete triangles

Use OpenGL to render triangles, not just vertices. You can not ignore normals, and need to worry about depth. Turn on depth buffering, local Blinn-Phong lighting, Gouraud shading. You should see the model with some sort of lighting and shading, with every triangle fragment having a slightly different color. You should also see occlusion.

Part 2: Using OpenGL, render lit triangles and apply custom texture. Ignore the texture information in the obj file. Instead use the image you read as the texture.

Use space bar to switch between part1 and part 2 of the assignment.
You should use the OpenGL mouse menu (right-click) to show users a list of different image files from which he can choose any one to be applied as a texture to the obj. Picking a different image removes the first texture and applies the new one. You should also have a light source as described in the general notes for this part of the assignment.

Part 3: Scaling, Rotation and Translation

You must handle keyboard events in both part 1 and part 2 to perform the following operations:
  1. Use "z" to zoom-in/scale-up the object
  2. Use "x" to zoom-out/scale-down the object
  3. Use "up-arrow" to move the object in +Y
  4. Use "down-arrow" to move the object in -Y
  5. Use "right-arrow" to move the object in +X
  6. Use "left-arrow" to move the object in -X
  7. Use "[" to move the object in +Z
  8. Use "]" to move the object in -Z
  9. Use "q" to rotate the view in clockwise direction
  10. Use "w" to rotate the view in anti-clockwise direction

Participation credit:

Please remember that you can get participation credit outside this assignment for posting your imagery, good or bad, on the course Google+ community.

Extra credit grading:

Extra credit opportunities include the following, with others possible with instructor approval:
  • 5% support arbitrarily sized images (and interface windows)
  • 5% support arbitrary viewing setups
  • 5% support multiple lights at arbitrary locations
  • up to 15% support multiple image formats

Extra credit: Arbitrarily sized images and interface windows

Read in an additional window.txt file that one line, lists the width and height of the interface window. Size your interface window to match. This should effect every part of your assignment.

Extra credit: Support arbitrary viewing setups

Read in an additional view.txt file that lists the eye's location, the view up, and the look at vectors, each on a different line. Render the scene with these viewing parameters. Note that with bad viewing parameters, you will not see the model. This should affect every part of your assignment.

Extra credit: Multiple and arbitrarily located lights

Read in an additional lights.txt file that on each line, describes the location and color of a light (use one triple for a light's color, with its ambient, diffuse and specular colors the same). Render the scene with these lights. In ray casting, you will have to sum the colors all the lights. This should affect every part of your assignment.

Exra credit: Multiple image formats

We have provided you a sample code which uses 24-bit bmp files as textures. You are free to use this code, or write your own. To claim this extra credit, you must implement support for an additional format apart from 24-bit bmp. The extra credit for this will be calculated as follows:
  1. 5%: one or more of 8-bit, 16-bit or 32-bit bmp
  2. 10%: one or more of JPEG, PNG or TIFF
  3. 15%: a combination of the above two