//////////////////////////////////////////////////////////////////////////////// Final Project - CSE 167 - Fall 2004 Justin K Kleffman 11/30/04 README.TXT //////////////////////////////////////////////////////////////////////////////// "Realistic modelling and texturing in openGL, incorporating 3D Studio Max" --------------------------------------------------------------------------------- Goals and Ideas: In brainstorming my final project I came to realize there is one thing many previous projects are lacking, and that's realism. Not to say that previous projects are no good, some of them are quite amazing. So my first thought was that I must somehow be able to use 3D Studio Max (3DS) in my project. When I came to realize you can export to an object file and possibly translate this into general openGL code I was set. Thus my original goal was simply to get good looking models into my scene, realistic texture mapping came later. What follows is a description of the capabilities of this project. Description: I've gone through many tutorials in 3DS and the P38 Lighting World War II jet is a nice low polygon model that I figured would be great to make a scene out of. To start here is the general flow in my project: 1) Model something nice in 3DS 2) Export to .obj file 3) Using my Object file loader, read in all information. 4) Slight modifications to viewing may be required, and you'll soon be seeing your model displayed nicely on the screen, openGL style. So as you can see my program reads in all the model information and displays it. It's that simple. No more sitting for hours trying to figure out normals and texture coordinates when you can just have them automatically output to a file for you (I guarantee no video game designer figures them out by hand). Next this brings me to my texture mapping. At first I implemented the phong lighting that the class has already beaten to death, and my scene was nice, but less than impressive. So in researching it I came to realize that a video game would not try to make everything it's own object in order to texture it, but instead use texture "sheets" with uvw coordinates that map into it and apply the correct texture to the correct place in your scene. Think about a building with windows and doors, etc. It's quite possibly a rectangular box with fancy texture mapping. Lastly, in order to make a more presentable scene, and to show that I learned openGL too, and not only 3DS, I made a reflective mirror floor and animated propellers that spin for your entertainment. ---------------------------------------------------------------------------------- Implementation: Background information on Object File Format: (by line type) v f f f - vertex line, 3 floats (f) specify x, y, and z. vn f f f - normal, 3 floats specify x, y, z, for the normal. vt f f f - texture, 3 floats specify the u, v, w coords for texturing. f f/f/f f/f/f f/f/f - a face, f/f/f indexes into vertex/texture/normal. So for example, an object file for a simple cube, with no normals or texture: v 1 1 1 v 1 1 -1 v 1 -1 1 v 1 -1 -1 v -1 1 1 v -1 1 -1 v -1 -1 1 v -1 -1 -1 f 1 3 4 2 f 5 7 8 6 f 1 5 6 2 f 3 7 8 4 f 1 5 7 3 f 2 6 8 4 This is specifying faces as polygons rather than triangles, so reading it off the first face you would make in openGL is using vertex 1, 3, 4, and 2. Texture and normal information is done the same way. This lends to a very simple pattern to understand and can be read in and stored in the structures of your creation. When outputting openGL it just goes triangle by triangle (faces) and uses the correct glNormal3f, glTexCoord3f, and glVertex3f. For the texture design 3DS allows you to alter the UVW mapping to whatever best suits your model and then output a "flattened" image which is essentially a "puzzle" of your model. If you were to cut your model up into pieces and lay them out flat this is your image. This can be exported to a giant bitmap and colored in with fancy textures in photoshop. This is one aspect I wish I had more ability with. Now with a colored in texture map for the entire plane and the uvw coordinates mapping into it perfectly it's just a matter of using the bitmap loading routines supplied to us. Lastly, I need to explain the reflection, the final technical aspect. It's actually less of a reflection and more of a camera "trick." It simply makes a transparent floor and then redraws the entire object below it upside down. Now to make it not look terrible when you move the camera below the floor the stencil buffer is used to not draw the plane below when you're looking down there, only drawing it when the viewer is above. --------------------------------------------------------------------------------------- Controls: (lights) '1' - Toggle white light '2' - Toggle red light '3' - Toggle green light 'h' - toggle positional vs. directional lights right-mouse-button -> Menu to toggle any or all lights. (eye candy) 'a' - toggle animation (spinning props) 'w' - toggle wireframe to see your model 'f' - toggle reflective floor 'c' - toggle backface culling 'M' - faster spinning propellers 'm' - slow down propellers 's' - flat/smooth shading (viewing direction) 'z' - Zoom in 'Z' - Zoom out 'o' - Counter-clockwise rotation 'O' - Clockwise rotation arrow-right - less rotate angle arrow-left - more rotate angle arrow-up - increase azimuth arrow-down - decrease azimuth -------------------------------------------------------------------------------------- Final Comments: The 'Create your own project' idea is genious. I'm happy with my project but I have a feeling there are going to be some other ones that completely blow it out of the water. A project of this type opens the doors to so much creativity and artistic achievement, it's a great break from the monotony that we've grown so used to and almost enjoy. Emphasis on almost.