CS 4554- Computer Graphics I: Assignment 1 : 2D Transform

Requirements

  • Download the project : CG1_LAB1.zip;
  • Load multiple 2D objects in the scene;
  • Control one object ( translate and rotate ) by keyboard or mouse;
  • Detect collision between objects and avoid penetration;

Upload( blackboard )

  • A description of your project structure (short documentation);
  • Source code with enough comments to make it clear what you are doing;
  • Movie of your animation

Transformations

  • The primary goal of this project is to implement 2D transformations that performs the rotations and translations on objects.
    In OpenGL, there are two ways to do this:
  • Update GL_ModelView matrix via OpenGL API. 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.
  • Apply the transformation to all the individual vertices of an object manually (multyply 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, generally you need to create a matrix class to calculate the transformation. And you may find it useful in the future.

Collisions

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

    When a collision occurs, you need to solve the penetration by stopping moving or sliding along the thing it hits. If your code implements collision detection without any response, try to find some way to show a occurring collision visually, for example, draw the intersected objects in a different color.

Extensions (Bonus)

  • Use more precise bounding box such as OBB, triangles, or convex polygons to detect the collisions among objects;
    Sometimes you may need to use different type of bounding boxes for different objects ( for example, you may prefer sphere for ball, box for wall );
  • Better collision response. Change the moving direction, add penalty force, or any other way to solve the penetration for a better quality;

Other Notes

  • The default display range in the project is from ( -1, -1 ) to ( 1, 1 ), so if you want to display your models correctly, you may need to scale them.
  • Update modelView Matrix in OpenGL : check glMatrixMode, glLoadIdentity, glTranslatef, glRotatef, etc. for more information;
  • Process keyboard input in GLUT : In this project, you need to do that in function key_press and special_key;
    check glutKeyboardFunc and glutSpecialFunc for more information;