Class CollisionObject

3DS Max Plug-In SDK

Class CollisionObject

See Also: Class Point3.

class CollisionObject : public InterfaceServer

Description:

A collision object can be applied to a particle system by a Space Warp. The collision object checks a particle's position and velocity and determines if the particle will collide with it in the next dt amount of time. If so, it modifies the position and velocity.

Methods:

Prototype:

virtual BOOL CheckCollision(TimeValue t,Point3 &pos,

Point3 &vel, float dt, int index, float *ct=NULL, BOOL UpdatePastCollide=TRUE)=0;

Remarks:

Implemented by the Plug-In.

This method checks a particles position and velocity to determine if there was be a collision between the particle and this collision object. If there was a collision, the particles position and velocity should be modified.

The plug-in may compute a line segment between where the particle is now, and where it will be in dt amount of time. The plug-in then checks if the line segment intersects the collision object. If so, it would compute the resulting position, and modify the velocity vector vel to point in the new direction (presumably reflected across the surface normal).

3ds max 3.0 introduced interparticle collision (where particles may collide with other particles). In order to implement interparticle collision (IPC) in the presence of collision objects, it became necessary to generalize the operation of the deflectors so that they didn't always work in discrete time intervals.

That is, in the general case of an unidentified number of particles interacting in an unspecified way, it was necessary to allow everything involved in that system to update to specified times without moving past that time.

In the absence of IPC enabled, the particle system calls the bound collision objects with the parameter UpdatePastCollide == TRUE, and the deflector checks all collisions, updates particles based on their collisions with deflectors and the ensuing, remaining time intervals in dt subsequent to the collisions.

In the presence of IPC that won't work. When IPC is active, all particles need to be updated to the time of the first collision in the system in dt, whether that collision be between particles or between particles and deflectors. Thus, in the presence of IPC, all particle updates to bound deflectors are called with UpdatePastCollide == FALSE. In that case, the collision objects return both the position and velocity of the updated particles and the time at which the collision occurred.

All such times are compared, along with all possible internally calculated IPC event times. If there are any nonnegative times returned greater than or equal to zero, all particle states are reverted to their states at the beginning of the interval and then updated to the precise minimum time returned as the earliest collision. And then everything starts up again trying to update itself to the next integral time, when control can pass back to whatever is asking the particles to update themselves. If there are other collisions in that time, it happens again.

This whole set of operations happens after any true returns from the trilinear sort/sweep correlator that looks for the possibility of collisions. If there are no possible collisions, everything proceeds through a complete interval normally.

Parameters:

TimeValue t

The time to check for collision.

Point3 &pos

The position of the particle to check and potentially modify.

Point3 &vel

The velocity vector of the particle to check and potentially modify.

float dt

This is an increment of time - the step size. The method checks if the particle will collide in this amount of time.

int index

This parameter is available in release 2.0 and later only.

The index of the particle being collided.

float *ct=NULL

This parameter is available in release 3.0 and later only.

An array of floating point times at which the collisions occurred.

BOOL UpdatePastCollide=TRUE

This parameter is available in release 3.0 and later only.

This is a flag to tell the collision object to update the particle past the collision to the remainder of input dt or to output the state of the particle at the collision. In the presence of interparticle collision enable, we have to update to the times of collisions and then retest from there. See the Remarks.

Return Value:

TRUE if there was a collision and the position and velocity have been modified; otherwise FALSE.

Prototype:

virtual Object *GetSWObject()=0;

Remarks:

This method is available in release 3.0 and later only.

This method provides a way of identifying the 'parent' Deflector for a CollisionObject available to a particle system. This must be implemented by all Deflectors. It returns the object pointer to the Deflector from which the Collision object is derived.