Crawling Particles Over a Mesh Surface Using XSI's ICE

(Click to Enlarge)(Click to Enlarge)Some time ago I was asked to work out a method for animating many thousands of characters across arbitrarilly complex surfaces. The solution turned out to be surprisingly simple but the nature of pre-7.0 particles made it a bit messy in practice so it seemed natural to have a stab at making it work in ICE.

A video of the animation can be found here


It turned out to be not only quicker to build but also much easier to slot into a workflow in a much more general way than we could in 6.5 because we can, if we wish, make it a part of the simulation cycle and modify what we've done further down the simulation - curve flow control, obstacle and flocking control, etc - and I've added some notes on various ways to do this at the end of the blog.

 

The Method.

  1. Take the particle position, P1, and its velocity, V1 and calculate point P' where the particle will be at the next iteration of the simulation.
  2. Find the point P2, the closest point to P' on the mesh we're crawling along.
  3. Recalculate the velocity V2 required to take the particle from it's current position P1 to the point P2 on he mesh, V2 = [P2-P1].
  4. Simulate.
  5. Goto 1.
Particle Placement on MeshParticle Placement on Mesh

The ICE Tree

Could not be simpler:

 (click to enlarge)(click to enlarge)

In the ICE tree above; at A, calculate what the particle position will be at the next iteration. Remember, velocity is units per second; since we need to position at the next frame we use a substep node to convert to units per frame. At B, find the closest point on the mesh at that position, finding the normal at the same time so we can align particles to the surface at the same time using this and the particle velocity as our alignment vectors and finally at C, calculatewhat the velcocity would need to be so the simulation step, outside of this compound, will place the particle at this new position on the mesh. Actual setting of the particle velocity is also done, along with any alignment, outside of this compound.

A Word About Why We Set Velocity Rather Than Position.

 Someone asked, why do we set the velocity rather than the particle position? Well, mostly the answer is, you can but it makes it difficult to use forces to control how our particles behave on the surface. If we just plop the particle down then any subsequent simulation step will move the particle off the surface. So by calculating the required velocity we keep the process within the simulation step. In fact calculating velocity isn't any extra overhead because we need it anyway; if we don't we can, and often do, end up going around a corner and finding our velocity is not longer pointing nicely along our surface so we have it anyway.Of course, if you don't care about particle control then by all means just position it and ditch the simulation node, but you must still keep and set the new velocity.

 What Next?

Direction control using curves to control flow of particles.

Self avoidance, obviously. They're all running through each other. Large crowds from a distance you can get away with it but for closer shots this needs looking at.

All the above works quite nicely for particles that stick and stay on the surface. You can use forces or aa velocity manipulator to control them to a fair degree but it's difficult to make them fall off the surface or make passing particles  stick and flow around the surface so I'll take a look at how we modify what we have so far to make this easier.