← Home

Assignment Description

Due: Friday Nov 4, 23:59:59 IST

You will write the OpenGL rendering and interaction part of a very simple game engine. We supply you with the geometry and textures of 5 maps from the Half-Life series, and we load this into an internal mesh structure for you. Your responsibility is to render this map, and allow the user to fly through it.

IMPORTANT, LICENSING ISSUES: This project uses maps from the Half-Life commercial engine. We are supplying this, and using it, in a purely educational manner. YOU ARE NOT ALLOWED TO REDISTRIBUTE ANY OF THIS DATA, OR USE IT FOR ANYTHING BEYOND THIS CLASS. In an effort to make the course relevant and interesting we are supplying you this data, but all copyright is still held by Valve Inc.

Skeleton Code

Download skeleton code here
Download map files here

Please ensure the GLUT library and headers are installed on your system. On Macs, it is usually installed by default. On Linux, try FreeGLUT.

Minimum Specifications

This project includes both the programming of an OpenGL application, as well as the more trial-and-error process of configuring your program to open with a reasonable view of the map you're loading. We suggest working through features in the order listed.

  1. Render all the polygons inside OBJMesh.
    • Each polygon is stored as an OBJFace (See MeshInfo.hpp)
    • Start by rendering each polygon with the color of the material associated with it.
    • The materialId integer in OBJFace corresponds to the index of this polygon's material inside the materials array inside OBJMesh
  2. Implement controls to move through the scene. You need to support:
    • Keyboard controls moving forwards and backwards (translating along the camera's z-axis)
    • Keyboard controls for looking left and right (rotating in horizontal plane, around camera's y-axis)
    • Keyboard controls for looking up and down (rotating around camera's x-axis)
    • Make the default position that the camera displays when the program launches be looking down on the map, ensuring that the whole map is visible. You can, for extra credit, implement something different that initializes the camera in a specific place within the map. This is specially relevant if you implement the "Gravity" part of the extra credit section -- in this case your default position should not start out as looking down on the map, but be somewhere on the ground plane inside the map.
  3. Implement a Phong shader in GLSL using the provided shading framework.
    • Use Shader::setUniform to pass uniforms to the shader variables you create.
    • Read the color of each polygon from its associated material.
    • Use the global material properties read from the command line. This is stored inside the Scene object as material. The Phong formula is the same as in A3.
    • Light the mesh using two directional lights. Use the bounding box we make available inside OBJMesh to configure the directional lights in a sane manner. Offset the two lights in opposite directions, so that it creates the effect of having two suns in different parts of the sky falling onto the map. To do this, you can, for example, model it as a light coming from a directional orthogonal to the largest side of the bounding box.
  4. Texture map each polygon by passing the texture map for this polygon to the GLSL shader.
    • The materialId integer in OBJFace corresponds to the index of this polygon's material inside the materials array inside OBJMesh. This material holds the specific texture map information for this polygon. Use Common.hpp's createGLTexture function to convert a bitmap image to an OpenGL texture stored on the GPU, and store the texture id using the variable we provide in the material class.
    • You will need to modify the GLSL shader to use this texture map. To specify the current texture, call Shader::setUniform with the ID of the texture.

Extra Credit

We will be awarding extra credit up to 25% of the assignment total. We will be awarding credit roughly proportional to the order of these ideas:

Implementation Hints

To start off, please read the MeshInfo.hpp header file that describes the whole internal mesh format. Understand how to access different types of elements -- there is some sample code in Scene.cpp that shows you how to query the mesh for data.

Look at the main() function to see all the OpenGL configuration we do.

TODO comments appear inside the code. Fill things in here. If you need to go beyond the skeleton or modify things to your own liking, feel free to do so.

Submission Instructions

Please submit a zip of your assignment directory, named <your-roll-number>.zip (e.g. 123456789.zip), containing:

Do NOT submit object/executable files or any other data. Run make clean before zipping.