|
CS 371
|
Program 3: GLUT Galaxy
Due on 4/29/05 before MIDNIGHT
The goal of this assignment is to learn the basics of constructing animations in OpenGL. You are to implement a system that animates a list of GLUT shapes as specified by a scene file.
Call your directory yourlastnameProg3 and pack it into a single "tar" file. Then drop the tar file off in the drop-off directory. The files in your directory should be correctly set up so that I can compile and run them without having to make changes.
Below is a sample scene file, including a full description of the scene file format. If you wish to add features, you should do so in a manner consistent with this format. I have included some examples of the suggested format for optional features. Such lines are commented as optional.
// Here is a sample scene. The keyword // indicates a comment that extends
// the end of the current line.
// Keywords and parameters
// The Scene-------------------------
// numX n
// int n is the number of items of type X to be entered, for example
// numLights n
// numSurfaces n
// windowDims (rows, cols)
// where rows and cols are int
// sceneAmbient (ambient)
// Point3Df ambient
// Cameras-------------------------
// camera (eye,lookAt,up,viewAngle,near,far)
// Point3Dd eye, lookAt, up
// double viewAngle, aspectRatio, near, far
// Note: near and far are given as positive values: They represent
// distance from eye along negative n axis. Angle is in radians
// Lighting-------------------------
// pointLight (location, ambient, diffuse, specular)
// Point3Df location, ambient, diffuse, specular
// dirLight (direction, ambient, diffuse, specular)
// Point3Df direction, ambient, diffues, specular
// Materials-------------------------
// A material property applies to all surfaces after it but before the next
// material property
// material (ambient, diffuse, specular, specExp)
// Point3Df ambient, diffuse, specular
// double specExp
// Transforms-------------------------
// A transform applies to all surfaces after it but before the next transform
// All rotations are counter-clockwise
// All angles are in DEGREES! Velocities are in degrees/frame.
// identity
// rotate (angle,direction) // see text for description
// double angle (radians); Point3Dd direction
// scale (xscale, yscale, zscale)
// double xscale, yscale, zscale
// translate (xtranslate, ytranslate, ztranslate)
// double xtranslate, ytranslate, ztranslate
// transform T // optional
// Transform4Dd T is an arbitrary transformation
// orbit (startAngle, velocity, distance)
// double startAngle, velocity, distance
// orbits are in (local) (x,y)-plane at the given distance from origin.
// They proceed couunter-clockwise around the (local) z-axis.
// startAngle gives starting orbital position for object, where
// startAngle = 0 lies on x-axis.
// spin (axisOfRotation, velocity)
// Point3Dd axisOfRotation
// double velocity
// Any object might spin around some local axis (axisOfRotation)
// orient (fromAxis, toAxis)
// Point3Dd fromAxis, toAxis
// Rotate coordinate system so that fromAxis moves to toAxis through
// the plane they determine (i.e., rotate around fromAxis x toAxis).
// Shapes-------------------------
// sphere (radius, longitudes, latitudes)
// double radius, int longitudes, latitudes
// torus (smallRadius, largeRadius, longitudes, latitudes)
// double small(and large)Radius, int longitudes, latitudes
// teapot size
// double size
//----------------------------------
//A sample scene file
windowDims (300,300)
sceneAmbient (0.2,0.2,0.2)
camera ((0,0,6),(0,0,0),(0,1,0),1.04703,1,1,150)
dirLight ((1,1,1),(.1,.1,.1),(.6,.6,.6),(.6,.6,.6))
// pointLight ((5,5,4),(.5,.5,.5),(.7,.7,.7))
material ((0.329412, 0.223529, 0.027451),(0.780392, 0.568627, 0.113725),
(0.992157,0.941176,0.807843),27.8974)
orient ((0,0,1),(1,1,0))
spin ((0,0,1),1)
teapot 1
pop
pop
material ((0.19125, 0.07355, 0.0225),(0.7038, 0.27048, 0.0828),
(0.0256777, 0.137622, 0.086014),12.8)
orient ((0,0,1),(-1,1,0))
orbit (0, 2, 2)
spin ((0,1,0),1)
sphere (.4, 15,15)
pop
orient ((0,0,1),(0,1,0))
orbit (180, 3, 1)
sphere (.2, 10,10)
pop
pop
pop
pop