Project 2: Basic particle system Constrained Particle System - - PowerPoint PPT Presentation

project 2
SMART_READER_LITE
LIVE PREVIEW

Project 2: Basic particle system Constrained Particle System - - PowerPoint PPT Presentation

Requirements Project 2: Basic particle system Constrained Particle System Tinkertoys Requirements for Particle system particle system Implement following components Particle structure The particle system is attached to a


slide-1
SLIDE 1

Project 2:

Constrained Particle System

Requirements

  • Basic particle system
  • Tinkertoys

Particle system

  • Implement following components
  • Particle structure
  • Force structure
  • ODE solver
  • Particle system that has accesses to particles,

forces, and an instance of ODE solver

Requirements for particle system

  • The particle system is attached to a node of your

hierarchical model other than the root node

  • There are at least two distinctive forces acting on the

particle system. For example, gravity and spring forces

slide-2
SLIDE 2

Skeleton code

  • Provide high level particle system structure in

ParticleSystem class

  • A Euler step is executed every time

ParticleSystem::computeForcesAndUpdateParticles() is called from ModelerView::draw()

  • ODE solver is called from

computeForcesAndUpdateParticles()

ParticleSystem

  • constructor, destructor, and etc.
  • computeForcesAndUpdateParticles()
  • drawParticles()
  • startSimulation()
  • stopSimulation()

Other structures

  • Particle class
  • Force class
  • An elegant implementation would include a

generic force class and a variety of distinct forces that inherit from it

Other structures

  • ODE solver
  • Ideally, ODE solver should be independent from

the particle system

  • Particle system instantiates an ODE solver and

keeps the pointer as a data member

  • When an ODE solver is created, a void pointer

that points to the particle system is passed to the ODE constructor

slide-3
SLIDE 3

Embedding in animation system

  • Store particles as coordinates in world space
  • Attach a particle emitter to a node in the model

hierarchy

  • need to calculate the world coordinates of the

particle emitter every time a particle is spawned

  • glGetFloatv(MODELVIEW_MATRIX, m)

Tinkertoy

  • Extend the basic particle system with constraints
  • Implement following two types of constraints
  • Constraint that keeps the bead on the circle
  • Constraint that keeps two particles at a fixed

distance apart from each other

Requirements for Tinkertoys

  • Implement a particle that is constrained to move

along a circle

  • Implement a second particle that is kept a fixed

distance apart from the particle on the circle

  • Simulate the particles under the gravity and the

interactive force applied using the mouse

  • Experiment the coefficients for the constraint

feedback

Skeleton code

  • There is no skeleton code for this part of the

assignment

slide-4
SLIDE 4

Where do you start?

  • Draw a circle on the screen
  • Rewrite robotarm.cpp by taking out all the

controls and drawing a 2D circle on the screen

  • Define global structures in ParticleSystem
  • Need to allocate space for structure such as

Jacobian matrix

Constraints

  • Implement constraints in a similar way as forces
  • Define a base class for constraints and inherit

from it when you implement each specific type of constraints

  • Number your constraints and particles so you can

index them easily

Jacobian matrix

  • 2D array
  • VL matrix class
  • Sparse matrix

n blocks m blocks xj xk Ci

Solving constraint forces

  • Build a linear system
  • Loop over each constraint to evaluate the

constraint function and its various derivatives

  • Solve the final linear system by
  • computing the inverse matrix
  • using linear system solvers provided by VL
slide-5
SLIDE 5

VL: Vector library

  • VL provides a set of vector and matrix classes, as

well as a number of functions for performing arithmetic with them

  • Most arithmetic operators and functions for vectors

and matrices are supported (+, -, *, /, dot(), len(), cross(), trans(), inv(), etc)

  • VL also provides two linear system solvers:

SolveOverRelax() and SolveConjGrad()

  • Include “VLd.h” in your code

Hooking up to basic particle system

  • Constraint forces are calculated after ordinary forces

and before updating the derivative of the current state

  • Everything happens in

computeForcesAndUpdateParticles()

Mouse interaction

  • Each time the mouse button and the shift key are

pressed at the same time, find the particle closest to the mouse and apply the force directly on that particle

  • Apply an attractive spring force between the particle

and the mouse until the button is released

  • Add code in ModelerView::handle() to catch the

event when left button and the shift key are pushed

  • Create and delete “mouse forces” on the fly

Experiments

  • Add feedback term to the constraint acceleration
  • Play with the coefficients ks and kd to find the
  • ptimal values
  • Do these experiments from the UI, instead of

recompiling the entire code every time you change the coefficients

¨ C = −ksC − kd ˙ C

slide-6
SLIDE 6

Bells and whistles

  • Implement additional types of constraints
  • Constraints that output more than one scalar
  • Initialize the velocity of particles
  • Helicopter with a cannon launching packages out

Bells and whistles

  • Realistic looking particles
  • Billboard technique
  • Alpha blending

Bells and whistles

  • Implement a more sophisticated ODE solver
  • Adaptive step size
  • Midpoint method
  • 4th order Runge-Kutta methd
  • Implicit Euler’s method

Bells and whistles

  • Implement collision detection
  • Provide control of the restitution constant
  • Allow particles to bounce off each other
  • Create an interactive billboard game
slide-7
SLIDE 7

Bells and whistles

  • Add flocking behaviors to simulate creatures moving

in flocks, herds, or schools

  • Simulate complicated interaction between the

character and the particles

  • Design a set of tools to build arbitrary tinkertoys on

the fly

  • building blocks: beads, rings, sticks, springs, etc.

Bells and whistles

  • Create a chain reaction machine
  • You might need to implement a rigid body

simulator

  • Cloth simulation
  • Read the literature in this area first

Introduce: monstrous bell Introduce: monstrous bell

=

slide-8
SLIDE 8

Demos