CS 4204: Computer Graphics

 

Announcements & syllabus

Schedule

Programming assignments

Homework

Exams

Courseware

Programming Assignment 2: Our first 3D Game

Summary

You will implement a program that displays a simple 3D world and allows the user to interact with it by firing cannon balls.

Due Date

The assignment is due on Thursday March 20 at 11:59 PM. The standard late policy for programs is in effect.

Required Features

  • The program should be written in C or C++ using openGL/GLUT. You may use any openGL/GLUT functions for this assignment.
  • The program should create a single interface window.
  • The window should display a perspective 3D view containing:
    • A flat ground plane with a regular texture (e.g., checkerboard).
    • Two rows of "columns" that extend away from the viewer. These should be relatively tall objects, of any shape. The rows should be a good distance apart but both rows should be clearly visible to the viewer.
    • A cannon that appears to come out of the camera. Initially the cannon should be parallel to the ground.
  • The user can interact in any of the following ways:
    • Moving the mouse up and down causes the cannon to rotate (pitch) up and down. The cannon can have any pitch between 0 and +80 degrees.
    • Clicking the left mouse button causes a ball to be fired out of the cannon. The ball's flight should then be animated using simple Newtonian physics. In other words, the ball should maintain its initial horizontal velocity, and its vertical velocity should change based on acceleration due to gravity. When the ball intersects the ground plane, it should stop, and remain at that position for the remainder of the program's execution.
    • Using the plus (+) and minus (-) keys changes the initial velocity of the ball. Display the current initial velocity at the bottom of the window.
    • Pressing the b key activates "be the ball" mode. In this mode, when a ball is fired, the camera should move through the 3D world along with the ball, and should rotate to point along the ball's current movement vector. Keep the initial offset of the camera to the ball constant (i.e., keep the ball in front of the camera). When the ball reaches the ground, wait 1 second, and then return the camera to its original location. Obviously, in this mode only one ball can be in the air at any time.
    • Pressing the n key returns the program to normal mode if "be the ball" mode has been activated.

Optional Features (for up to 10 bonus points)

  • Create a visually interesting 3D world for the balls to fly through.
  • Provide a nicer interface for setting the cannon pitch, the initial velocity, and the program mode.
  • Provide a third mode allowing the user to fly around the 3D scene.
  • Provide targets for the user to try to hit with the balls, and detect when the balls hit the targets.
  • Provide a virtual dog to retrieve the balls after you fire them. :-)

Submission

Turn in your program via email to the TA. You may either submit a single source file or a ZIP archive of several source/header files. You may also optionally include a plain text README file if you wish.