Interface: MaterialHolder

The MaterialHolder Interface is exposed by the Event Helper class.

It provides access to the particles' materials.

Available in 3ds Max 2014 and higher.

Methods:

<boolean><PF_Event>.isMaterialHolder()

Returns True if a material is assigned to the Event via any of the Particle Flow Material operators.

Returns False if no material is assigned (even if a Material operator exists, but no valid material is assigned to it).

<boolean><PF_Event>.inheritsMaterial()

Returns True if the Event inherits a material from higher up in the flow, for example if the Material operator is assigned to the global PF_Source event, or if the Event has no material (neither in the Event nor in the global PF_Source event).

Returns False if the Event does not inherit its material because the Material operator is in the Event itself.

<material><PF_Event>.getMaterial()

Returns the material associated with the Event, either through a local Material operator, or inherited from a global Material operator.

<boolean><PF_Event>.setMaterial <material>material

Assigns a material to the Event. The material will only be used if the Event does not contain a Material operator.

After assignment, the Particle Flow must be turned off and on again for the new material to take effect.

The .getMaterial() method will NOT return the material if assigned via .setMaterial() , it will return undefined instead.

<integer><PF_Event>.getMaterialPriority()

Returns the material priority.

<integer><PF_Event>.getStreamDepth()

Returns the stream depth of the Event within the flow.

For example, if the Event is directly connected to the PF_Source, the return value will be 1. If the Event is connected to the initial event, the return value will be 2 and so on.

If an event is not connected, the return value will be 0.

<boolean><PF_Event>.updateMaterial <boolean>doReport

Updates the material and returns True if the material of the current event has been updated, False if it was already updated.

If the argument is passed as True, a pop up message will report the state of the Event's material.

<integer><PF_Event>.updateMaterials <boolean>doReport

Updates all materials in all Events in the flow the PF_Event is part of.

If the argument is passed as True, a pop up message will report the state of the Event's material.

Returns the number of Events whose materials have been updated, or 0 if all materials were already updated.

<integer><PF_Event>.updateMaterialsDownstream <boolean>doReport

Updates all materials in all downstream Events of the flow the PF_Event is part of.

If the argument is passed as True, a pop up message will report the state of the Event's material.

Returns the number of Events whose materials have been updated, or 0 if all materials were already updated.

EXAMPLES AND RESULTS

   pf = PF_Source() --Create a PF Source
   --> $PF_Source:PF Source 001 @ [0.000000,0.000000,0.000000]
   ne = Event() --Create an Event
   --> $Event:Event 001 @ [0.000000,0.000000,0.000000]
   particleFlow.beginEdit() --Disable automatic encapsulation
   --> OK
   b = Birth() --Create a Birth operator
   --> $Birth:Birth 001 @ [0.000000,0.000000,0.000000]
   rnd = RenderParticles() --Create a Render operator
   --> $Render:Render 001 @ [0.000000,0.000000,0.000000]
   mtl = Material_Static() --Create a Material Static operator
   --> $Material_Static:Material Static 001 @ [0.000000,0.000000,0.000000]
   shp = ShapeLibrary() --Create a Shape operator
   --> $Shape:Shape 001 @ [0.000000,0.000000,0.000000]
   pos = Position_Icon() --Create a Position Icon operator
   --> $Position_Icon:Position Icon 001 @ [0.000000,0.000000,0.000000]
   dis = DisplayParticles Type:6 Color:white--Create a white Display operator set to Geometry 
   --> $Display:Display 001 @ [0.000000,0.000000,0.000000]
   particleFlow.endEdit() --Enable automatic encapsulation
   --> OK
   pf.appendAction rnd --Add the Render operator to the PF Source
   --> true
   ne.appendAction b --Add the Birth operator to the Event
   --> true
   ne.appendAction pos --Add the Position Icon operator to the Event
   --> true
   pf.appendAction shp --Add the Shape Icon operator to the PF Source
   --> true
   pf.appendAction dis --Add the Display operator to the PF Source
   --> true
   pf.appendInitialActionList ne --Wire the Event to the PF Source as initial action list
   --> true

   ne.isMaterialHolder() --Check to see if the Event is a material holder - it is not
   --> false
   ne.appendAction mtl --Add the Material Static to the Event
   --> true
   ne.isMaterialHolder() --Check again if the Event is a material holder - still not
   --> false
   mtl.setmaterial (standard diffusecolor:red name:"RedMat") --Assign a Red material
   --> true
   ne.isMaterialHolder() --Check again if the Event is a material holder - now it is!
   --> true
   ne.getMaterial() --Get the Event's material
   --> RedMat:Standard
   ne.activate false --Turn off the Event...
   --> OK
   ne.activate true -- ...and turn it on again to force an update
   --> OK
   --RENDERING at this point will produce RED particles
   --based on the color of the Material in the Event.

   ne.inheritsMaterial() --See if the Event inherits its material - it does not.
   --> false
   particleFlow.beginEdit() --Disable automatic encapsulation
   --> OK
   mtl2 = Material_Static()
   --> $Material_Static:Material Static 002 @ [0.000000,0.000000,0.000000]
   particleFlow.endEdit() --Enable automatic encapsulation
   --> OK
   pf.appendAction mtl2 --Add the new Material Static to the PF Source
   --> true
   ne.inheritsMaterial() --See if the Event inherits its material - it still does not.
   --> false
   mtl2.setmaterial (standard diffusecolor:blue name:"BlueMat") --Assign a Blue material
   --> true
   ne.inheritsMaterial() --See if the Event inherits its material - it has its own.
   --> false
   delete mtl --Delete the Material Static operator used by the Event
   --> 1
   ne.inheritsMaterial() --Now check to see if the Event inherits a material - it does!
   --> true
   --RENDERING at this point will produce BLUE particles
   --based on the color of the inherited PF Source material.


   delete mtl2 --Delete the Material Static operator used by the PF Source
   --> 1
   ne.activate false --Turn off the Event...
   --> OK
   ne.activate true -- ...and turn it on again 
   --> OK
   --RENDERING at this point will produce WHITE particles
   --based on the color of the Display operator.

   ne.setMaterial (standard diffusecolor:green name:"GreenMat") 
   --> true
   ne.activate false --Turn off the Event...
   --> OK
   ne.activate true -- ...and turn it on again 
   --> OK
   --RENDERING at this point will produce GREEN particles
   --The Green material is now assigned directly to the Event by MAXScript,
   --without the use of a Material operator!

   ne.getStreamDepth() --Check the stream depth at the Event - it incorrectly reports 0
   --> 0
   ne.updateMaterials false --Force an update of all materials - it claims that they all were ok
   --> 0
   ne.getStreamDepth() --Check the stream depth at the Event again - now it is correct
   --> 1

This Interface is available in:

Event : Helper