EIGA501 Introduction To 3D Graphics – Coursework One
EIGA501 Introduction to 3D Graphics – Coursework One version 1
Build a simple 2D game with some 3D effects in OpenGL using the GLUT toolkit. The game is loosely based on the classic 80s game ‘Asteroids’. A mock-up of the game screen includes a spacecraft in the center, with asteroids appearing at the start and the spacecraft able to turn and fire missiles. The asteroids rotate slowly on their axes, and if a missile hits an asteroid, the asteroid disappears, and the score increases by 10 points. When all asteroids are destroyed, a new set is randomly generated, avoiding the player's ship position. The game continues indefinitely, with an optional pause or stop feature. The background features a drifting star field, with stars appearing as old ones disappear, which can be static for lower marks. Shapes are built from primitives, with the option to use pre-made designs or create custom ones. The star field uses points, with customizable size, and colored primitives give textures to shapes, to be enhanced with lighting in coursework 2.
Paper For Above instruction
Introduction
This paper discusses the development of a simple 2D game with 3D elements in OpenGL, resembling the classic ‘Asteroids’ game. The aim is to demonstrate proficiency in OpenGL and GLUT for creating basic graphical objects, transformations, collision detection, and user interaction. The project emphasizes understanding primitives, transformations, and real-time graphics rendering, providing a foundation for further 3D development in subsequent coursework.
Game Concept and Design
The game features a central spacecraft controlled via keyboard inputs. The user can rotate the ship left or right using arrow keys, and fire missiles towards the asteroids. Asteroids are modeled geometrically with arbitrary shapes, rotating slowly on their axes, creating dynamic movement. When hit by a missile, an asteroid disappears, and the score updates. Once all asteroids are destroyed, a new set appears at random positions, avoiding the ship. The background is a drifting star field, enhancing the visual depth, either static or animated based on the marking scheme.
Implementation of Core Components
Spacecraft Model and Rotation
The spacecraft is constructed from primitives such as triangles or polygons. It is positioned at the center of the scene, with rotation controlled by arrow keys, updating the model matrix for smooth transformations. The code should use clear, well-named functions such as drawSpaceShip() and rotateShip(), and include extensive comments. The model uses colored vertices to create texture-like effects, with future lighting planned for coursework two.
Asteroids: Rotation and Redraw
Asteroids are modeled from polygons and rotate continuously. Their shapes can be predefined or randomly generated, and upon destruction, they are removed and new ones are generated at random positions, excluding the ship location. Functions like drawAsteroids() and asteroidHit() manage their rendering and collision detection. The random placement algorithm ensures varied gameplay and scores extra marks for dynamic behavior.
Star Field Dynamics
The star field is implemented using points to simulate stars. It drifts slowly in a chosen direction, with new stars generated as old ones disappear, creating an immersive background. Static star fields are acceptable but less rewarded. OpenGL functions such as glPointSize() and glBegin(GL_POINTS) are used, with colors for texture simulation. The star field enhances the depth and visual richness of the scene.
Missile Mechanics and Collision Detection
Missiles are designed as short-lived primitives fired from the ship, moving in the direction of the ship’s orientation. Functions like fireMissile() and updateMissiles() update their positions each frame. Collision detection checks whether a missile intersects an asteroid using proximity thresholds. On collision, the asteroid disappears, and the score updates accordingly. The code must be well-structured, with extensive comments for clarity.
Score Panel and User Feedback
A dedicated on-screen panel displays the current score, updated whenever an asteroid is destroyed. It is drawn using textured or colored primitives, positioned to be visually distinct. Clear and responsive feedback mechanisms enhance user engagement.
Technical Considerations and Marking Criteria
Proper use of OpenGL primitives, transformations, and the GLUT library is essential. Your code should be structured into functions with meaningful names, extensively commented, and follow good coding practices. Collision detection, object rotation, and random generation algorithms are key aspects. The game should run in real time, with smooth animations and interactive controls. Marks are awarded for code quality, adherence to specifications, and implementation of features, with additional marks for creative design in object shapes and background effects.
Conclusion
This project demonstrates fundamental skills in computer graphics programming, including primitive modeling, transformations, collision detection, and user interaction within OpenGL. By successfully implementing the game's core mechanics, students develop a solid foundation for more advanced 3D game development, including enhancements like lighting and textured models in subsequent coursework.
References
- OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.5 (8th Edition). (2013). Addison-Wesley Professional.
- Shreiner, D., & et al. (2013). OpenGL Programming Guide: The Official Guide to Learning OpenGL. Addison-Wesley.
- Mattson, T., et al. (2012). OpenGL SuperBible: Comprehensive Tutorial and Reference. Addison-Wesley Professional.
- Watt, A., & Watt, M. (2013). 3D Computer Graphics. Addison-Wesley.
- Hearn, D., & Baker, M. (2011). Computer Graphics with OpenGL. Pearson.
- Foley, J. D., van Dam, A., Feiner, S. K., & Hughes, J. F. (1990). Computer Graphics: Principles and Practice. Addison-Wesley.
- Angel, E., & Shreiner, D. (2011). Interactive Computer Graphics: A Top-Down Approach Using OpenGL. Addison-Wesley.
- Eric Lengyel. (2010). Mathematics for 3D Game Programming and Computer Graphics. Delmar Cengage Learning.
- Porter, T. (2000). OpenGL: A Primer. Addison-Wesley.
- Hughes, J. (2014). Foundations of 3D Computer Graphics. Springer.