Assignment 3                                                               due by 3/7/2008

 

[235 points] This assignment consists of two parts which are two separate programs. The purpose of the first part is to get you used to event-driven programming and callbacks using the GLUT libraries, as well as with some basic OpenGL commands. The second part is meant to be a somewhat open-endedIt is meant to help you learn the basic OpenGL commands related to both modeling transformations and basic viewing transformations. The material you will need for doing the second part is found mainly in chapter 3 of the OpenGL programming guide.

First Part2D insect

Implement the program found on pages 24-25 of the OpenGL programming guide (you should be able to copy it verbatim, plus add in the #includes in the header).  Once you have that running correctly, you are to modify this program to display something different, and to operate somewhat differently:

  • You are to replace the rectangle by a set of non-rectangular polygons with different colors. These polygons are to form a 2D insect modelThose colored polygons are different parts of this insect.  Make any insect as you like, but at least the insect should include one body, one head, and several legs. This will mean replacing the glRectf command with some basic commandsYou can find the necessary information in chapter 2 of the OpenGL book, through page 56.
  • Make the insect spin when the left mouse button is pressed down, but spin in the opposite direction when the right button is pressed down.
  • Make motion stop when the left/right mouse button is released, rather than when a different button is pressed.
  • While a button is pressed down (and the insect is spinning), you should let the user control the speed of the spinHere is how the control should work (assume the point at which they first click down on the mouse button is thehomeposition):  Moving the mouse up from the home position should make it go faster, moving it down from the home position should make it go slowerYou can always start spinning at some default rate (i.e. that is the rate it will spin at whenever the mouse is in the home position), if you wantThe farther up the mouse is moved from the home position, the faster it should spin, and the farther below, the slowerThis should apply only while the button is pressed after releasing the button, the speed should beforgotten”, so the starting spinning speed should be the same each time the button is pressed.
  • Moving the mouse left of the home position should decrease the intensity of the background colorMoving the mouse to the right of the home position should increase the intensity of the colorWhenever the mouse is at the home position, it should be at the initial colorNote that this also needs to occur only while a mouse button is depressed.
  • Change the color of the background to cyan, magenta, yellow, or white, when the 'c', 'm', 'y', or 'w' key is hit, respectivelyNote that the mouse movement should be able to increase/decrease the background color, so make sure the starting background color is notpurecyan/magenta/yellow/white, but can varyPick a color for your polygon that can be seen regardless of background color.
  • The user should be able to toggle between the ways the polygons are displayedIf the user hits the "1" key, the polygon should be displayed as a set of points marking the vertices onlyIf the user hits the "2" key, the polygon should be displayed as a set of lines showing the outline of the polygons only (i.e. not filled in).  If the user hits the "3" key, the polygons should be filled in completelyYou can start in a default position, and should always display the polygon in the form of the last way selected.
  • When the user presses the middle mouse button, they should be able to pick up and drag the insects in the windowThat is, when the user presses the middle mouse button (anywhere in the window, it does not need to be in the polygon itself), holds the mouse button down, moves the mouse, and releases the button, the polygons shoulddragby the distance/direction that the mouse movedNote that when you start spinning the insect, it is OK for the polygon to spin around the center of the screen, rather than its own center
  • Make the window title "<your name> - Assignment 3".
  • Second Part: 3D insect

    You are to implement an OpenGL program that performs the following functionsThere are several aspects you should try to include, and they will be worth varying numbers of pointsBut, you may get significant partial credit by doing some parts, even if others are skipped.

    Note: we have not discussed lighting, so most of your models will look very "flat" dont worry about thisWell add lighting stuff in later onBut, you should use different colors to highlight different parts, so that they can be distinguished.

    As a reminder, you are not to use outside code to do these tasksHowever, you may use the source code included in the OpenGL programming guide or in Hearn and Baker, and this might give you a good starting point.

    You should submit, along with your code, a README file that tells what the controls for the system areYour controls should not be too complicated, and should make some sense (i.e. not just random motions).  A common way is to use a key command to set a mode (e.g. move hand mode, or zoom mode, etc.), then make the mouse control the motionYour instructions should make it clear how you met the various components of the assignment, when options were givenAt least some motion must be specified by a mouse. Below is the detail instruction for the second part:

    aCreate a 3D hierarchical model of an "insect".

    You can use the example provided in the book (pages 152-154) for the robot arm as a starting pointThe insect, of course, will be more complicated than thisSpecifically, your insect should include:

  • Six legs, each leg with at least 2 segments
  • At least one "body" piece
  • A "head" piece
  • You should model this with reasonable shapes - see appendix D for some of the shapes GLUT provides for you (these will be sufficient) scaling/translating/rotating these will allow you to build a very basic, but still reasonably complex modelIdeally, you could use things like spheres at the joints to hide theseparationthat will occur as the pieces moveYour model does not need to be particularly accurate or precise, or even look that much like a real insect (in fact, it almost certainly wont).

    b. Allow the user to control the motion of the insect. 

    That is, the user should be able to make the insect move at the various jointsThe way you implement this motion is up to you, but it is suggested that you limit the motion in some fashionAt least one joint should have at least two degrees of freedom i.e. be able to rotate in two orthogonal directions (think your wrist vs. your finger joints).  The head would be an obvious choice here

    c. Allow the user to change the view parameters

    That is, you must allow the user to actually change things like the direction and orientation being viewed fromFor the purposes of this assignment, the view changes do not need to be too complicated (e.g., you dont need a full fly-through).  There are several ways you can change viewing parametersThese include, but are not limited to:

  • Pan: moving the viewpoint and eyepoint from left to right or up and down
  • Object centered rotation: moving the eyepoint around the object, but with same focal point.
  • Rotating in place: letting the eyepoint stay in a fixed position, but change the direction of view.
  • Zooming: Zooming in on an object (from same position)
  • Driving: moving eypoint forward/backward
  • You should implement at least 3 different view changesThey may chosen from the above list, but are not limited to themThat is, you should allow the user to change at least 3 different parameters in the way they look at the modelThese should affect the view only, not the model itselfYou should have at least one that affects the projection matrix, and at least one that affects the modelview matrix.

    d. Include hidden surface removal (see the very beginning of chapter 5 of the OpenGL programming guide). 

    Without hidden surface removal, things could look quite wrong, with the most recently drawn thing always appearing in front. You should use opengl functions to do hidden surface removal. You should run both backface culling and Z-buffer algorithm.

    f. Subjective Evaluation

    A portion of your grade will be based on a subjective evaluation of "how good" of a job you have done on the previous parts: modeling the insect, providing reasonable controls for the insect movement, and providing reasonable view controlsFor example, when modeling the insect, specifying additional parts/joints, choosing good shapes for the parts, etc. will earn more pointsSpecifying only the minimum number of parts using only rectangular boxes will earn you no subjective points.

    gAdditional Features.

    You have the chance to earn extra credit on this assignment by implementing additional featuresNote that the amount of effort to get these bonus points is not necessarily proportional to the amount of work theyll require (i.e. it can be quite a bit of work for not too many bonus points).

    1)      Put together a motion animation for the insectThe insect shouldwalkforward (or around) in some pattern by moving its legs (note that you do not need to allow a user to specify individual joint motion while this is happeningThe walking motion of the legs should benaturallooking, and the insect should move forward as its legs move

    2)      Allow the user to control thewalkingof the insectThis could be by giving directions (such as turn to the left/right by moving the mouse), giving a goal position (e.g. clicking at some point in front of it), etcIn doing so, the insect should be able to turn in different directionsNote that the walking motion should still benaturali.e. the turning should correspond with different leg movements.

    In your README file, you should clearly explain what (if anything) you have implemented additionally

    Grading:

    First Part: 2D insect

    [5] Draw insects (made by polygons)

    [5] Spin when left mouse button pushed down

    [5] Opposite spin when right mouse button pushed down

    [5] Spinning stops when mouse button released.

    [12] Speed of the insect changes smoothly when moving mouse up/down

    [12] Background intensity changes smoothly when moving left/right

    [10] Color changes with key press

    [10] Toggle 1/2/3 to display points/lines/filled

    [20] Click and drag polygon position.

    [1] Window titled correctly

    Second Part: 3D insect

    a. Overall: [10 points]

       [5 points] Basic requirements met, including README, window, etc.

       [5 points] At least some movement (model or view or both) specified using mouse.

    b. Model Specification: [30 points]

       [15 points] Insect put into place, with minimum number of pieces

       [15 points] Pieces specified in good configuration

       [5 points] Variation in coloring to distinguish (some) different parts

    c. Model Movement: [35 points]

       [30 points] User control over joint motion

       [5 points] At least one joint with at least two orthogonal rotational motions

    d. View Modification: [35 points]

       [30 points] Three view changes specified (10 points each), and working correctly

       [5 points] At least one change in projection and at least one in modelview matrix

    e. Hidden Surface Removal: [10 points]

       [10 points] Hidden surface removal included

    f. Subjective Evaluations: [30 points]

       [10 points] Insect is modeled well part shapes are reasonable, proportional, etc.

       [5 points] Controls over joint motion are intuitive

       [5 points] Joint motion is limited to appropriate ranges

       [5 points] Choices of view changes are reasonable

       [5 points] Controls over view are intuitive

    g. Additional Features: [up to 20 bonus points]

       [10 points] Basic walking motion implemented

       [10 points] Walking direction specification