A long time ago, in a galaxy far, far away. . . OPENGL WARS Episode V: The Final Project The roommate alliance had been nearly destroyed by the lack of group assignments in CSE 167 when news came of groups being permitted in the final project. Matt and Chris were in the planning phase of their own projects; Matt was making a Mech walking sequence and Chris was making a Towers of Hanoi game. The incessant humming and flickering of the television presented to them a plan to rekindle the bonds of the roommate alliance in the form of a moving starfield. The varying movement of tiny white pixels on a screen eventually evolved into a full-blown flight simulator featuring none other than the ever-so-popular X-Wing fighter spacecraft. The final project, of course, is supposed to take approximately 20 hours per person to complete. The ideas running through the heads of the allied roommates would take far more than 40 hours to complete. A plan had to be made to maximize the features in the project yet still have a finished product to turn in by the due date. The following outline was made to enable Matt and Chris to turn in the project at nearly any point of completion: 1. Model, light, and texture a Space Ship. A Star Wars X-Wing will be used since the model is relatively straightforward yet complex enough to look good. 2. Give controls to the ship so that it can be maneuvered. 3. Create a small universe in which every star has its own solar system. Each solar system will be designed with an object oriented heirarchical approach. The planets of the system will only be rendered when the ship comes within a certain distance. Upon approaching an object, the mesh count will increase to provide more detail when up close to an object. Upon approaching a solar system, the star/sun in the center will begin to give off a diffuse light. 4. Create a distance approximation calculator that approximates a distance calculation without the use of squares and square roots. 5. Create a borderless universe. At the moment, the idea to accomplish this is to have a giant cube in which the universe is contained. Once the ship gets within a certaindistance of an edge of the cube, another cube is created next to the cube for the ship to travel into. 6. Design a simple particle collision system that will enable the ship to crash into planets or projectiles. 7. Create other ships that will randomly fly around the universe. 8. Create a weapons system for teh ship. 9. Make pretty explosions. Of course, by the time the project was due, that list had turned into the following: 1. Spend countless hours designing an immensely complex object oriented design system. The immensely complex code for this system was written to minimize the number of lines of code written for the flight simulator. 2. Model and light an X-Wing space ship. This thousands of lines of code for this time consuming task has the benefits of making texturing more difficult than one of Professor Kubes midterms. 3. Give controls that make it easy to get lost in space. 4. Create a single solar system with a single sun and throw a giant star texturemap around you so it looks like space. 5. Implement LIGHT SPEED! Yes, now your old as dirt Pentium II lab computer can slowly draw polygons at the speed of light. THE FEATURES Implemented by Matthew Jordan: - An X-Wing style spacecraft was designed with home made triangle and quad functions that automatically calculate surface normals. - several texture images were designed to go on the sun, planets, and R2D2. Some textures (such as Earth and Jupiter) were downloaded off the net. Most downloaded textures were heavily modified to make them more visually appealing or to make them wrap onto spheres better. - Solar system design Implemented by Chris Frohoff: - Fully object oriented design approach makes adding and manipulating objects in the universe easy. - Ship can be navigated throughout this universe and the camera can change its viewing distance and angle. - Home made sphere drawing object that automatically implements texturemaps. - Light speed intro sequence - Wire grid overlay option to make navigation more user friendly - helped with texture designs. THE PROBLEMS ENCOUNTERED - Randomly picking hundreds of points to design the X-Wing proved to be a near impossible task. To achieve the correct object shape, an X-Wing was designed using Newtek Lightwave and then she ship was seperated into several surface chunks. Each chunk was roughly sketched on paper and the points were labeled and their values recorded. These chunks were then redrawn on the computer with OpenGl code. - The design of the X-Wing spacecraft proved to be more complex than expected and made it very difficult to implement visual modifications such as surface normals and texturemaps. This was solved by implementing a myQuad() function and a myTriangle() function that automatically calculates surface normals. Because of the lack of strips and fans, the ship now always looks like the shading flat. This works out though since ships aren't supposed to look very smooth. The myQuad() and myTriangle() functions were designed to be able to implement texturemaps in the future, but ship texturemaps proved to be beyond this project since the ship is designed with about 100 triangles and quads not including the cylindrical shapes on the guns and engines. The only texturemapped surface on the ship is R2D2. - The object oriented approach, though carefully planned, still proved to have some inflexibilities which required a bit of a hack to implement some of the features that were not origionally planned for. For example, the starfield is a giant sphere with a texturemap on the inside. To get this sphere to follow the ship, yet not rotate with the ship, a method had to be added to implement this feature. This added method turned out having a small memory leak which will require an even larger hack job to solve. - Ship navigation proved to be somewhat difficult to effectively implement. When the ship would pass the 90 degree incline/perform a loop, the controls would get messed up. This was solved by putting a limit on the turning angles. THE CONTROLS: Navigation UP ARROW - turn up DOWN ARROW - turn down LEFT ARROW - turn left RIGHT ARROW - turn right 'a' - accelerate 'z' - decelerate Camera CTRL + UP ARROW - move camera angle up CTRL + DOWN ARROW - move camera angle down CTRL + LEFT ARROW - move camera angle left CTRL + RIGHT ARROW - move camera angle right CTRL + 'a' - move camera away from ship CTRL + 'z' - move camera towards ship. Move it past the ship for first person viewpoint Miscellaneous 'w' - toggle wireframe mode 'c' - toggle grid overlay 's' - toggle smooth shading 'm' - decrease the mesh count of planets (decrease by 5. Minimum mesh is 5) 'M' - increase the mesh count of planets (increase by 5) ESC - ends the program TOTAL NUMBER OF LINES OF CODE WRITTEN - 5624 not including RgbImage code provided by Professor Buss TOTAL TIME SPENT PER PERSON - At least 40 hours each. Luckily, the human body can go longer than expected without sleep.