CMSC 427 Assignment: Texture Mapping and Animation with OpenGL, Assignments of Computer Graphics

An assignment for cmsc 427, a spring 2009 computer science course. Students are required to set up opengl, compile texture.cpp, and complete various tasks such as replacing a large quad with a grid of smaller quads, modifying quad coordinates, animating ripples, and rotating the quilt. The assignment includes instructions for compiling the code on windows and linux systems.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-25f
koofers-user-25f 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assignment 1
CMSC 427, Spring 2009
Due 11:00am, Tuesday, Februrary 24, 2009
Maximum Score: 10 points
ThisassignmentinvolvessettingupOpenGL,texturemapping,procedurallydefinedmodelsandanimation.
CompilingtheStartupCode
Inordertocompiletexture.cpp,youwillneedtosetupthefollowingincludefiles:
#include <GL/glut.h> //openGL utilitiy toolkit
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h> //for reading from file
#include <math.h> //for trig functions
VisualStudiouserscanfollowtheinstructionsathttp://www.cs.csustan.edu/~rsc/CS3600F01/InstallOpenGL.html
Inaddition,Windowsuserswillneed
#include <windows.h> // make sure that <windows.h> comes before <glut.h>
Linuxuserscancompileusinggcc‐g‐otexturetexture.cpp‐lGL‐lGLU–lglutafteraddingfollowingincludes:
#include <stdlib.h>
#include <unistd.h>
Youwillalsoneedtohavetheassociated.libfilesand.dllfilesforGLUTinaplacewhereyourcompilercan
findthem.
AssignmentTasks
Gettheprogramcompiledandshowingthequilttextureonasquarefacingthecamerabeforemaking
modificationstotexture.cpp.
1. Thequiltiscurrentlymappedontoasinglelargequad.Replacethisquadbyagridofsmallerquadsthatcover
thesamearea.Theoutputafterthisstepshouldlookjustthesame:onelargesquarefacingthecamera.To
dothis,youwillneedtoreviewyournotesabouttexturemappingcoordinates.(2.5points)
2. Modifythecoordinatesofthesmallquadssothatthequilthasripplesorwaves.(Youwillneedtousea
trignometricfunctionforthis.)(2.5points)
3. Animatetheripples,sothatthequiltwavesovertime.(2.5points)
4. Rotatethequiltinvariousdirectionssothattheusercanseeitfromalldifferentsides.(2.5points)
Mostofyourchangeswillbemadeinthe“display”function,whichisrunagainandagaininaloop.Butyouwill
probablyneedtoaddsomeglobalvariablesthatmaintaintheirstatebetweenrunsofthisfunction.(Ifyoufeel
globalvariablesareinelegant,feelfreetodoitanotherway.)
Submityourfinaltexture.cppfile(wellcommented,please,includingyournameatthetop)electronically.
Youcandiscussthisassignmentwithothersbutallthecodethatyouturninmustbeyourownandnotbasedon
anyoneelse’swork.

Partial preview of the text

Download CMSC 427 Assignment: Texture Mapping and Animation with OpenGL and more Assignments Computer Graphics in PDF only on Docsity!

Assignment 1

CMSC 427, Spring 2009 Due 11:00am, Tuesday, Februrary 24, 2009 Maximum Score: 10 points

This assignment involves setting up OpenGL, texture mapping, procedurally defined models and animation.

Compiling the Startup Code In order to compile texture.cpp, you will need to set up the following include files:

#include <GL/glut.h> //openGL utilitiy toolkit #include <GL/gl.h> #include <GL/glu.h> #include <stdio.h> //for reading from file #include <math.h> //for trig functions

Visual Studio users can follow the instructions at http://www.cs.csustan.edu/~rsc/CS3600F01/InstallOpenGL.html In addition, Windows users will need

#include <windows.h> // make sure that <windows.h> comes before <glut.h>

Linux users can compile using gcc ‐g ‐o texture texture.cpp ‐lGL ‐lGLU –lglut after adding following includes:

#include <stdlib.h> #include <unistd.h>

You will also need to have the associated .lib files and .dll files for GLUT in a place where your compiler can find them.

Assignment Tasks

Get the program compiled and showing the quilt texture on a square facing the camera before making modifications to texture.cpp.

1. The quilt is currently mapped onto a single large quad. Replace this quad by a grid of smaller quads that cover the same area. The output after this step should look just the same: one large square facing the camera. To do this, you will need to review your notes about texture mapping coordinates. (2.5 points) 2. Modify the coordinates of the small quads so that the quilt has ripples or waves. (You will need to use a

trignometric function for this.) (2.5 points)

3. Animate the ripples, so that the quilt waves over time. (2.5 points) 4. Rotate the quilt in various directions so that the user can see it from all different sides. (2.5 points)

Most of your changes will be made in the “display” function, which is run again and again in a loop. But you will probably need to add some global variables that maintain their state between runs of this function. (If you feel global variables are inelegant, feel free to do it another way.)

Submit your final texture.cpp file (well commented, please, including your name at the top) electronically.

You can discuss this assignment with others but all the code that you turn in must be your own and not based on

anyone else’s work.