building a particle system

24
Building a Particle System References: 1. Gamasutra article by Van d er Berg 2. Particle System API by McA llister 3. Explosion.c

Upload: abrial

Post on 22-Jan-2016

29 views

Category:

Documents


0 download

DESCRIPTION

Building a Particle System. References: 1. Gamasutra article by Van der Berg 2. Particle System API by McAllister 3. Explosion.c. Particle System (PS) Gallery. Performance and Requirement. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Building a Particle System

Building a Particle System

References:1. Gamasutra article by Van der Berg2. Particle System API by McAllister3. Explosion.c

Page 2: Building a Particle System

Fall 2009 2

Particle System (PS) Gallery

Page 3: Building a Particle System

Fall 2009 3

Page 4: Building a Particle System

Fall 2009 4

Page 5: Building a Particle System

Fall 2009 5

Page 6: Building a Particle System

Fall 2009 6

Page 7: Building a Particle System

Fall 2009 7

                                                                                     

Page 8: Building a Particle System

Fall 2009 8

Page 9: Building a Particle System

Fall 2009 9

Page 10: Building a Particle System

Fall 2009 10

Performance and Requirement

Keep in mind: a PS greatly increases the number of polygon per frame (one particle: four vertices & 2 triangles)Perform as few memory operations (allocation/release) as possible Use a flag to mark a particle dead or respawn

Ability to link PS within the hierarchy of other geometry (smoke out of a cigarette)

Page 11: Building a Particle System

Fall 2009 11

Data Structure

Reference 1 contains all other detailsReference 1 contains all other details

Page 12: Building a Particle System

Fall 2009 12

Explosion

A simple particle system demo for explosion effects (particles and debris)Observe how particle evolves and how debris rotates

Page 13: Building a Particle System

Fall 2009 13

Particle System API (McAllister)

API used in some academic projectsDesign modeled after OpenGLDesign goals: Run-time efficiency Flexibility: create effects from simple

building blocks (gravity, bounce, …) Scalable simulation quality Easy to learn

Page 14: Building a Particle System

Fall 2009 14

API Description

Particle Position Velocity Color Alpha Size Age Secondary position Secondary velocity

Particle group A set of particles acted

upon by the same forces API applies to the

current group

Action Functions modify the

attributes of particles in the current group

Currently has 27 actions (some are physically related)

Building blocks for special effects

Page 15: Building a Particle System

Fall 2009 15

Actions in Use

ActionList Actions compiled (si

milar to displaylist)

Page 16: Building a Particle System

Fall 2009 16

Attributes and Domains

API state (color, velocity, size, …)pSource: create new particles

Domain: a uniform mechanism for specifying a region of three-space

pColorD: a region of color space

pVelocityD: a region of vector space

A variety of shapes: PDSphere, PDPlane, …

Specified by 9 or fewer floats

Page 17: Building a Particle System

Fall 2009 17

Particle Simulation

Newton’s lawUse Euler’s method with user-specified step size dt

Page 18: Building a Particle System

Fall 2009 18

Design a PS that suits your needs

Starting posBreaking posTimeline: ADSR envelopeColor attributesRendering styleDynamics

Page 19: Building a Particle System

PAPI (v.210)

You need VC80!Uses freeglut

Page 20: Building a Particle System

Fall 2009 20

Particle Data Structure

Page 21: Building a Particle System

Fall 2009 21

Example: ParticleContext_t PGenParticleGroups

P_group_count Max_particles (similar to display list)

CurrentGroup Current particle group all

actions and commands apply

SetMaxParticlesGetGroupCount

# of particles in the groupGetParticlePointer

Expose internal storage of particles (avoid copying for higher performance)

Page 22: Building a Particle System

Fall 2009 22

GetParticlePointer

Page 23: Building a Particle System

Fall 2009 23

ParticleContext_t P

GravityMove (vel, rotvel)

Update pos, orient (up vector)

P.Source (rate, dom) Particles to add per unit

timeP.Sink (inOrOut, dom)

Kill particles w.r.t dom

Bounce (friction, resilience, cutoff, dom)

Sphere, rectangle, triangle disc, plane

Color (rgb); Color(dom)

Translate pos into color

Velocity (dom) …

Page 24: Building a Particle System

Fall 2009 24

pDomain

Blob, Box, Cone, Cylinder, Disc, Line, Plane, Point, Rectangle, Sphere, Triangle