CS 4554 - Computer Graphics I: Assignment1: 2D Transform

Lab Project Files

Windows Users

Download Lab1_Win.zip

Mac Users

Download Lab1_Mac.zip

Upload to Blackboard

  • A description of your project structure (short documentation);
  • Source code with enough comments to make it clear what you are doing;
  • Video/Gif/Images of your result (upload to the discussion board as well);

Requirements

  • In this lab, you are asked to create a simple space ship shooting game based on the project files that are given above.
  • You are required to finish:
    • Move the space ship with the keyboard
    • Rotate the space ship based on the relative direction between the ship and the mouse position
    • Move and rotate the rocks in space
    • Pause the game and display an explosion when the ship collides with the rocks
    • Shoot bullets from the space ship and destroy the rocks
  • Extensions (Bonus):
    • Use more precise bounding boxes such as OBB, triangles, or convex polygons to detect collisions.
    • Create enemy drones to attack you
    • Add scoreboard, heath bar or other mechanisms to make the game more polished
    • Better collision response. (such as collide with each other, bouncing off the wall, etc.)

Transformations

  • The primary goal of this project is to implement 2D transformations that apply the translation, rotation, and scaling to objects.
  • In OpenGL, there are two ways to do this:
    • 1. Update the GL_ModelView matrix via OpenGL API, such as glLoadMatrix(const GLfloat * m); glPushMatrix(); glPopMatrix(); Since all object vertices are multiplied by the ModelView matrix before being rendered (OpenGL does this automatically), this will render the object in a new location and orientation.
    • 2. Apply the transformation to all the individual vertices of an object manually (multiply transform matrix with vertex vectors) and then just draw the transformed object, so no need to update the ModelView matrix.
  • No matter which way you choose, a matrix class to calculate the transformation would be convenient. And you may find it useful in the future.

 

Collisions

  • To find collisions among models and boundaries, a simpler (but less accurate) way is to define a sphere(4.3.1) or AABB(4.2) (axis-aligned bounding box) big enough to cover the object and find collisions between that and any of the objects in the scene.

 

Additional Help Information

  • The default display range in the project is from ( -1, -1 ) to ( 1, 1 ), since we have already pre-processed the models during loading, the size of the models are all unified to fit a 2x2 box.
  • The mouse position uses a different coordinate: (0, 0) to (windowWidth, windowHeight), so the Y-axis is opposite to the display coordinate, the center is different as well.
  • To calculate the angle between 2 points based on a relative vector, atan2() would be a good option.