Download Integrated Project (EIE330)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Transcript
EIE360 Integrated Project
Lecture 3
Particle Effects
References:
[1] Gregory Junker, Pro OGRE 3D Programming, Apress, 2006
[2] Ogre Tutorials – Ogre Wiki
http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials
[3] http://code.google.com/p/gmogre3d/wiki/ParticleScripts
[4] Microsoft MSDN, C++ reference
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
1
Architecture of the Interactive
Virtual Aquarium System
Computer A
USB port
Your
program
Kinect Sensor Device
Network
Computer B
3D Graphics
System
Your
program
3D Graphics
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
2
Particle Effects in OGRE




Particle systems are the foundation of most visual
special effects in a 3D application
They refer to the kind of computer graphics techniques to
simulate certain fuzzy phenomena
They are otherwise very hard to reproduce with
conventional rendering techniques
These fuzzy phenomena include bubbles, fire, smoke,
explosion, snow, …
Fireball
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
Bubbles
3
Particle System Templates

Particle systems are typically script based to enable fast
prototyping and iteration

Users only need to change the data in a script file in
order to change the behavior of a particle system

Templates are used to standardize the script files


Can be reused to create multiple particle systems that are similar
Some major items in a template



Basic – the basic setup information of the particle system
Emitters – define how the particles are emitted
Affectors – define the particles’ path and lifetime once emitted
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
4
A Typical Template
particle_system
EIE360/Explosion
{
quota 1000
material Examples/FlarePointSprite
particle_width
50
particle_height
50
cull_each
false
renderer
billboard
sorted
false
local_space
true
iteration_interval
0
nonvisible_update_timeout
0
billboard_type
oriented_common
billboard_origin
center
billboard_rotation_type texcoord
common_direction
010
common_up_vector 0 1 0
point_rendering
false
accurate_facing
false
emitter Point
{
angle 180
colour 1 0.9 0 0.9
colour_range_start
colour_range_end
direction
emission_rate
position
velocity
velocity_min
velocity_max
time_to_live
time_to_live_min
time_to_live_max
duration
duration_min
duration_max
repeat_delay
repeat_delay_min
repeat_delay_max
}
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
affector LinearForce
{
force_vector 0 -200 0
}
1 0.9 0 0.9
1 0.2 0 0.9
010
2000
000
300
300
300
2.5
2.5
2.5
2
2
2
5
5
5
affector ColourFader
{
red
-0.4
green -0.4
blue -0.1
alpha -0.5
}
}
5
Template: Basics

quota




Particle systems cannot emit particles without bound
Need to specify a quota
Will stop emitting particles when quota has been used up
material




Need to define how each particle is composed
E.g., an explosion can be composed by many
flare light points of different colors
The definition of materials is stored in a script file
Many material examples script files can be found
in media/materials/scripts
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
flare
6
Template: Basic (cont)

sorted



Ogre can sort particles based on their distance from the camera
Require heavy computation hence disable by default
May be useful in some situation such as (excerpt from [1]):
Without sorting, we see the fire
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
With sorting, the smoke
obscures the fire
7
Template: Basic example
particle_system
EIE360/Explosion
{
quota
1000
material Examples/FlarePointSprite
particle_width
50
particle_height
50
cull_each
false
renderer
billboard
sorted
false
local_space
true
iteration_interval
0
nonvisible_update_timeout
0 Many
billboard_type oriented_common
billboard_origin
center
billboard_rotation_type texcoord
common_direction
010
common_up_vector
010
point_rendering
false
accurate_facing
false
flare
light points
of large size
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
8
Template: Emitters

In the context of particle systems, an emitter is an object
that emits particle. A few emitters can be found in Ogre







point emitters
box emitters
cylinder emitters
ellipsoid emitters
hollow ellipsoid emitters
 emit from the shell of an ellipsoidal volume
ring emitters
 emit from the edges of a planar ring
The rate, velocity, and direction in which particles are
emitted are completely configurable
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
9
Template: Emitters (cont)

angle and direction


Particles are usually emitted in a “cone” around
the direction of the emitter
The size of the cone is defined by “angle”




If “angle” = 0, emit particle in a straight line
If “angle” = 180, emit in all directions
If “angle” = 90, emit in a hemisphere around the
direction vector
The direction is defined by “direction”

“direction” = 0 1 0, means parallel to the y-axis
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
10
Template: Emitters example
emitter Point
{
angle 180
colour 1 0.9 0 0.9
colour_range_start 1 0.9 0 0.9
colour_range_end 1 0.2 0 0.9
direction
010
emission_rate 2000
position
000
velocity
300
velocity_min
300
velocity_max
300
time_to_live
time_to_live_min
time_to_live_max
duration
2
duration_min
2
duration_max 2
repeat_delay
5
repeat_delay_min
repeat_delay_max
3. Particle Effects by Dr Daniel Lun
5
5
}
flare light points
emitted in all
directions
Department of
ELECTRONIC AND INFORMATION ENGINEERING
2.5
2.5
2.5
11
Template: Affectors




Affectors affect the particles’ path and lifetime once they
are emitted into the game world
Can impose “gravity”, “wind” on particles
Can define particles that will change color after emission
LinearForce
 Apply a force to the particles
 The particles will drift following the direction of the
force after emission
 E.g. force_vector 0 -200 0 defines a force vector that
forces the particles falling onto the ground after
emission
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
12
Template: Affectors (cont)

ColorFader



Modify a particle’s color while it exists
The color definition is in terms of “component change
per second”
E.g. The following code will fade the color by 0.5 each
second (the max and min value are 1 and 0, resp)
affector ColourFader {
red -0.5
green -0.5
blue -0.5
alpha -0.5
}
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
13
Template: Affectors example
affector LinearForce
{
force_vector
0 -200 0
}
affector ColourFader
{
red
-0.4
green
-0.4
blue
-0.1
alpha
-0.5
}
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
• All flare light points will
fall onto the ground
• Color will change and
disappear at the end14
Template: Affectors example
affector DeflectorPlane
{
plane_point 0 300 0
plane_normal 0 -1 0
bounce 0
}
Define an invisible plane
at point (0, 300, 0) with
normal equal to -1
(0, 300, 0)
X
Normal = -1
Means all particles will
go thru the plane
without bouncing back
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
15
Particle Editor


For fast prototyping of particle systems, an application
ParticleEditor is provided by the Ogre community
Allow real time visualization of the particle effect with
changes in parameters
Can be downloaded from
http://www.ogre3d.org
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
16
Introducing Particle Systems
to the Aquarium

Assume the following variable is defined:
SceneNode * mBubblesNode

Then create a ParticleSystem with the particle effect
Bubbles defined in EIE360/Bubbles

Create a scene node and attach the ParticleSystem to it
Ogre::ParticleSystem *bubblesParticle =
mSceneMgr->createParticleSystem(“Bubbles”,
“EIE360/Bubbles”);
mBubblesNode = mSceneMgr->getRootSceneNode()->
createChildSceneNode("BubblesNode"); //Node name
mBubblesNode->attachObject(bubblesParticle);
mBubblesNode->setPosition(Ogre::
Department of
17
ELECTRONIC AND INFORMATION ENGINEERING
Vector3(0,
-20, -50)); //Position of the bubbles
3. Particle Effects by Dr Daniel Lun
An example …
Department of
ELECTRONIC AND INFORMATION ENGINEERING
3. Particle Effects by Dr Daniel Lun
18