AssetManager コア インタフェースは 3ds Max 2010で導入され、3ds Max シーン ファイルへのアセット データの保存を管理します。
インタフェース > コア インタフェース > AssetManager |
3ds Max 2010 より前のバージョンでは、外部ファイル(アセット)を参照したプラグインがそのアセットのファイル名を文字列またはパス オブジェクトとして保持し、このファイル名を 3ds Max シーン ファイルに文字列または IParameterBlock2 TYPE_FILENAME パラメータとして格納していました。プラグインによって使用されるアセットを 3ds Max が識別できるようにするために、プラグインは IAssetAccessor から派生するクラスを実装します。このクラスから提供される情報は、主にアセット トラッカーによって使用されます。
3ds Max 2010 以降、アセットは AssetUser クラスのインスタンスとして処理されます。このクラスのインスタンスには、アセットのファイル名、タイプ、およびこのアセットに依存する 3ds Max シーン ファイル(外部参照を解決するために使用されます)が含まれています。アセットへのアクセスおよびアセットの寿命管理は、アセット マネージャによって処理されます。
3ds Maxシーン ファイルへのアセットのロードと保存は、AssetUser と AssetManager によって行われます。
3ds Max シーンを保存すると、アセット データはアセット マネージャによって 3ds Max ファイルの別のストリームに保存されます。これにより、外部プログラムがアセット データにアクセスしてシーンで使用されているアセットを識別できるようになり、3ds Max にシーン ファイルをロードしなくてもアセット データを修正することができます。
以下のメソッドは、AssetManager が管理する情報を MAXScript に公開します。
メソッド:
<IObject>AssetManager.GetAsset <filename>fileName <enum>assetType autoAcquire:<bool> assetType enums: {#Other | #Bitmap | #XRef | #Photometric | #Animation | #VideoPost | #BatchRender | #ExternalLink | #RenderOutput | #PreRenderScript | #PostRenderScript | #Sound | #Container | #MaxCreationGraph} autoAcquire default value: true
指定されたファイル名とアセット タイプを持つアセットの AssetUser オブジェクトを返します。
<IObject>AssetManager.GetAssetByIndex <index>index
指定されたインデックスを持つアセットの AssetUser オブジェクトを返します。
AssetManager.GetNumAssets() を使用してアセットの数を取得します。
詳細については、「本トピックの最後にある例」を参照してください。
<IObject>GetAssetById <&TSTR>assetid assetid is In parameter
指定されたアセット ID を持つアセットの AssetUser オブジェクトを返します。3ds Max 2017 以降で使用可能です。
例: |
box material:(standard diffusemap:(bitmaptexture filename:"fur.tga")) --> $Box:Box002 @ [0.000000,0.000000,0.000000] assetid = (assetmanager.GetAssetByIndex 1).GetAssetId(); --> "{DBD187ED-0BA9-4D07-9B85-BA44F5170FD9}" assetmanager.GetFileName assetid --> "fur.tga" a=assetmanager.GetAssetById assetid --> <IObject:AssetUser> a.GetFileName() --> "fur.tga" |
<TSTR by value>AssetManager.GetAssetId <filename>fileName <enum>assetType assetType enums: {#Other | #Bitmap | #XRef | #Photometric | #Animation | #VideoPost | #BatchRender | #ExternalLink | #RenderOutput | #PreRenderScript | #PostRenderScript | #Sound | #Container | #MaxCreationGraph}
指定されたアセット タイプを持つ指定されたファイル名のアセット ID を返します。
例: |
AssetManager.GetAssetID "Simple_Stone_Mtl_Marble_bump.jpg" #Bitmap "{7477A3A4-0304-47AC-8427-6B490673231A}" |
<TSTR by value>AssetManager.GetFileName <&TSTR>assetid assetid is In parameter
指定された AssetID を持つアセットのファイル名を返します。
例: |
AUIO = AssetManager.GetAssetByIndex 1--get the AsserUser with index 1 --><IObject:AssetUser> AUIO.GetFileName()--get the file name -->"Untitled Scene" --This is equivalent: AssetManager.GetFileName (AUIO.getAssetID())--get the name by AssetID -->"Untitled Scene" |
<integer>AssetManager.GetNumReference <&TSTR>assetid assetid is In parameter
指定された AssetID を持つアセットへの参照の数を返します。
<bool>AssetManager.AddReference <&TSTR>assetid assetid is In parameter
指定された AssetID を持つアセットへの参照を追加します。
成功した場合は true を、失敗した場合は false を返します。
<bool>AssetManager.ReleaseReference <&TSTR>assetid assetid is In parameter
指定された AssetID を持つアセットの参照を解放します。
成功した場合は true を、失敗した場合は false を返します。
例: |
AUIO = AssetManager.GetAssetByIndex 1--get the AsserUser with index 1 --><IObject:AssetUser> AID =AUIO.getAssetID()--get the file name -->"{7477A3A4-0304-47AC-8427-6B490673231A}" AssetManager.GetNumReference AID--get the reference numberby AssetID -->4 AssetManager.AddReference AID--add a referenceby AssetID -->true AssetManager.GetNumReference AID--get thereference numberby AssetID -->5 AssetManager.ReleaseReference AID--release a referenceby AssetID -->true AssetManager.GetNumReference AID--get thereference numberby AssetID -->4 |
<INT64>AssetManager.GetNumAssetUsersCreated()
現在の 3ds Max セッションで作成された AssetUser インスタンスの合計数を返します。
<INT64>AssetManager.GetNumAssetUsers()
AssetUser インスタンスの数を返します。
<INT64>AssetManager.GetNumAssetsCreated()
現在の 3ds Max セッションで作成されたアセットの合計数を返します。
<INT64>AssetManager.GetNumAssets()
アセットの数を返します。
例: |
AssetManager.GetNumAssetUsersCreated() -->19862L AssetManager.GetNumAssetUsers() -->114L AssetManager.GetNumAssetsCreated() -->1080L AssetManager.GetNumAssets() -->18L |
<bool>AssetManager.RemoveMissingAssets()
見つからないアセットを削除します。
見つからないアセットが正常に削除された場合は True を返します。
見つからないアセットが削除されなかった場合には False を返します。
3ds Max 2016 以降で使用可能です。
例: |
以下のスクリプトは MAXScript リスナーに現在のシーンにあるすべてのアセットの ID、タイプ、ファイル名を出力します。 |
--Loop through all Asset indices: for i = 1 to AssetManager.GetNumAssets() do ( local AUIO = AssetManager.GetAssetByIndex i--get the AssetUser IObject local AID = AUIO.GetAssetId()--get the Asset's ID local AType = AUIO.getType()--get the Asset's Type local AFile = AUIO.getfilename()--get the Asset's File Name format"ID:% Type:% File:%\n"AID AType AFile--format the info ) |
出力例: |
ID:{B6D86A17-85FF-42E2-99D4-BB2F1857C4FB} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\PlaneToBake_diffuse.tga ID:{7477A3A4-0304-47AC-8427-6B490673231A} Type:#bitmap File:Simple_Stone_Mtl_Marble_bump.jpg ID:{8188ACCD-A014-4B24-A3DD-697269D8BFDB} Type:#bitmap File:Simple_Concrete_Mtl_BroomStraight_pattern.jpg ID:{B0B6A6FD-2B76-4EA0-8B34-D1F3F3596F91} Type:#bitmap File:x47645df4 ID:{CF096A5C-41C8-43FD-852F-8823B9A707C7} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsmax\renderoutput\AssetMan_.tga ID:{D5A9608F-EE4E-4BDC-AAB6-93D3D34E5F65} Type:#bitmap File:Simple_Concrete_Mtl_BroomCurved_pattern.jpg ID:{30241317-2623-4628-9BF1-ED06449E3D06} Type:#bitmap File:Simple_Metal_Mtl_DiamondPlate_pattern.jpg ID:{742F4FE3-91FC-48E7-9F3B-37CE76D37046} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01_diffuse.tga ID:{8BEFCD25-F133-4D5E-8678-E710F8BFBFF8} Type:#bitmap File:Simple_Metal_Mtl_CheckerPlate_pattern.jpg ID:{21B0F246-C6D0-44D3-9ECE-87D7BF8AFF14} Type:#bitmap File:Simple_Metal_Mtl_Break_pattern.jpg ID:{B5BB9B91-DBB4-486B-835A-A107F9F4783F} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\PlaneToBake_lighting.tga ID:{65CAE8F4-F0DF-4CC3-A05C-733CC0285CF4} Type:#bitmap File:C:\Program Files\Autodesk\3ds Max 2010\CachedThumbnails\1000000000000003.bmp ID:{5FF857B0-D2E0-4DCC-B4F7-97248CBC6FC5} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01LightingMap.tga ID:{31FE4D48-12B5-422E-A5D2-3A2979D773CD} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01_lighting.tga ID:{6AC17983-685D-42A8-8269-DBEA5FECB0DB} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Plane01_lighting.tga ID:{9BEAD40C-2562-42CF-A95D-E13E0EBD526D} Type:#bitmap File:C:\Program Files\Autodesk\3ds Max 2010\CachedThumbnails\1000000000000004.bmp ID:{2253E2F5-82FE-46B1-B012-BC5FA100D86A} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Sphere01DiffuseMap.tga ID:{42B8F3F4-0D38-49D9-A9D9-598288A4E674} Type:#renderoutput File:C:\Documents and Settings\username\My Documents\3dsmax\renderoutput\AssetMan_.tga ID:{AC8AF90A-44DB-42C9-AC9E-7C35A7EBFF1A} Type:#bitmap File:C:\Documents and Settings\username\My Documents\3dsMax\sceneassets\images\Plane01_diffuse.tga ID:{A9742E5A-4AB4-471D-A440-DE47F5262EF9} Type:#bitmap File:Simple_Stone_Mtl_Granite_bump.jpg ID:{8EC0A624-D996-48D7-9AA8-775ACA1652B9} Type:#xref File:C:\Documents and Settings\username\My Documents\3dsmax\scenes\RENOIR\AssetManagerTest.max ID:{B51DCC8A-57C6-4308-B5B8-00FE0A105A29} Type:#bitmap File:Simple_Stone_Mtl_StoneWall_bump.jpg ID:{16544B6C-5D81-4E96-9B4D-550BFD4111E3} Type:#bitmap File:Simple_Metal_Mtl_Brush_pattern.jpg |
関連項目
MAX ファイルの AssetManager、AssetUser、アセット メタデータへのアクセス