Accessing the Components of the Particle System

Particle Simulator Operators

The simulation operator is an Operator, available via the Primitive.ConstructionHistory property on the ParticleCloudPrimitive object.

| For the C++ API, you have to use the CComAPIHandler to browse the ConstructionHistory—see Navigating the Operator Stack/Construction History. For an example of navigating inside a particle cloud (including how to get the simulation operator), see Accessing the Emitter Property .

Particle Clouds

The ParticleCloud object parents the ParticleCloudPrimitive, which is a specialized kind of Primitive. You can access the ParticleCloudPrimitive via the X3DObject.ActivePrimitive property or X3DObject::GetActivePrimitive C++ API function from the ParticleCloud object.

In the object model, the ParticleCloudPrimitive gives you access to the ParticleCollection which you can enumerate to get specific Particle objects and access particle data across the entire collection. The C++ API does not use a separate interface to access all Particle data in the cloud: this functionality is available directly from the ParticleCloudPrimitive class.

| The ParticleCloudPrimitive also gives you access to the operator stack which is the doorway to the rest of the components of the particle cloud outside Particle Events. The ParticleCloudPrimitive is one of the pieces of data accessible from inside a particle event script, along with an array of indices identifying the particles that triggered the event and the frame number of the simulation at the time the event was triggered.

You can create a ParticleCloud object using the X3DObject.AddParticleCloud method or via the CreateParticleCloud command.

Particle Emitters

You can access the particle emitter’s X3DObject and Property set using the procedure described in Accessing the Emitter Property.

| The emitter object and its property set are not directly accessible from the particle cloud or its primitive when writing scripted Particle Events.

Particle Types

The ParticleType object is available via:

• the ParticleCloudPrimitive.ParticleTypes property in the object model and the ParticleCloudPrimitive::GetParticleTypes function in the C++ API

• enumerating the children of the emission property to which it is attached—see Accessing the Particle Type Property under the Emitter Property for more information

You can create new particle types using the CreateParticleType command (see What is an ISIVTCollection? for information about working with this special type of collection).

Particle Attributes

ParticleTypes may define special custom parameters called ParticleAttributes. Particle Attributes can be created either through the UI or through scripting from the ParticleType object via the ParticleType.AddAttribute method or the AddUserParameter command). However, they can only be retrieved through scripting via the Particle.Attributes property (see Adding and Accessing User Parameters and Particle Attributes) or, using the C++ API, with Particle::GetAttributes.

Particle Events

ParticleTypes also manage Particle Events, which are essentially events that are triggered when some condition or state is reached. For example, when a particle reaches a certain age, it may die or split or turn green. Another typical particle event is when a particle collides with another object or comes within a certain distance of a goal, etc. XSI supplies several preset events, but you can also run a custom JScript or VBScript routine when the event is triggered (called a scripted particle event).

Particle Events themselves are not accessible through the object model. However, if you’re really determined, there are two ways to get them depending on what you need them for:

- To access an event that’s used by a particle cloud you can get them through the particle type that they’re attached to (see Accessing the Particle Event Property under its Particle Type).

or

- To access an event from the particle types container (Particle Types scope in the Explorer) you can use the omni-purpose GetValue or the Dictionary.GetObject method on the container, which returns a Property object:

           // VBScript
           set pevent = GetValue("ParTypes.<PType_name>.<PEvent_name>")
           set pevent = Dictionary.GetObject("ParTypes.<PType_name>.<PEvent_name>")

           // JScript
           var pevent = GetValue("ParTypes.<PType_name>.<PEvent_name>");
           var pevent = Dictionary.GetObject("ParTypes.<PType_name>.<PEvent_name>");

Particle Shaders

Natural forces and obstacle objects also affect the particle simulation, but are not directly part of the particle system’s structure.

There are some shader presets for particles available in XSI:

- Click the Sim PTypes tab on the Shader Presets shelf (Toolbars > Shader Presets under the View menu).