Computer Graphics Programming
Primary topics covered:
- Basic Graphics programming using OpenGL
- Preliminary taste for VR Juggler (as time permits)
Foreword:
I would like the computer graphics with OpenGL experience to be fun & exciting, and I will try my best to keep you engaged. As I mentioned last year to REU students, it is your enthusiasm and creativity plays primary role in creating fantastic effects. I will give you as many examples as possible so you can attempt your assignments & projects off them. Do not hesitate to ask/email me if you have any questions.
Steal code as you see fit from the resources I provided or from elsewhere. Do NOT claim it as your own, but use it to the enhance the "cool factor" in the code that you are developing on your own. In your code, acknowledge the poor guy from whom you stole any piece of code from. It will make him happy if he happens to see your code at some point in his life.
I take it that the class contains people from various fields and various levels of expertise and experience. So, be a good neighbor and help out others if they are stuck at any point. Collaboration is very good. I encourage you guys to work in groups for completing the assignments and projects.
Day 1
- Intro to OpenGL
- Some OpenGL applications created by people like you
- A walk through of a simple OpenGL code
- Assignment for Day 1
- Download simple OpenGL 'Dots' example code. The output of the code consists of 3 dots. Assignment for day 1 will require you to:
- Compile and run the code
- Add a 4th dot
- Write your name initials using OpenGL primitives - points, lines & polygons
- Enclose your initials within a circle. You will need to create a circle using OpenGL line or line strip primitives. Hint: Think about defining your circle using polar coordinates (Polar what ?? Are you sure you didn't mean polar bear or polar express?? What is it anyway? Hint: Google search).
- The initials are to have one color and the circle should be in a different color.
- You can make the code fancy by adding stuff - like animating your initials, changing stuff on screen with keyboard input etc. Use your imagination
- Submission:
- Rename your folder containing the visual studio project to 'firstnameLastnameDay1'. Then, copy paste this folder on the X drive at: X:\users\reu\GraphicsProgrammingCourse\Submissions\Day1.
Day 2
- Animation
- OpenGL Coordinate System
- Keyboard & mouse feedback
- Transformations
- Projection transformation
- Model View transformation
- Project proposal presentation on day 3
- Assignment for Day 2
- The primary aim of this assignment is to familiarize with transformations.
- Download the 'rotating cube' template code provided.
- Create a simple planetary system
- A central sphere that spins on its vertical axis
- A second sphere that is at an offset, which also spins, but the axis is to be at 23.50 to the vertical.
- Make this second sphere revolve around the central sphere
- Automate these transformations in a smooth animation
- Press the key 'R' to reverse the direction of spinning and revolution
- Draw straight lines through the spheres to make their axes visible
Day 3
- Normals
- Lighting
- Material Properties
- Load 3D Models
- Assignment for Day 3
- The primary aim of this assignment is to familiarize with lighting.
- Download the template code provided (day3Lighting.zip).
- When you run the code, you should see a no-roof room with a blue colored car that can be moved forward and backward using up and down arrow keys. The car can turn left and right with left/right arrow keys as well.
- The car also has a head light that projects spot light onto the floor and one of the walls
- The exercise for today is very simple. You would need to address the following questions:
- Question # 1
- Light from the car does not show on Al Capone. Throw light from the car's headlight on Al Capone. You would need to work with the function that draws Al Capone in render.cpp
- Question # 2
- Two .obj models come pre-loaded (al.obj and porsche.obj). Load a soccer ball .obj file located in the folder 'data'.
- Question # 3
- Write code to draw the soccer ball .obj model bouncing up and down on the floor. Make sure the light rays from the car's headlight appear on the bouncing soccer ball, when it passes by.
- Question # 4
- Currently, the headlight works only on the floor and left wall. Make it work for other walls too.
Day 4
- Assignment for Day 4
- The primary aim of this assignment is to familiarize with simple texturing and some terrain drawing.
- Download the template code provided (simpleTerrainLoader). You might also need simpleImageLoader.zip and normalVector.zip sample files as well.
- The simple terrain loader assignment template will draw a terrain that is loaded from a text file. Loading terrain data into the program is done for you already.
- When you run the code, you will be able to see terrain in three different modes - wireframe triangles, wireframe quads, and points. You can toggle between these modes by hitting the key '1', '2', and '3'. Pressing '4' button does not draw anything yet. This part has to be filled by you.
- You will have to write code to draw a textured terrain. You will need to address the following three questions to get it working:
- Question 1: Load an image file in the init() function. Check simpleImageLoader sample to know how to load an image file
- Question 2: Fill up the function 'calcNormalVector' with code so that it takes three vec3_t parameters and returns a normal. See 'normalVector.zip' file to know how to calculate a normal vector, given three different X, Y, Z coordinates.
- Question 3: Finally, write code to create a terrain that is made of quadrilaterals. 'toggleMode = 3' option will draw the terrain in wireframe with quads. Your textured terrain code also will look similarly except that you will have to add code to specify texture coordinates. The trickiest part of this question is to figure out how to sample the texture coordinates so that one texture spreads out over the terrain rather than having multiple textures repeated again and again.
Day 5
- No new material covered today
- Downloads for day 5
Projects
- There needs to be a proposal. Team members in each pod are required to do a three minute power point presentation indicating what they wish to do for the final project. I will evaluate them and discuss with each team if it is a realistic goal. You are free to choose a topic related to your faculty member assigned project. However, the computer graphics project must be OpenGL related.
- Date for project presentations: Thursday, June 16, 2009
- Time: 3 - 4.30pm
- Submissions: Zip your entire project folder and save it in the X drive in the appropriate folder
- Deliverables for presentation: Live demo of the project required. Power point slides explaining the contribution of each team member required
- Extensions: This is a hard deadline. Please stick to it
- In the final project presentations, have 1 or 2 slides explaining highlights and challenges encountered when completing the project. Also, indicate the contribution of each team member in completing the project
- Show your project in action
- Q&As at the end of the presentation
- Work with your own research team in your pod.
- I strongly encourage you to divide up tasks for the project on the first day so everyone has fair amount of input. It is for your own benefit. It hurts to see one work horse doing the coding while others go bask under the sun.
- There is no limit to what you can do for your projects. Here are a few ideas however:
- 2D/3D Breakout
- 2D/3D Paint
- Tetris
- Solar system
- Roller coaster
- A NASCAR race simulation
- Expand on the projects you have done in the 'Intro to computer programming' and make it graphical
General Notes:
- Linux Users
- If you are a Linux fanatic or if you would like to explore Linux for a change, please do so. I personally prefer using Linux although the OpenGL codes you would develop can run on both the platforms.
- I made sure that the source code templates I provided can be compiled and executed on both Windows and Linux. Each template has a .vcproj file for windows users and a Makefile for Linux users.
- Visit codeDevelopmentOnLinux to get started with using Linux.
- Assignments
- Each of you need to submit an assignment although you can collaborate with each other for the completion
OpenGL Resources:
OpenGL Example Templates:
The codes that you can download here are meant to be templates for doing your assignments/project. I have tried to make each of them simple and self contained so that you can use parts of it directly in the code you develop.
| Template 1 |
Simplest OpenGL example - two cubes one with lighting and the other without |
| Template 2 |
An animated cube rotating about a vertical axis - useful to incorporate animation in your assignments/projects |
| Template 3 |
Bouncing ball - can be useful if you want to write any code that has to do with objects reflecting over a surface |
| Template 4 |
An image/texture loader - can load .jpg, .bmp, .gif, .png, .tga, .tiff, .pcx files. Works with transparent textures too. All you need is to call a function |
| Template 5 |
A terrain loader - can load simple ordered x,y,z points data set and can be loaded in three different modes - points, wireframe or textured with lighting |
| Template 6 |
A simple code illustrating texturing on objects - sphere, cylinder, cone, disk, etc |
| Template 7 |
A simple random number generator |
| Template 8 |
An OpenGL Bitmap font (text) renderer |
OpenGL WWW Resources:
--
VijayKalivarapu - 09 Jun 2009