PhysX Collision Test

Path: Particle View > Click or add a PhysX Collision test. The PhysX Collision test is similar to the standard Collision test, but instead of allowing collisions between particles and Deflector space warps, it enables collisions between particles and standard objects applied with the PFlow Collision Shape modifier. Usage is similar to the Collision test, but some details differ due to the nature of physics simulation and the PhysX setup.

Note: Always place a PhysX test below the PhysX World operator in an event, otherwise the test cannot retrieve proper simulation information after a simulation integration step. Improper placement of a PhysX test results in deactivation of the PhysX World simulation; a message to that affect is logged in the MAXScript listener and also appears in the prompt area in the bottom of 3ds Max dialog.

Procedure

This procedure describes a simple usage of PhysX Collision to simulate an outer-space encounter between a ball and a bunch of blocks, inside a box.

  1. Open Particle View and drag a PhysX Flow from the depot to the window. PhysX Flow is an easy way to create a simple flow with all the elements necessary for physics simulation. In the Perspective viewport, you see a cubic array of blocks (cubic particles created by Birth Grid) and the PhysX World helper icon.

  2. In Event 01, click the PhysX World 01 operator and then on the PhysX World 01 rollout, click the => button.

  3. This selects the PhysX World helper and displays its parameters on the Modify panel.

  4. At the top of the Parameters rollout, turn off Apply Gravity.

  5. In the Perspective viewport, add a Box primitive that encompasses the blocks with room to spare; a cube of 150 units on a side should be about right. Center the box on the blocks.

  6. Convert the box to editable poly, select and delete the top polygon, and add a Shell modifier. Angle the view so you can see down into the box; it should resemble the following illustration:

  7. In the Front viewport, add a sphere of Radius=20 above the right side of the box. The Perspective viewport should now look like this:

  8. Go to frame 30, turn on Auto Key, and in the Front viewport, position the sphere just inside the bottom-left corner of the box, as shown:

  9. Play or scrub the animation. The ball should intersect the blocks as it travels; if not, adjust its path.

  10. Return to frame 0 and turn off Auto Key.

  11. Select the sphere and apply the PFlow Collision Shape (WSM) modifier.

  12. On the modifier Parameters rollout, set Shape to Sphere, and then click Activate.

  13. Select the box and apply the PFlow Collision Shape (WSM) modifier. Make sure the Shape option is set to Geometry, the default; if not, choose Geometry.

  14. Click Activate.
    The box and sphere are now equipped, thanks to the Collision Shape modifier, to collide with the particles inside the box.

  15. Back in Particle View, drag a PhysX Collision test to the bottom of Event 01.
    Click the test so its parameters appear in Particle View, and then, under the Deflectors list (currently empty), click By List.
    The Select Deflectors dialog opens, listing only the objects qualified to act as deflectors in PhysX Collsion: the box and sphere.

  16. Highlight the box and sphere entries in the list (Ctrl+A is one way) and then click Select.
    The box and sphere appear in the Deflectors list.
    Because in this example you won't be passing the particles to another event, you don't need Test True If Particle or any of its options.

  17. Play the animation.
    The sphere crashes through the array of particles, sending them scattering, bouncing off each other and the inside of the box. If you extend the animation length to 300 frames or so, you can see them start to fly out of the opening at the top of the box.

    Tip: If you want the ball to bounce around inside the box as well, delete the sphere geometry and re-create the ball as a spherical particle created with a Birth Stream operator in a separate event connected to the global event, and aim the birth stream icon at the particle array. Be sure to include PhysX Shape operator and an instance of the PhysX World operator in the second birth event. Instancing the PhysX World operator makes the PhysX Collision test global for both events, so you don't need to instance the test as well.

Interface

Deflectors - Lists the non-particle objects that serve as deflectors in the PhysX simulation. This is the main difference between the PhysX Collision test and the standard Collision — instead of using Deflector-type space warps, you specify geometry objects to which the PFlow Collision Shape modifier has been applied. The Deflectors list can contain only such objects. If a geometry object is not modified with PFlow Collision Shape, it cannot be considered as a deflector for the PhysX Collision test.

Another important difference is that PhysX Collision simulates collision for all particles in the simulation defined by a PhysX World operator — that is, particles in all events with a PhysX World operator associated with the same PhysX World driver. Regardless of the placement of PhysX Collision test in a particular event, if the test is in the same event as a PhysX World operator, the collision is done for all particles that are under control of that PhysX World operator's driver.

Add/By List/Remove - To add an object modified with PFlow Collision Shape to the simulation, click Add and then select the object, or, to add several at one time, use By List. To remove an object, highlight its name in the list and click Remove.

=> - To select an object assigned in PhysX Collision, highlight it in the list and then click this button. This selects the object in the scene and makes it easy to access the object parameters.

Test True If Particle group

The primary function of the PhysX Collision test is to define the scene geometry objects with which the particles the in simulation collide. Because the operator works as a test, you can also use it to redirect particles to the next event upon collision. The job of tracking which particles collide and when collisions occur requires additional CPU resources, so if you don't need the test for redirection (and you don't have a wire coming out of the test), turn off Test True If Particle.

Also, if Test True If Particle is off, it doesn't matter which event the test resides in, since it works on a global simulation level. If Test True If Particle is on, then all collisions of particles in the current event with the deflector are counted, and they are used to redirect particles to the next event at the right moment, as specified by other parameters in this group.

The Collides, Is Slow After Collision(s), Is Fast After Collision(s), and Collided Multiple Times options and controls are similar to those in the standard Collision test, but with a few differences:

  • The Collides option does not have a drop-down list to define the following particle velocity; during simulation a particle has to collide and further velocity is a result of a deflection, so it doesn't make sense to provide the choice of bounce, or stop, or continue. By definition, it's always a bounce.

  • The collisions are counted during the whole integration step. The test directs particles to the next event only after simulation of the integration step is completed. Effectively, a particle can collide multiple times during an integration step; it will be redirected to the next event if you use the Collides option. The particle, however, is not redirected to the next event immediately after its first collision; it is redirected as a fact of a collision during the integration step.

    Similarly, with the Collided Multiple Times option, a particle is redirected to the next event if during the integration step (and in previous frames cumulatively) if it collided with the deflector at least the specified number of times. And again, it's not redirected to the next event right away, at the moment it collides for the Nth time; it's redirected to the next event at the end of the integration step if the cumulative number of collisions exceeds the value in # Times spinner.

  • There is no Will Collide option.

Report To Data Operator - When using Particle Flow Tools Box#3, enable this option if you need the number-of-collisions data to be used by a Data Operator; you can use the Input PhysX sub-operator to retrieve these data in a Data Operator. Available when Test True If Particle is on. Typically you'd use this when the test is not wired to any following event.

Additive Count - When on, the reported data represent the total number of collisions a particle had while present in the current event. When off, the test reports only the number of collisions a particle experienced during the last integration step. Available only when Report To Data Operator is on.

Collision Group - Use this setting for collision exclusions, as explained in the PhysX World Helper topic.