Accessing the Emitter Property

To get the emitter property (EmissionProp) you need to go through the input ports of the ParticlesOp.

1. If you don’t already have a pointer to the particle cloud you can find it from the Scene_Root using the siCloudPrimType value with the X3DObject.FindChild method:

// JScript
var pcloud = ActiveSceneRoot.FindChild( "", siCloudPrimType );
var cprim = pcloud.ActivePrimitive;

// C++
Application app;
   Model root = app.GetActiveSceneRoot();

ParticleCloud pcloud( root.FindChild(L"", siCloudPrimType, CStringArray()) );
ParticleCloudPrimitive cprim = pcloud.GetActivePrimitive();

2. Using the operator stack (ConstructionHistory) you can enumerate over the operators to find the simulation operator under the particle cloud:

var op;
var opstack = new Enumerator( cprim.ConstructionHistory );
for ( ; !opstack.atEnd(); opstack.moveNext() ) {
       if ( opstack.item().Name == "ParticlesOp" ) {
       op = opstack.item();
       break;
   }
}

3. Once you have the simulation operator you can query its input ports to find the emission property using the SIObject.Type property on the value returned from the Port.Target2 property:

var eprop;
if ( op != null ) {
   for ( var i=0; i<op.InputPorts.Count; i++ ) {
       if ( op.InputPorts(i).Target2 != null
              && op.InputPorts(i).Target2.Type == "EmissionProp" ) {
          // Get the EmissionProp nested under the particle operator
          // and exit the loop
          eprop = op.InputPorts(i).Target2;
       }
   }
}

 

You can use the same method to access forces, obstacles and goals nested under the particle operator:

• For forces, look for the force type (fan, drag, vortex, etc.) instead of EmissionProp.

• For obstacles, look for ObstacleProp instead of EmissionProp.

• For goals, look for ParticleGoal instead EmissionProp.