CSCI 441 - Computer Graphics

Fall 2016 - Assignment 2 - The Sword of a Thousand Truths



|   Home |  Syllabus |  Assignments |  Leaderboard |  Schedule |  Resources   |
This assignment is due by September 7, 2016 by 11:59pm.

Until this point, you have always led a rather humble simple life. Now that you will be recruiting other heroes, you realize everything is about to change. Your plain tunic and sandles do not live up to the brillance of your new banner. The woman's cloth shimmers as the sunlight passes through it. Meanwhile, your tunic is stained and tattered. If you are going to be the hero you said you would be, then you will need to look the part.


Part I - Adorn Your Hero


As you wander around the town, you realize everyone stops what they are doing to look at you pass by. Once they think you are out of earshot, they quickly begin whispering to each other. You no longer can pass through town unknown. You decide it would be best to purchase some new equipment and enter the local shop.

The shopkeeper leaps to his feet greeting you enthusiastically.
"Welcome, welcome! I am honoured that you have chosen my shop to outfit yourself before your upcoming journey."
('Journey?' you think to yourself 'What have I gotten myself into?')
"Please take whatever it is you need. Do not worry about the cost, that will be my problem to worry about. I will gladly do my part to help the cause."
Not wanting to insult the Shopkeeper, you begin browsing through his shop still unsure what this great cause is. You gather some items you think would be useful (new shoes, pants, a proper fitting armor, etc.) but only take the pieces you need. The Shopkeeper insists to take more, but you politely refuse.

You return to the Temple with your belongings and begin outfitting yourself with the new equipment. You are about finished when you notice a sword leaning against the altar. You didn't take a sword from the shopkeeper, where did it come from? It was not here when you got back, surely you would have noticed such an item. The old woman is nowhere to be found either. Stranger Things have been taking place lately.

After admiring the intricate details etched into the scabbard, you slowly remove the sword. A glow begins to emit from the blade and then quickly goes out. Confused, you fully remove the sword and realize there is a scroll wrapped around the end. You remove the scroll and the sword begins to glow once again in your hand, a bit longer this time, but again goes out. You unfurl the scroll and begin to read:
It was foretold, that one day, Heroes who could wield the sword might reveal themselves.

For this assignment, you will write an OpenGL/GLUT progrm that displays a 2D animated and interactive Hero. Make your window a traditional size (say 512x512...the same as A01, hmm). Your Hero must be made up of OpenGL primitives, at least one of which is solid, and drawn in hierarchical fashion. In other words, the eyes and mouth should be drawn with respect to the head and the head with respect to the body, etc. A carefully placed call to glTranslatef() could be used to move entire portions of the Hero's body.

Your Hero must have some form of constant animation regardless of user interaction (head bobbing side to side, arms waving up and down, etc.). The user must be able to move the Hero around the screen with the keyboard and the Hero must wrap around the screen. That is, when the Hero gets to the left edge of the screen, the Hero should then reappear on the right edge of the screen. Same scenario for right-to-left, top-to-bottom, and bottom-to-top. When each of these four scenario happens, you must call the following respective functions: moveLeft(), moveRight(), moveUp(), and moveBottom(). This will take care of advancing the map for you. Make sure to keep the function call to drawMap() at the beginning of your renderScene() function, right after we load the identity matrix to the ModelView Matrix.

The Hero must also interact with the mouse (change the Hero's color, expression, fire an arrow, etc.) and the interaction must be based on the position of the mouse (the Hero runs away from the mouse, it fires an arrow at the mouse, the Hero constantly looks at the mouse, etc.). Your program must register a callback for the keyboard, mouse, passive motion, and timer (it is generally not good practice to rely on glutIdleFunc()). Feel free to use the special keyboard keys as well (if you wish to control the Hero by the arrow keys). As discussed in class, it is possible to combine the mouse and keyboard together for Shift + Click operations.

Have fun and be creative! Don't be limited to just the suggestions above. Try out different key combinations, make full use of the mouse, make your assignment as cool as possible! Your Hero will be added to the Hero page so if you have a particularly cool pose you'd like to use, be sure to capture that as your screenshot.

Use this source code package(Mac & Win) as the starting point since it contains the necessary shell to create the world map. Additionally, download these world map images and put them into the images/ folder to populate the world map.
Clearly, you will need to learn to master such a powerful weapon, perhaps it is a sign from above.

You put on all your new equipment from the Shopkeeper, grab the sword, and look at your reflection in the blade. Looking the part of Hero, you let out a short breath. After a moment's pause you gather yourself, turn around, and walk out the door. You're unsure when you'll return to the Temple, but you know that day will come. Heading to the door, you step out and start looking for others to recruit. You're not sure how you'll know who to trust, but you have a sense they will reveal themselves to you.


Part II - Website


Update the webpage that you submitted with A1 to include an entry for this assignment. As usual, include a screenshot (or two) and a brief description of the program, intended to showcase what your program does to people who are not familiar with the assignment.


Part III - Questions


Briefly answer the questions below. Include your response in the README.txt file.
  1. Provide a series of OpenGL calls that accomplish the following transformations. Your answer should begin and end with glPushMatrix(), glPopMatrix(), and assume you have a function drawHelmet() which takes care of drawing the Mines helmet to the screen.
    1. As seen in class, it is very simple to rotate an object and have it spin around its own local axis. The Mines helmet is located at (x, y). How can we rotate the helmet around the origin (0, 0) without the object spinning, but staying stationary around its own local axes? An angle of rotation θr is provided and updated each frame to simulate the animation. (Think back to the example from the end of class on Wednesday, August 31).
    2. Instead of rotating around the origin (0, 0), how can we rotate the helmet around an arbitrary point (i, j)?
    3. We have discussed the Shear transformation in class. OpenGL does not provide a built in glShearf() as it does for translate, rotate, or scale. Provided an angle of shear θs, how can you tell OpenGL the necessary transformation matrix and apply the matrix to the drawing of the helmet? (Hint: Your answer will not require any reference to glTranslatef(), glRotatef(), or glScalef().)


Documentation


With this and all future assignments, you are expeced to appropriately document your code. This includes writing comments in your source code - remember that your comments should explain what a piece of code is supposed to do and why; don't just re-write what the code says in plain English. Comments serve the dual purpose of explaining your code to someone unfamiliar with it and assisting in debugging. If you know what a piece of code is supposed to be doing, you can figure out where it's going awry more easily.

Proper documentation also means including a README.txt file with your submission. In your submission folder, always include a file called README.txt that lists:
  • Your Name / HeroName
  • Assignment Number / Project Title
  • A brief, high level description of what the program is / does
  • A usage section, explaining how to run the program, which keys perform which actions, etc.
  • Instructions on compiling your code
  • Notes about bugs, implementation details, etc. if necessary
  • How long did this assignment take you?
  • How much did the lab help you for this assignment? 1-10 (1 - did not help at all, 10 - this was exactly the same as the lab)
  • How fun was this assignment? 1-10 (1 - discontinue this assignment, 10 - I wish I had more time to make it even better)


Grading Rubric


Your submission will be graded according to the following rubric.

PercentageRequirement Description
20%Hero is correctly drawn with OpenGL primitives. Draw calls are structured hierarchically, with some form of model instancing [1]. Hero must be broken down into function calls that handle smaller components.
25%Hero is in a state of constant animation, even when the user is not interacting with it.
20%Hero responds to keyboard presses by moving around the screen. Proper bounds checking is performed to move your Hero from world to world and the worlds update. Pressing ESC closes the program.
20%Hero responds to mouse clicks and mouse movement. The response is based on the location of the mouse.
5%Questions from Part III are answered and included in the README.txt file.
5%Submission includes source code, Makefile, and README.txt.
Source code is well documented. Webpage named <HeroName>.html submitted and updated with screenshot from latest assignment.
5%Submission compiles and executes.
[1] In other words, a call to drawHero() would be made up of calls to drawHead(), drawBody(), etc.. Within drawHead() are two calls to drawEye() to place each eye on the head. A properly placed call to glTranslatef() could move the entire head (and eyes) with respect to the Hero's body. Each component should be drawn with respect to the component it is attached to (i.e. eye locations are set as offset from center of head) rather than being specified with respect to the center of the Hero. Individual components can then be moved hierarchically. If there are any questions, feel free to post a question to Piazza.


Experience Gained & Available Achievements


Assignment Attribute
Assignments +100 XP
Web Attribute
Web +100 XP
Point, Set, Match
Point, Set, Match


Submission


Please update you Makefile so it produces an executable with the name a2. When you are completed with the assignment, zip together your source code, Makefile, README.txt, and www/ folder. Name the zip file, HeroName_A2.zip. Upload this file to Blackboard under A2.


This assignment is due by September 7, 2016 by 11:59pm.
Last Updated: 01/01/70 00:00


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0