プラグイン開発者はオブジェクト モデルを介して、UserDataBlob オブジェクトとしてオブジェクトの生バイナリ ユーザ データを使用できます。 ユーザ データ ブロブは、SceneItem.AddProperty メソッドをサポートする任意のオブジェクトにアタッチできます。
UserDataBlob は UserDataMap に似ていますが、コンポーネント別のバイナリ データではなく、オブジェクト レベルのバイナリ データの保存をサポートしています。 たとえば、あるユーザ データが頂点クラスタ内のすべてのポイントに適用される場合、そのユーザ データは UserDataBlob に保存されます。一方、ユーザ データが単一の頂点に適用される場合、ユーザ データは UserDataMap の適切なインデックスに保存されます。
C++ の例: シーン ルートへの UserDataBlob の適用
// C++ example (using the C++ API) giving an overview of applying user data
// to a scene object (the scene root)
using namespace XSI;
Application app ;
Model root = app.GetActiveSceneRoot();
UserDataBlob myBlob ;
root.AddProperty( L"UserDataBlob", false, L"udb", myBlob ) ;
// This is the structure that we would like to save inside Softimage
struct ExampleData
{
double x ;
int y ;
int z ;
} ;
// Save the structure
ExampleData data ;
data.x = 90.1 ;
data.y = 12 ;
data.z = 14 ;
myBlob.PutValue( (unsigned char*)&data, sizeof( ExampleData ) ) ;
// Retrieve the structure again
unsigned char * pBuffer = NULL ;
unsigned int cntBuffer = 0 ;
myBlob.GetValue( pBuffer, cntBuffer ) ;
// We can conveniently read the contents of the user data
// by casting back to the structure
ExampleData * pData = (ExampleData*)pBuffer ;
// Update our structure based on what is already on the userdatablob
data.x = 3.15 + pData->x ;
data.y = 12 + pData->y ;
data.z = 0 ;
// Save our updated values
myBlob.PutValue( (unsigned char*)&data, sizeof( ExampleData ) ) ;