MaterialHolder インタフェースは、イベント ヘルパー クラスによって公開されます。
パーティクルのマテリアルへのアクセスを提供します。
3ds Max 2014 以降で使用可能です。
メソッド:
<boolean><PF_Event>.isMaterialHolder()
いずれかのパーティクル フローの[マテリアル] (Material)オペレータによりマテリアルがイベントに割り当てられている場合は True を返します。
マテリアルが割り当てられていない場合には([マテリアル] (Material)オペレータが存在しているものの、有効なマテリアルが割り当てられていない場合にも) False を返します。
<boolean><PF_Event>.inheritsMaterial()
イベントが前のフローからのマテリアルを継承する場合には True を返します。たとえば、[マテリアル] (Material)オペレータがグローバルの PF_Source イベントに割り当てられている場合や、イベントにマテリアルがない(そのイベントにもグローバルの PF_Source イベントにもない)場合です。
[マテリアル] (Material)オペレータがイベント自身の中にあるためにイベントが自身のマテリアルを継承しない場合には False を返します。
<material><PF_Event>.getMaterial()
ローカルの[マテリアル] (Material)オペレータを通じて、またはグローバルの[マテリアル] (Material)オペレータから継承した、イベントに関連付けられているマテリアルを返します。
<boolean><PF_Event>.setMaterial <material>material
イベントにマテリアルを割り当てます。このマテリアルは、イベントに[マテリアル] (Material)オペレータが含まれていない場合にのみ使用されます。
割り当てた後に新しいマテリアルを有効にするには、パーティクル フローをオフにしてから再びオンにする必要があります。
マテリアルが .setMaterial()
により割り当てられている場合、.getMaterial()
メソッドはこのマテリアルを返し ません。代わりに未定義を返します。
<integer><PF_Event>.getMaterialPriority()
マテリアルの優先順位を返します。
<integer><PF_Event>.getStreamDepth()
フロー内のイベントのストリームの深さを返します。
たとえば、イベントが PF_Source に直接接続されている場合は、1 の値が返されます。イベントが最初のイベントに接続されている場合は、2 などの値が返されます。
イベントが接続されていない場合は、0 の値が返されます。
<boolean><PF_Event>.updateMaterial <boolean>doReport
マテリアルを更新し、現在のイベントのマテリアルが更新された場合は True を、既に更新されていた場合は False を返します。
引数が True として渡された場合は、ポップアップ メッセージによりイベントのマテリアルの状態のレポートが表示されます。
<integer><PF_Event>.updateMaterials <boolean>doReport
PF_Event が属するフロー内のすべてのイベント内のマテリアルを更新します。
引数が True として渡された場合は、ポップアップ メッセージによりイベントのマテリアルの状態のレポートが表示されます。
マテリアルが更新されたイベントの数を返すか、またはすべてのマテリアルが既に更新されていた場合には 0 を返します。
<integer><PF_Event>.updateMaterialsDownstream <boolean>doReport
PF_Event が属するフロー内の下流にあるすべてのイベント内のマテリアルを更新します。
引数が True として渡された場合は、ポップアップ メッセージによりイベントのマテリアルの状態のレポートが表示されます。
マテリアルが更新されたイベントの数を返すか、またはすべてのマテリアルが既に更新されていた場合には 0 を返します。
例と結果
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
このインタフェースは下記で使用できます。