v6.0
RefModel
リファレンス Model に解像度を追加します。 リファレンス モデルには、解像度を無制限に設定できます。 各解像度には、名前とファイルがあります。
AddRefModelResolution( Model, [ResolutionName], [FileName] ); |
パラメータ | タイプ | 詳細 |
---|---|---|
Model | 文字列 | 解像度の追加先モデル。
デフォルト値: 現在選択されている値 |
ResolutionName | 文字列 | 解像度の名前。 指定されていない場合は、デフォルトの名前が指定されます。 |
FileName | 文字列 | この新しい解像度に使用するファイル名。 デフォルトでは、ファイル パスが設定されていません。 |
/* This example illustrates how to add and remove resolutions on a reference model. It also demonstrates how to navigate through the resolution information on a reference model (see the convenience functions at the bottom of the example, especially GetAllResolutions). */ // Import a referenced model. NewScene( null, false ); var sModelPath = XSIUtils.BuildPath( Application.InstallationPath(siFactoryPath), "Data", "XSI_SAMPLES", "Models", "ManSkeleton_Basic.emdl" ); ImportModel( sModelPath, null, true ); // Add a new resolution var oRefModel = Application.ActiveSceneRoot.Models.Item(0); AddRefModelResolution( oRefModel, "MyRes", sModelPath ); // Display the current resolutions LogResolutions( oRefModel ); // Now remove the original resolution and verify that the new resolution is there var iTargetRes = GetResolutionIndexByName( oRefModel, "res1" ); if ( iTargetRes > -1 ) { var iCurrentRes = oRefModel.NestedObjects("Active Resolution").Value; if ( iCurrentRes == iTargetRes ) { // Change the active resolution to the new one and remove the original oRefModel.NestedObjects("Active Resolution").Value = iTargetRes + 1; RemoveRefModelResolution( oRefModel, "res1", true ); } // Display again the resolutions LogResolutions( oRefModel ); } // Expected results: // INFO : res0 // INFO : file = // INFO : name = Offloaded // INFO : res1 // INFO : file = Models\ManSkeleton_Basic.emdl // INFO : name = res1 // INFO : res2 // INFO : file = Models\ManSkeleton_Basic.emdl // INFO : name = MyRes // INFO : res0 // INFO : file = // INFO : name = Offloaded // INFO : res1 // INFO : file = Models\ManSkeleton_Basic.emdl // INFO : name = MyRes /* These are convenience functions that do most of the work of navigating through the resolutions information nested under each reference model. The resolutions info is never displayed in the UI, but you can think of its structure like so: ReferenceModel (model) - Resolutions (special container) - res0 (compound parameter) - File parameter (eg., "<installationpath>/Data/XSI_SAMPLES/Models/ManSkeleton_Basic.emdl") - Name parameter (eg., "MyRes") + res1 ... + resN In order to access this info you need to use the SIObject.NestedObjects property on the ReferenceModel, the Resolutions container, and then each resolution parameter. */ function GetAllResolutions( in_oRefModel ) { var e = new Enumerator( in_oRefModel.NestedObjects ); for ( ; !e.atEnd(); e.moveNext() ) { var oCurrentContainer = e.item(); if ( oCurrentContainer.Name == "Resolutions" ) { return oCurrentContainer.NestedObjects; } } } /* Logs the file and name values of each resolution to history */ function LogResolutions( in_oRefModel ) { // Visit each resolution and find its name and file info var oResolutions = GetAllResolutions( in_oRefModel ); for ( var i=0; i<oResolutions.Count; i++ ) { var oResolutionParameter = oResolutions(i); Application.LogMessage( oResolutionParameter.Name ); // The file and name parameters are nested under the compound resolution parameter var oResInfo = oResolutionParameter.NestedObjects; for ( var j=0; j<oResInfo.Count; j++ ) { Application.LogMessage( " " + oResInfo(j).Name + " = " + oResInfo(j).Value ); } } } /* Returns the index number of the resolution given its name */ function GetResolutionIndexByName( in_oModel, in_sResName ) { // Visit each resolution and check its name against the specified name var oResolutions = GetAllResolutions( in_oModel ); for ( var i=0; i<oResolutions.Count; i++ ) { var oResolutionParameter = oResolutions(i); if ( oResolutionParameter.NestedObjects("name").Value == in_sResName ) { return i; } } // If not found, return a negative value return -1; } |