!!!もっとも簡単なプラグイン !!Shade7.5でのプラグインソース まずは、「Shade7.5」でのプラグインのソースを記載します(「Shadeプラグイン大全」の一番始めのソースより抜粋)。 これがShade8では多少すっきりした形となります。 //----------------------------------------------------------// // [HelloShade.cpp] // // もっとも簡単なプラグイン // // メッセージウィンドウに「HelloShade!!」と表示します。 // // 2003.08.30 - 2004.11.24 // // Yutaka Yoshisaka // //----------------------------------------------------------// struct allocator_class { }; #include #include #include #include #include #if WIN32 #include "windows.h" #endif #include "com.h" #include "shadeversion.h" #include "shadetypes.h" #include "shapeclass.h" #include "correctioninterface.h" #include "motioninterface.h" #include "dialoginterface.h" #include "streaminterface.h" #include "renderinglightclass.h" #include "renderingcontextinterface.h" #include "imageinterface.h" #include "sceneinterface.h" #include "effectorinterface.h" #include "pluginids.h" #include "pointer.h" #include "dllentries.h" //プラグインID。 //デベロッパごとにデベロッパIDを取得しておく必要があります。 static const int hello_shade_id = 0x50100000; struct helloshade_plugin_component : plugin_interface { virtual void do_it (shade_interface *shade, scene_interface *scene, void *aux = 0) { shade->message("Hello Shade!!"); } virtual int get_shade_version ( ) const { return SDK_VERSION; } virtual int get_id (void * = 0) { return hello_shade_id; } }; //******************************// // グローバル関数群 // //******************************// extern_c void STDCALL create_interface (const IID &iid, int i, void **p, shade_interface *shade, void *) { unknown_interface *u = new helloshade_plugin_component; u->AddRef(); *p = (void *)u; } extern_c int STDCALL has_interface (const IID &iid, shade_interface *shade) { if (iid == plugin_iid) { return 1; } return 0; } extern_c const char * STDCALL get_name (const IID &iid, int i, shade_interface *shade, void *) { if (iid == plugin_iid) { return "HelloShade" ; } return 0; } extern_c int STDCALL get_interface_version (void *) { return interface_version; } extern_c int STDCALL get_id (const IID &iid, int i, void *) { if (iid == plugin_iid) { return hello_shade_id; } return 0; } extern_c bool STDCALL is_resident (const IID &iid, int i, void *) { return false; } extern_c void STDCALL get_info (shade_plugin_info &info, shade_interface *shade, void *) { const bool japanese = shade->is_japanese_mode(); info.sdk_version = SDK_VERSION; info.recommended_shade_version = 380000; info.major_version = 1; info.minor_version = 0; info.micro_version = 0; info.build_number = 0; info.product_name = "HelloShade"; info.author = (char *)"shade plugin book."; info.company = ""; info.comments = japanese ? (char *)"簡単なプラグイン" : (char *)"simple plugin."; } extern_c bool STDCALL has_separate_interfaces ( void * ) { return false; } extern_c int STDCALL get_text_encoding (shade_interface *shade, void *) { return shade->is_japanese_mode() ? plugin_interface::japanese_encoding : 0; } !!Shade8での変更点 !「struct allocator_class { };」は不要に Shade7.5までのプラグインでは、「struct allocator_class { };」が #includeよりも前にないとプラグインビルドできない、というのがありました。 これは、Shade8からはなくなってます。 !#includeの指定 だらっと続いた#includeの指定ですが、スマートになってます。 plugin_interfaceで「Hello Shade!!」と表示させるだけなら以下の指定だけでOKです。 #include "shadebuildnumber.h" #include "plugininterface.h" #include "shadeinterface.h" #include "pluginids.h" #include "dllentries.h" 「shadebuildnumber.h」はShade8から追加されましたね。 これは次の変更に絡んでます。 !SDK_VERSIONの廃止 → SHADE_BUILD_NUMBERへ 各プラグインインターフェースで今まで、「SDK_VERSION」を返していた部分があります、 virtual int get_shade_version ( ) const { return SDK_VERSION; } このSDK_VERSIONが廃止され、変わりに「SHADE_BUILD_NUMBER」を返すようになりました。 virtual int get_shade_version ( ) const { return SHADE_BUILD_NUMBER; } これは「shadebuildnumber.h」に定義されています。 Shadeの内部ビルド番号が宣言されています。 !プラグインIDがUUIDに変更 「[[プラグインIDからUUIDへ|uuid_shade8sdk]]」を参照。プラグインの識別(マルチプラグインでは個々にUUIDを持たせる)は UUIDにて管理されるようになりました。 よって、get_id関数で返していたIDは、get_uuid関数でUUIDを返す仕様となってます。 !グローバル関数のextern_cの廃止(2005/12/02追加) Windowsでは問題なかったのですが、OSXでのプラグインビルドでは extern_c void STDCALL create_interface (... みたいに「extern_c」を使うとコンパイルエラーになりました。 extern "C" void STDCALL create_interface (... と書かないといけないようです。 とりあえずですが、大きな変更は上記くらいです。 後はUUIDになったことにより関数名の変更、関数名・引数パラメータが若干変わった、 機能追加された、などなどがちらほらあります。 それでは、Shade8用に書き換えた「HelloShade.cpp」を次に記載します。 !!Shade8でのプラグインソース 下記のUUIDは自分のマシンで生成してコピー&ペーストするようにしてください。 //----------------------------------------------------------// // [HelloShade.cpp] // // もっとも簡単なプラグイン(Shade8対応) // // メッセージウィンドウに「HelloShade!!」と表示します。 // // 2003.08.30 - 2005.12.02 // // Yutaka Yoshisaka // //----------------------------------------------------------// #include "shadebuildnumber.h" #include "plugininterface.h" #include "shadeinterface.h" #include "pluginids.h" #include "dllentries.h" #define HELLO_SHADE_ID uuid_class("77dc0269-ac76-4617-8ef6-32cbcc547afd") struct helloshade_plugin_component : plugin_interface { virtual void do_it (shade_interface *shade, scene_interface *scene, void *aux = 0) { shade->message("Hello Shade!!"); } virtual int get_shade_version ( ) const { return SHADE_BUILD_NUMBER; } virtual uuid_class get_uuid (void * = 0) { return HELLO_SHADE_ID; } }; //******************************// // グローバル関数群 // //******************************// extern "C" void STDCALL create_interface (const IID &iid, int i, void **p, shade_interface *shade, void *) { unknown_interface *u = new helloshade_plugin_component; u->AddRef(); *p = (void *)u; } extern "C" int STDCALL has_interface (const IID &iid, shade_interface *shade) { if (iid == plugin_iid) { return 1; } return 0; } extern "C" const char * STDCALL get_name (const IID &iid, int i, shade_interface *shade, void *) { if (iid == plugin_iid) { return "HelloShade" ; } return 0; } extern "C" int STDCALL get_interface_version (void *) { return interface_version; } extern "C" uuid_class STDCALL get_uuid (const IID &iid, int i, void *) { if (iid == plugin_iid) return HELLO_SHADE_ID; return uuid_class(0,0,0,0); } extern "C" bool STDCALL is_resident (const IID &iid, int i, void *) { return false; } extern "C" void STDCALL get_info (shade_plugin_info &info, shade_interface *shade, void *) { const bool japanese = shade->is_japanese_mode(); info.sdk_version = SHADE_BUILD_NUMBER; info.recommended_shade_version = 380000; info.major_version = 1; info.minor_version = 0; info.micro_version = 0; info.build_number = 0; info.product_name = "HelloShade"; info.author = (char *)"shade plugin book."; info.company = ""; info.comments = japanese ? (char *)"簡単なプラグイン" : (char *)"simple plugin."; } extern "C" bool STDCALL has_separate_interfaces ( void * ) { return false; } extern "C" int STDCALL get_text_encoding (shade_interface *shade, void *) { return shade->is_japanese_mode() ? plugin_interface::japanese_encoding : 0; } グローバル関数である「get_info」のSHADE_VERSIONもSHADE_BUILD_NUMBERに している点に注意です。 info.sdk_version = SHADE_BUILD_NUMBER; これさえクリアすると、後はほとんどShade7.5プラグインSDKと同じ要領で プラグインを作ることが可能なはずです。