0% found this document useful (0 votes)
5 views

PS2

The assignment requires creating an interactive animation of a rocket using OpenGL, focusing on texture mapping, blending, particle systems, and animation. Students must implement a particle system for the rocket's fire, design the rocket using geometric shapes, and create a star field to simulate outer space. Creativity is encouraged in designing the rocket and textures, as well as adding features like keyboard controls and additional effects.

Uploaded by

simon wong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PS2

The assignment requires creating an interactive animation of a rocket using OpenGL, focusing on texture mapping, blending, particle systems, and animation. Students must implement a particle system for the rocket's fire, design the rocket using geometric shapes, and create a star field to simulate outer space. Creativity is encouraged in designing the rocket and textures, as well as adding features like keyboard controls and additional effects.

Uploaded by

simon wong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSC3260 Principle of Computer Graphics

Spring Term 2003


Problem Set 2
Due Date: 14th of Mar, Friday, 6:00pm
20% per day penalty, Fail the course if you copy

The Rocket

Topics:
Texture Mapping
OpenGL Blending
Particle System
Animation with Timer

Introduction:
In this assignment, you are required to create an interactive animation of a rocket flying
in the outer space. The rocket is drawn using basic OpenGL primitive like triangle fans
and quads, and is texture mapped with a bitmap image file texture. The fire at the bottom
of the rocket is rendered using a particle system, in which each particle is governed by
the Newtonian law of motion. And the surrounding star space is implemented using a
virtual star sphere consisting of many vertices.

Implementation Details
z Texture Loading and Texture object generating (10%)
A bitmap file loader bitmap.h and bitmap.c are provided for your use, and the
function GLubyte * LoadDIBitmap(const char *filename, BITMAPINFO **info) can be
used to load a bmp file. The contents of the image are loaded into an Glubyte array (in
the format of GL_RGB) and the bmp header information like width and height are saved
into the BITMAPINFO structure.
In GLvoid LoadGLTextures(void), you are required to load 2 bitmap files and
create one texture object for each of it. Each texture object should have proper texture
parameter setting like how the texture is to be applied to each pixel, the minification filter,
magnification filter, repeating and clamping settings; and then specify the bitmap as a 2D
texture for each texture object using glTexImage2D(). The 2 bitmap files are provided,
Particle.bmp is the particle texture and Rocket.bmp is the rocket texture.

z The Particle System (30%)


The fire at the bottom of the rocket is required to implement using a particle system
adopting Newtonian Physics. Each fire particle is described as:
typedef struct
{
int active; //Dead Or Alive?
float life; // Indicate how long it can still live, range
// 0.0~1.0, when decresed to <=0.0, it's dead
float fade; // Indicate how fast the life decrease
float color[3]; // The RGB color of the particle
float pos[3]; // the current position of the particle
float velocity[3]; // the current velocity of the particle
float acceleration[3]; // the current acceleration of the particle

} particle;

and a particle system is described as:


typedef struct
{
particle particles[MAX_PARTICLES]; // Particle Array
float initspeed[3]; // The initial speed for newly generated particles in
//the particle system
float initaccele[3]; // The initial acceleration for newly generated particles in
//the particle system

} particleSystem;

A particle system named “fire” is created for you.

In the InitParticles(void) function, you have to initialize the attributes of the particle
system and also the attributes of each particle in it, including position, velocity,
acceleration, color, life, fading speed, etc, in which the color is chosen from a color array
static GLfloat colors[12][3]. You should add some randomness to some attributes
initialization like velocity, acceleration and fade to achieve good effect. A useful
equation maybe

initial value = mean value + randomness × range

You can choose to use the data structures provided, or you can design your own. Marks
will not be deducted for not using the provided data structures.

In the UpdateParticles(void) function, which is called after each frame is drawn, you have
to update the attributes of each particle. You may assume the motion of each particle
follows the following discreet Newtonian equations:
Moving
direction
∆s = v(t) × ∆t
∆v = a(t) × ∆t
Gravitational
force
where ∆t is the incremental amount of time, v(t) and a(t) are the current velocity and
acceleration at time t. ∆s is the incremental distance traveled ( in x,y,z dimentions). And
∆v is the corresponding incremental change in velocity. The acceleration of each particle
may be governed by the gravitational force (G) or other field you specify. You should
also decrease the life of each particle using the fade value and produce the fade out effect.
And give those dead particles (life<=0) a new life by setting its attributes again.

In the DrawParticles(void), you should draw each particle as a square facing the
viewer(looking at the –Z direction). The center of the square is the current particle
postion, and the length of each side is 1.0.

(x+0.5,y+0.5,z)

(x,y,z)

Texture map
(x-0.5, y-0.5, z)

This square use the particle color, in the format of RGBA, in order to do the blending.
The life of the particle is used as the alpha channel. And it is also texture mapped with a
“mask” bmp texture to modulate its color and produce a feathered edge. OpenGL
Blending should be enabled for proper combination of colors with the background.

z The Rocket (30%)


H[0]

Cylinder radius r[0]

H[1]

H[2]

H[4]

H[3]
The rocket is designed using a cone(the head), a cylinder (the body) and 4 quads (the
wings). The cone is drawn using triangle fans, and the cylinder is approximated by a
series of quads. The center of the bottom of head is placed at the origin of the modeling
coordinates. All the shape data are stored in an array float H[5], and float r[2] (only r[0],
r[1] is for texture coordinates).

Texture mapping:

The texture map has 3 parts for the head, body and wings. The head and wing use planer
mapping, and the cylinder body use cylindrical mapping. The texture coordinates are
stored in the array float s[5], float t[6], and also float r[2] (only r[1], r[0] is for modeling)

Center s[0], t[0], radius r[1]

s[2], t[2]

s[1], t[1]
s[3], t[5]

s[4], t[4]
s[3], t[3] s[4], t[3]
In the GLvoid DrawRocket(float H[5], float s[5], float t[6], float r[2]) function, make use
of the parameters, calculate the corresponding texture coordinates and specify it with
glTexCoord2f() for each vertex. You have to set the texture parameters correctly when
loading the rocket texture, which is described before, so that the lighting effects can also
be applied to the rocket.

All the shape data and texture coordinates arrays: float H[5], float s[5], float t[6], float r[2]
are provided with default values, and the texture maps are provided. You may change or
design your own texture map and coordinates if needed.

Timer Animation
The animation is produced by using a glut timer, which will reset itself and continuously
call the function TimerFunc() every 10 ms. You should place any animation controls, like
those variables which need to be updated after every frame here.

Star Field (10%)


In the function GLvoid InitStars(void) and GLvoid DrawStars(void)
Initialize all the stars in the array named stars, including colors and positions, all the
stars must be randomly distributed on a virtual sphere. Draw the virtual star sphere
around the rocket to simulate the outer space, you should do rotations of the sphere
during animation and make the stars seems moving, also you can try to make them
flashing to add in more effect.

Creativity (20%)
1) Design your own rocket and the texture map for it. Design new texture map for the
particle. You can also add in new objects with proper texture mapping.

2) Implement keyboard controls to change the fire color, power of the fire, view the
rocket from different angles, etc. Also you can make the fire more realistic by
gradually changing color in animation and adding a spline trail for each particle.

3) Other good effects you can think of.

Grading Scheme:
z Texture Loading and Texture object generating, texture parameter settings (10%)
z The Particle System, life cycle, and particle rendering (30%)
z The Rocket texture mapping (30%)
z Star Field (10%)
z Creativity (20%)
Guidelines to submit programming assignments to graphics account
1) In each "*.c" file, type your full name and student ID. Missing of this essential
information will lead to mark deduction.

2) You are suggested to write your programs on SOLARIS, since there will be enough
technical support. If you developed the program in other platform, make sure your
program can be compiled and executed on SOLARIS as the program will only be
tested on this platform.

3) Provide only one source file and name it as submit.c. All your codes should be
resided in this file. No additional .c or .h files are allowed (no need to include
bitmap.h and bitmap.c). No need to provide Makefile as the program will be tested
using the sample Makefile and other utility files available in the graphics account.

4) Provide a README.txt file and describe any special or new feature of your program

5) Zip all the program files together with any bmp texture maps of your own(if you use
the original Particle.bmp and Rocket.bmp, no need to include) in one zip file. Name
the zip file with your own student ID. Zip only the essential *.c (submit.c), texture
maps , and README.txt. For example, type (on UNIX)
zip 01234567.zip myRocket.bmp submit.c README.txt

6) uuencode the zip file and mail it to graphics account with the subject "ps2 01234567".
ps2 stands for problem set 2. 01234567 is your student ID. Keyword ps2 is critical for
the mail filter to work correctly. For example, type (on UNIX)
uuencode 01234567.zip 01234567.zip | elm -s "ps2 wkchan" [email protected]

7) Note that you have to type the "01234567.zip " twice in the uuencode command.

You might also like