The Collision Engine
This page gives some more details about how collisions are handled within X-Particles. You may find it helpful to read this when selecting collision options in the emitter and collider tag.
- Basic use
- Objects particles can collide with
- The effect of particle radius
- Spawned particle direction
- Particle-particle collision
The collision engine in versions 2 and 3 of X-Particles is much faster and more accurate than in version 1. Among other things, the risk of particle leakage through a surface is very small, and you can use the collision engine to move particles over a surface they collide with.
Collisions in X-Particles are divided into two types:
- collisions between particles and scene objects
- collisions between particles emitted from the same or another emitter (particle-particle collisions)
You can select either or both of these, so you can have both types of collision enabled, both disabled, or only one of them enabled. They are handled quite separately.
Collisions between particles and scene object
To detect collisions, you need to do the following things:
- select the object(s) you want the particles to collide with and add a Collider tag to each one
- change any of the settings in the Collider tag, as required (the defaults are fine to start with)
- adjust the particle 'Radius' setting in the emitter if required
Then just play the animation and adjust the emitter and/or tag settings as needed.
Objects particles can collide with
Particles can only collide with polygon objects. They will collide with ordinary polygon objects, Cinema 4D primitive objects, Extrude and other C4D generator objects. They will not collide with splines, or generators such as Array or Cloner objects. If you want to collide with objects like that, you can do one of the following:
- make the object editable (not always desirable, of course)
- do a Current State to Object command on the generator and put the collider tag on the resulting polygon object (which you can make invisible if needed); remember also to do Connect and Delete on the polygon object if necessary, because generators such as the Cloner will produce several different polygon objects when made editable
- add the Cloner to a Connect object and put the collider tag on the Connect object instead of the Cloner
If you want to collide with an object in a Subdivision Surfaces (SDS) object, place the tag on the SDS object, not the child object of the SDS object. If you put the tag on the child object, you will still get collisions but with the original surface, not the smoothed surface generated by the SDS object.
Very importantly, an object which is invisible in the scene can still be used as a collider object. So you can make a converted object invisible to both editor and renderer, and it will appear as if the particles are colliding with the original object.
The effect of particle radius
Collision engines such as that found in Cinema 4D's Dynamics are based on polygon to polygon intersections - collisions between the polygons of the objects are detected. This is mathematically intensive and time-consuming, and is therefore impractical (and usually unnecessary) for particle systems potentially involving thousands or millions of particles.
In the X-Particles collision engine, each particle is, in effect, surrounded by an invisible sphere, the size of which is determined by the Radius setting in the emitter. The collision engine looks for the intersection of this sphere with the object surface. This is necessary because the particle itself is of infinitely small size. If the engine tried to detect an intersection of the exact particle location with a polygon, some collisions would be missed and particle 'leakage' would occur. You can test this by setting the particle radius to zero, which will cause significant leakage of particles on collision.
The particle radius is initially set at an arbitrary value of 1 screen unit. This gives good accuracy when determining the intersection of the particle with the surface, but there is a possible risk of leakage. If you do get particles leaking through the surface, try increasing the radius value. You may also need to increase the radius if each particle is associated with a large generated object and you wish to prevent interpenetration of the particle object with the scene object.
The collision engine in X-Particles is fine for bouncing particles off screen objects and/or other particles. For more precise collisions involving small numbers of particles, you can consider using Cinema 4D's inbuilt Dynamics system instead. Details of how to use X-Particles with dynamics can be found on this page.
Spawned particle direction
If you spawn particles on collision, you can choose between various settings for the direction of the spawned particles. Some are quite clear, but the two which can be confused are 'Source Particle' and 'Face Normal'. Figure 1 shows the difference between the two.
When a particle hits an object, it bounces off at an angle which depends on the angle at which the particle hit the face of the object. When 'Source particle' is chosen as the direction, the spawned particles travel along the same direction as the source particle - subject to any variation added by the Spread setting in the Collider tag.
In contrast, in this mode the spawned particles travel in a different direction to the source particle. Instead, they travel along the direction of the normal of the face which was hit by the source particle. This can be visibly different from the source particle's new direction.
Which method to choose?
At first glance it seems obvious that the Source particle direction would be preferred. But what happens when a bullet hits a stone wall? Do the fragments of stone which are produced travel in any direction, or predominantly along the direction of the ricocheting bullet, or directly away from the wall? (I don't know the answer to that question, by the way!) But this is a case when its up to you to choose which is best for your scene. Try them both, play with the Spread setting (and also add in some bounce variation in the collider tag and maybe some speed and lifespan variation in the spawning emitter), and see which looks best to you.
You can also detect collisions between the particles themselves (those emitted from the same emitter or different emitters). You DO NOT need a Collider tag for this. Instead, you will need to add a Particle-Particle Collisions object to the scene. Please see that page in the manual for details.
Alternatively, you can use the Constraints object for particle-particle collisions. This has the advantage of being much faster than the Particle-Particle Collisions object, but has few parameters that you can set. It may be all you need, however, in many situations.