値 > ArrayParameter 値 |
3ds Max の一部のプラグインでは、パラメータ データが MAXScript による ArrayParameters としてアクセス可能な形式で保存されます。このため、インデックスでパラメータ データにアクセスし、パラメータ データを反復できます。
コンストラクタ:
<MAXWrapper>.parameter
parameter には ArrayParameter が含まれます。
プロパティ
<ArrayParameter>.count
ArrayParameter 内の値の数を返します。調整可能な ArrayParameter が使用されている場所は、MAXWrapper オブジェクトで特に明記していない限り読み込み専用です。
演算子
<ArrayParameter>[<integer>]
ArrayParameter の要素を返します。インデックスは 1 から始まります。
<ArrayParameter>[<integer>] = <value>
ArrayParameter の要素を値に設定します。
各 ArrayParameter には、特定のタイプ(浮動小数点など)のデータだけ、またはそのデータ タイプに一致するコントローラだけを含めることができます。 showProperties() 関数は、これらの配列パラメータを <type> array で示します。 たとえば、 int array 、 texmap array のようになります。
プラグインでは、ArrayParameter 中の特定のエントリ 1 つをポイントするパラメータ名も定義できます。たとえば、 mapAmounts は、ArrayParameter を含む標準マテリアルのプロパティになります。この ArrayParameter 内の各要素には、1 つのマップ チャネルに対するマップ量が含まれます。スクリプト内で簡単にアクセスできるよう、標準 .ambientMapAmount プロパティが mapAmounts[1] のエイリアスとして(その他のすべての一般的なマップのエイリアスとともに)提供されます。 ambientMapAmount エイリアスのコントローラには、エイリアス上の .controller プロパティあるいは mapAmounts[1] プロパティのいずれかによってアクセスできます。
例: |
次のいずれかです。 |
$foo.material.ambientMapAmount.controller |
または |
$foo.material.mapAmounts[1].controller |
これらは、周囲光のマップ量マテリアル プロパティのコントローラを取得できます。 |
3ds Max 6 以降では、ArrayParameter 値を強制的に Array に置き換えることができます。
例 |
mtl = standard() mapsArray = mtl.maps as array |
次のスクリプトでは、ArrayParameter の要素のデータ タイプを表示する際に、ArrayParameter 要素へアクセスする場合と、プラグインで ArrayParameter の中の 1 つの特定のエントリをポイントするパラメータ名を定義している場合の showProperties() の使い方を示します。
スクリプト |
m=CompositeMaterial() -- create a Composite material showproperties m -- show the properties for the material m.amount -- show value of parameter amount m.amount[1] *= .5 -- reduce the value for one element m=standard() -- create a Standard material showproperties m -- show it’s properties m.ambientMapAmount=13 -- set the value for one element via its alias m.mapAmounts[1] -- and show the element was changed |
出力 |
compositematerial:Composite -- result line 1 .materialList (Material : material array -- output line 2 .mixType (Composite Type) : int array -- ArrayParameter elements are integer .mapEnables (Map Enable) : bool array -- ArrayParameter elements are boolean .amount : float array -- ArrayParameter elements are float OK -- result line 2 #(100, 100, 100, 100, 100, 100, 100, 100, 100, 100) -- result line 3 50.0 -- result line 4 Standardmaterial:Standard -- result line 5 .mapEnables (Map Enables) : bool array -- pruned output line 6 .maps : texmap array .mapAmounts (Map Amounts) : percent array .ambientMap (alias for maps[0]) .ambientMapAmount (alias for mapAmounts[0]) .ambientMapEnable (alias for mapEnables[0]) .bumpMap (alias for maps[8]) .bumpMapAmount (alias for mapAmounts[8]) .bumpMapEnable (alias for mapEnables[8]) 13 -- result line 7 13.0 -- result line 8 |