Project2S16

From Immersive Visualization Lab Wiki
Revision as of 19:27, 9 April 2016 by Hvt001 (Talk | contribs)

Jump to: navigation, search

Project 2: 3D Models

From this point on we're no longer using the rasterizer code. In all future homework projects we're going to use OpenGL for all our rendering.

In this homework assignment you're going to learn how to:

  • load polygonal OBJ files
  • render polygons in modern OpenGL
  • automatically center and scale 3D models
  • set up the virtual camera
  • control the camera with the mouse
  • set up light sources
  • set material properties

1. 3D Model Loader

You already know how to load point clouds. It turns out that the 3D model files from project 1 (Bunny, Bear, Dragon) contain surface descriptions as well, by means of triangle connectivity.

Besides vertices and vertex normals you are going to have to parse the files for connectivity. It is defined with the letter 'f' for face. Each line starting with the letter 'f' lists three sets of indices to vertices and normals, which define the three corners of a triangle. The numbers are indices into the vertex and vertex normal lists. Example:
f 31514//31514 31465//31465 31464//31464

Modify your OBJ loader so that it also parses the face lines, then modify your code to display triangles instead of vertices for the OBJ objects.

2. Rendering using modern OpenGL

The starter code has been modified so that the Cube now gets rendered with modern OpenGL, through the use of a VAO (Vertex Array Object), VBOs (Vertex Buffer Object), and EBOs (element buffer object). In order to make the use of the programmable pipeline possible, a shader class was added to the starter code, along with a sample vertex and fragment shader. At the moment, the sample fragment shader causes all objects to be colored light orange. You will be fixing this later when you begin working with lights. Using Cube's example of the modern OpenGL approach, add the ability to render your OpenGL using modern OpenGL. Since you are no longer using the Rasterizer, use the 't' key to toggle between immediate mode (the OpenGL mode from project 1) and modern OpenGL. There should be a noticeable application speedup when using modern OpenGL.

[to be continued]