VertexPaint : モディファイヤ

VertexPaint - superclass: modifier; super-superclass:MAXWrapper - 12:0 - classID: #(2126202437, 2078409803)

以前のバージョンの 3ds Max にあった VertexPaint クラスが、3ds Max 6 では OldVertexPaint という名前に変更されました。変更後はクラス名はまったく同じですが、classID はまったく別のものに置き換えられました。

コンストラクタ:

vertexPaint ... PaintLayerMod...

プロパティ:

<VertexPaint>.ignoreBackfacing BooleanClass default: false -- boolean; Ignore_Backfacing

[バックグラウンドを無視]オプションを取得/設定します。

<VertexPaint>.mapChannel Integer default: 0 -- integer; Map_Channel

マップ チャネルを取得/設定します。

<VertexPaint>.layerMode String default: "Normal" -- string; Layer_Mode

レイヤ モードを取得/設定します。

<VertexPaint>.layerOpacity Float default: 100.0 -- animatable; float; Layer_Opacity

レイヤの不透明度を取得/設定します。

<VertexPaint>.layerIsolated BooleanClass default: false -- boolean; Layer_Isolated

分離したレイヤ モードを取得/設定します。UI の[下位レイヤのカラーを除外]に対応しています。

<VertexPaint>.surviveCondense BooleanClass default: false -- boolean; Survive_Condense

集約を残すモードを取得/設定します。UI の[レイヤを保持]に対応しています。

<VertexPaint>.lightingModel Integer default: 1 -- integer; Lighting_Model

ライティング モデルを取得/設定します。有効な値は次のとおりです。

  1. - ライト + 拡散反射光

  2. - ライトのみ

  3. - 拡散のみ

<VertexPaint>.colorBy Integer default: 0 -- integer; Color_By

カラー割り当てモードを取得/設定します。有効な値は次のとおりです。

  1. - 面で色分け

  2. - 頂点で色分け

<VertexPaint>.castShadows BooleanClass default: false -- boolean; Cast_Shadows

影付けオプションの状態を取得/設定します。UI の[シャドウ] (Shadows)オプションに対応しています。

<VertexPaint>.useMaps BooleanClass default: false -- boolean; Use_Maps

マップを使用オプションの状態を取得/設定します。UI の[マッピング] (Mapping)オプションに対応しています。

<VertexPaint>.useRadiosity BooleanClass default: false -- boolean; Use_Radiosity

ラジオシティを使用オプションの状態を取得/設定します。UI の[ラジオシティを使用]に対応しています。

<VertexPaint>.radiosityOnly BooleanClass default: false -- boolean; Radiosity_Only

ラジオシティのみオプションの状態を取得/設定します。UI の[ラジオシティのみ]に対応しています。

<VertexPaint>.radiosityOption Integer default: 0 -- integer; Lighting_Model

ラジオシティ ライティング モデルのインデックスを取得/設定します。

<VertexPaint>.hideUnselSubobjs BooleanClass default: false --  boolean; Hide_Unselected_Subobjects

選択されていないサブ オブジェクトの非表示と表示を切り替えます。このオプションは、UI 内で公開されていません。

インタフェース: IVertexPaint

このインタフェースから、VertexPaint モディファイヤのペイント状態にアクセスできます。このインタフェースを使用するには、次の操作を実行します。

  1. AcquirePaintState() を使用してペイントの状態を取得します。これは現在の状態のコピーです。
  2. 必要に応じて状態を変更します。
  3. ApplyPaintState() を使用して状態を再適用します。
  4. 必要に応じて MergeVertexColors() を使用して、スタック内の VertexPaint モディファイヤの下位からベイク処理された頂点カラーをキャプチャします。

3ds Max 2019.3 Update 以降で使用可能です。

メソッド:

<Interface>AcquirePaintState <node>node

指定したノードの VertexPaintState オブジェクトのコピーを取得します。変更するには、このオブジェクトを取得する必要があります。

<void>ApplyPaintState <node>node <Interface>state

指定した VertexPaintState を指定したノードに適用します。VertexPaintState オブジェクトが変更されていて、変更されたノードに変更を再度適用する必要がある場合は、この操作を行う必要があります。

<void>ReleasePaintState <node>node <Interface>state

指定したノードから、指定した VertexPaintState を解放します。

<void>MergeVertexColors <node>node

[頂点ペイント] (VertexPaint)モディファイヤの下位の指定ノードのベイク処理された任意の頂点カラーを、モディファイヤの[ペイント] (Paint)に合成します。

インタフェース: VertexPaintState

このインタフェースは、VertexPaintState オブジェクトのカラーを編集するためのメソッドを公開します。メソッドには 2 つのタイプがあります。

これらのメソッドのカラー パラメータは[R,G,B,A]形式の Point4 です。アルファ チャネルは適用されるペイントの量に影響し、0.0 の場合は効果なし、1.0 の場合は効果が最大(100%)となります。

3ds Max 2019.3 Update 以降で使用可能です。

メソッド:

<node>ReleasePaintState()

現在ペイント状態のオブジェクトを解放します。

<integer>GetNumRawColors()

VertexPaintState オブジェクトで保持されている未加工のカラー エントリの数を返します。これは分解されたトポロジ内の未加工インデックスの数です。

<index>GetRawIndex <index>faceIndex <index>vertIndex

面のインデックスと頂点のインデックスで指定された頂点の未加工のインデックスを返します。これは、内部の「分解されたトポロジ」内の頂点で保持されているカラー値のインデックスです。各頂点に、隣接する各面の個別のカラー値が保持されます。このインデックスは、GetRawColor() または SetRawColor() を呼び出す際に必要になります。未加工のインデックスの基数は 1 です。

<point4>GetRawColor <index>rawIndex

指定した頂点の未加工のカラーを返します。特定の頂点/面の組み合わせの未加工のインデックスを取得するには、GetRawIndex() を使用します。

<point4>GetVertAverageColor <index>vertIndex

指定した頂点のすべてのカラー エントリ(隣接する面ごとに 1 つずつ)の平均カラーを取得します。

<point4>GetFaceAverageColor <index>faceIndex

faceIndex で指定された面の平均カラー(すべての頂点で保持されている面の平均カラー)を取得します。

<point4>GetFaceVertColor <index>faceIndex <index>vertIndex

以下のカラーを取得します。

<void>SetRawColor <index>rawIndex <point4>color

「未加工」インデックスを使用して、単一の頂点エントリのカラーを設定します。このインデックスを取得するには、GetRawIndex() を使用します。

<void>SetVertColor <index>vertIndex <point4>color

指定した頂点のカラーを設定します。この値は、指定した頂点で保持されるすべてのエントリに影響します。頂点には、隣接する各面のカラー エントリが 1 つ保持されます。4 つのエッジを持つ頂点のカラー エントリ数は、TriMesh の場合は 6、ポリゴン メッシュの場合は 4 です。

<void>SetFaceColor <index>faceIndex <point4>color

指定した面のすべてのエントリのカラーを設定します。4 つのエッジを持つ面のカラー エントリ数は、TriMesh の場合は 6、ポリゴン メッシュの場合は 4 です。

<void>SetFaceVertColor <index>faceIndex <index>vertIndex <point4>color

1 つの面/頂点の組み合わせのカラー エントリを設定します。これは、面/インデックスの組み合わせの未加工インデックスを取得して、SetRawColor() を呼び出す操作と機能的に同等な、便利なメソッドです。

-- Demo: VertexPaint Scripting

fn doYourThing = (print "doing my thing")

-- Create an object and VertexPaint
g = Box() -- geometry object
    v = PaintLayerMod()
    addModifier g v
    g.showVertexColors = on



-- ---------- PAINT COLOR STATE ----------
-- Create a VertexPaint State object
-- This captures the current state into the object for editing.
-- Note:  Necessary to pass the node as a parameter to disambiguate,
-- since the modifier could be applied on multiple objects.
    s = v.AcquirePaintState g



-- ---------- RAW COLOR ACCESS ----------
-- Check how many color entries are in the state
    s.GetNumRawColors()
-- Each vertex has multiple entries, one for each face surrounding the vert.
-- VertexPaint maintain an "exploded topology" at all times.
-- Set a raw color entry, index is 1-based (not 0-based)
    s.SetRawColor 1 [1, 0.5, 0, 1]
    v.ApplyPaintState g s
-- Four entries are R,G,B and Amount, which is the amount of paint applied, and acts
-- like a mask in Photoshop terms.  Amount of zero means the paint has no effect.
-- Red 1.0 (maximum), Green 0.5, Blue 0.0 = Orange



-- ---------- VERTEX COLOR ACCESS ----------
-- Set a vertex color, affects all entries for the vert.
-- A vert with four visible edges has about six entries in a trimesh, four in a polymesh
    s.SetVertColor 1 [1, 0.5, 0, 1]
-- Apply the state back to the modifier
    v.ApplyPaintState g s
-- Get a vertex color, this takes the average of all entries for the vert
    c = s.GetVertAverageColor 1
    if( c != [1, 0.5, 0, 1] ) do UhOh()



-- ---------- FACE COLOR ACCESS ----------
-- Set a face color, affects all entries for the face.
-- A face with four edges has six color entries in a trimesh,  four in a polymesh
    s.SetFaceColor 1 [1, 0.5, 0, 1]
-- Apply the state back to the modifier
    v.ApplyPaintState g s
-- Get a face color, this takes the averaage of all entries for the face
    c = s.GetFaceAverageColor 1
    if( c != [1, 0.5, 0, 1] ) do UhOh()



-- ---------- FACE VERT COLOR ACCESS ----------
-- Specify both a face and a vert (in that order) to indicate a single raw entry
    faceNum=2
    vertNum=4
    s.SetFaceVertColor faceNum vertNum [1, 0, 0, 1]
-- OR, get the equivalent index to use with SetRawColor()
    x = s.GetRawIndex faceNum vertNum
    s.SetRawColor x [0, 1, 0, 1]
-- Apply the state back to the modifier
    v.ApplyPaintState g s



-- ---------- CAPTURE COLORS ----------
-- Capture any existing vertex colors on an object into a new VertexPaint.
-- Specify the map channel you're interested to capture
    v.mapChannel = 3
    v.MergeVertexColors g
-- This is similar to "Condense to Single Layer",
-- however it does not delete any modifiers.
-- Fetch the state again for editing
    s = v.AcquirePaintState g



-- ---------- !! WARNING !! ----------
-- ---------- SELECTIONS ----------
-- The sub-object selection masks the operation of ApplyPaintState(),
-- just like it masks the effect of brush strokes.
-- If you do not want this behavior, make sure to clear the selection
    selHoldSubobjLevel = 0
    if( (finditem (selection as array) g) > 0 )  do -- are we selected?
    (
        selHoldSubobjLevel = subobjectLevel -- remember subobject level
        subobjectLevel = 0 -- go to object level
    )
-- Do your thing
    doYourThing()
-- Revert selection after
    if( selHoldSubobjLevel > 0 ) do (
        subobjectLevel = selHoldSubObjLevel
    )

従来の VertexPaint モディファイヤによる元の定義を次に示します。

OldVertexPaint : モディファイヤ

OldVertexPaint - superclass: modifier; super-superclass:MAXWrapper - classID: #(1715171243, 1945400197)

3ds Max 6 以上ではクラス インスタンスを作成できません