Public Member Functions

ParticleObject Class Reference

This reference page is linked to from the following overview topics: Particle System Plug-ins, Plug-in Base Classes, Deformable Objects.


Search for all occurrences

Detailed Description

This is the base class for creating particle system plug-ins.

Many particle systems may be derived from class SimpleParticle instead of this class. See Class SimpleParticle for more details. Note: This class is derived from GeomObject and still has GEOMOBJECT_CLASS_ID as its super class. To determine if an object is a ParticleObject, call: Animatable::GetInterface() with the ID I_PARTICLEOBJ or use the macro: GetParticleInterface(anim) where anim is the object in question. This will return a ParticleObject* or NULL. See Class Animatable . Note: See the method Animatable::GetProperty() for details on choosing the method used to evaluate the particle system during motion blur rendering.

See also:
Class Animatable, Class GeomObject, Class ForceField, Class CollisionObject, Class ShadeContext

#include <object.h>

Inheritance diagram for ParticleObject:
Inheritance graph
[legend]

List of all members.

Public Member Functions

BOOL  IsParticleSystem ()
virtual void  ApplyForceField (ForceField *ff)=0
  This method is called to add the force field object passed to the list of force field objects operating on this particle system.
virtual BOOL  ApplyCollisionObject (CollisionObject *co)=0
  This method is called to add the collision object passed to the list of collision objects operating on this particle system.
int  IsDeformable ()
  Implemented by the System.
BOOL  CanCacheObject ()
  Implemented by the System.
virtual BOOL  NormalAlignVector (TimeValue t, Point3 &pt, Point3 &norm)
  Implemented by the System.
virtual Point3  ParticlePosition (TimeValue t, int i)
  Returns the position of the specified particle in world space at the time passed.
virtual Point3  ParticleVelocity (TimeValue t, int i)
  Returns the velocity of the specified particle at the time passed (in 3ds Max units per tick).
virtual float  ParticleSize (TimeValue t, int i)
  Returns the world space size of the specified particle in at the time passed.
virtual int  ParticleCenter (TimeValue t, int i)
  Returns a value indicating where the particle geometry (mesh) lies in relation to the particle position.
virtual TimeValue  ParticleAge (TimeValue t, int i)
  Returns the age of the specified particle -- the length of time it has been 'alive'.
virtual TimeValue  ParticleLife (TimeValue t, int i)
  Returns the life of the particle -- the length of time the particle will be 'alive'.
virtual BOOL  HasConstantTopology ()
  If a particle system has a fixed number of particles of fixed topology, then it can return TRUE for this method, and the renderer will then compute the image motion blur velocities based on the vertex motions, giving motion blur for rotating particles etc.

Member Function Documentation

BOOL IsParticleSystem ( ) [inline, virtual]

Reimplemented from Object.

{return TRUE;}
virtual void ApplyForceField ( ForceField ff ) [pure virtual]

This method is called to add the force field object passed to the list of force field objects operating on this particle system.

Parameters:
ff Points to an instance of a ForceField object.
Sample Code:
    void SimpleParticle::ApplyForceField(ForceField *ff)
    {
        fields.Append(1,&ff);
    }

Implemented in SimpleParticle.

virtual BOOL ApplyCollisionObject ( CollisionObject co ) [pure virtual]

This method is called to add the collision object passed to the list of collision objects operating on this particle system.

Parameters:
co Points to an instance of a collision object.
Returns:
If a particle does not support this method it should return FALSE; otherwise return TRUE.
Sample Code:
    BOOL SimpleParticle::ApplyCollisionObject(CollisionObject *co)
    {
        cobjs.Append(1,&co);
        return TRUE;
    }

Implemented in SimpleParticle.

int IsDeformable ( ) [inline, virtual]

Implemented by the System.

This method returns TRUE to indicate it is deformable. A particle object is deformable, but does not let itself be deformed using the usual GetPoint() / SetPoint() methods. Instead a space warp must apply a force field to deform the particle system.

Reimplemented from Object.

{return TRUE;} 
BOOL CanCacheObject ( ) [inline, virtual]

Implemented by the System.

This method returns FALSE to indicate the object cannot be cached. Particle objects don't perform a shallow copy and therefore cannot be cached.

Reimplemented from Object.

{return FALSE;}
virtual BOOL NormalAlignVector ( TimeValue  t,
Point3 pt,
Point3 norm 
) [inline, virtual]

Implemented by the System.

This method is inherited from Class Object. This is a default implementation provided for particle systems.

Parameters:
t The time to compute the normal align vector.
pt The point of intersection.
norm The normal at the point of intersection.
Returns:
TRUE if this method is implemented to return the normal align vector; otherwise FALSE.

Reimplemented from Object.

{pt=Point3(0,0,0);norm=Point3(0,0,-1);return TRUE;}
virtual Point3 ParticlePosition ( TimeValue  t,
int  i 
) [inline, virtual]

Returns the position of the specified particle in world space at the time passed.

The Particle Age texture map and the Particle Motion Blur texture map use this method.

Parameters:
t The time to return the particle position.
i The index of the particle.
Note:
When a texture map calls these methods, the particle index i is passed to the texmap in the data member ShadeContext::mtlNum. The particle systems encode the index of the particle associated with the face of the particle mesh being shaded into the mtlNum. For instance, once the particle system generates a mesh to be rendered, every face of the mesh corresponds to a particle. This isn't a one-to-one correspondance because there are more faces than particles (if the particles are represented as tetrahedrons there are four faces per particle). When a texture map or material that is shading a mesh generated by a particle system wants to know which particle the face is associated with it gets this info out of the ShadeContext::mtlNum. For example, here is a fragment of the code from the Particle Age texture map where it evaluates the color of the point being shaded:
    AColor PartAgeTex::EvalColor(ShadeContext& sc)
    {
        ...
    // Evaluate...
        Object *ob = sc.GetEvalObject();
        if (ob && ob->IsParticleSystem()) {
            ParticleObject *obj = (ParticleObject*)ob;
            TimeValue t = sc.CurTime();
            TimeValue age = obj->ParticleAge(t,sc.mtlNum);
            TimeValue life = obj->ParticleLife(t,sc.mtlNum);
            ...etc.
        }
    } 
{return Point3(0,0,0);}
virtual Point3 ParticleVelocity ( TimeValue  t,
int  i 
) [inline, virtual]

Returns the velocity of the specified particle at the time passed (in 3ds Max units per tick).

This is specified as a vector. The Particle Age texture map and the Particle Motion Blur texture map use this method.

Parameters:
t The time to return the particle velocity.
i The index of the particle.
{return Point3(0,0,0);}
virtual float ParticleSize ( TimeValue  t,
int  i 
) [inline, virtual]

Returns the world space size of the specified particle in at the time passed.

The Particle Age texture map and the Particle Motion Blur texture map use this method.

Parameters:
t The time to return the particle size.
i The index of the particle.
{return 0.0f;}
virtual int ParticleCenter ( TimeValue  t,
int  i 
) [inline, virtual]

Returns a value indicating where the particle geometry (mesh) lies in relation to the particle position.

This is used by Particle Motion Blur for example. It gets the point in world space of the point it is shading, the size of the particle from ParticleSize(), and the position of the mesh from ParticleCenter(). Given this information, it can know where the point is, and it makes the head and the tail more transparent.

Parameters:
t The time to return the particle center.
i The index of the particle.
Returns:
One of the following: PARTCENTER_HEAD The particle geometry lies behind the particle position. PARTCENTER_CENTER The particle geometry is centered around particle position. PARTCENTER_TAIL The particle geometry lies in front of the particle position.
{return PARTCENTER_CENTER;}
virtual TimeValue ParticleAge ( TimeValue  t,
int  i 
) [inline, virtual]

Returns the age of the specified particle -- the length of time it has been 'alive'.

The Particle Age texture map and the Particle Motion Blur texture map use this method.

Parameters:
t Specifies the time to compute the particle age.
i The index of the particle.

Reimplemented in SimpleParticle.

{return -1;}
virtual TimeValue ParticleLife ( TimeValue  t,
int  i 
) [inline, virtual]

Returns the life of the particle -- the length of time the particle will be 'alive'.

The Particle Age texture map and the Particle Motion Blur texture map use this method.

Parameters:
t Specifies the time to compute the particle life span.
i The index of the particle.
{return -1;}
virtual BOOL HasConstantTopology ( ) [inline, virtual]

If a particle system has a fixed number of particles of fixed topology, then it can return TRUE for this method, and the renderer will then compute the image motion blur velocities based on the vertex motions, giving motion blur for rotating particles etc.

If the particle system is topology-varying it should return FALSE.

{ return FALSE; }

ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject
ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject ParticleObject