00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * Lamp for Maya 実装 00022 * 00023 * "Test/LampForMayaUnitTestBuildFlag.h"のLAMP_FOR_MAYA_UNIT_TEST_BUILD_FLAG 00024 * フラグを立てるとユニットテストをビルドします。<br> 00025 * 実行後Maya上で以下のコマンドを実行するとユニットテスト開始します。<br> 00026 * 「LampForMayaTest; unloadPlugin LampForMaya;」<br> 00027 * プラグインのアンロードはメモリリークを誤判定しないために必要です。<br> 00028 * <br> 00029 * プロジェクト設定<br> 00030 * 構成プロパティ->デバッグ->動作->コマンドに「maya.exe」<br> 00031 * 構成プロパティ->デバッグ->動作->コマンド引数に<br> 00032 * 「-command "LampForMayaTestInitialize;"」<br> 00033 * <br> 00034 * Mayaのファイルパス<br> 00035 * 「Lamp/LampForMaya/plug-ins」にプラグインパスを通す必要がある。<br> 00036 * 「Lamp/LampForMaya/scripts」にスクリプトパスを通す必要がある。<br> 00037 * 「Lamp/LampForMaya/icons」にアイコンパスを通す必要がある。<br> 00038 * Maya.envに以下の三行を付け加えるとよい。<br> 00039 * MAYA_PLUG_IN_PATH = D:/Lamp/LampForMaya/plug-ins<br> 00040 * MAYA_SCRIPT_PATH = D:/Lamp/LampForMaya/scripts<br> 00041 * XBMLANGPATH = D:/Lamp/LampForMaya/icons<br> 00042 * @author Junpee 00043 */ 00044 00045 /** @namespace LampForMaya Lamp用Mayaプラグイン 00046 * 00047 * 3DグラフィックスライブラリLampのMayaプラグイン用ネームスペースです。 00048 */ 00049 00050 #include "System/stdafx.h" 00051 #include <maya/MFnPlugin.h> 00052 #include "Translator/Core/LampTextTranslator.h" 00053 #include "Translator/Core/LampBinaryTranslator.h" 00054 #include "Material/Basic/LampBasicMaterial.h" 00055 00056 #include "Test/LampForMayaUnitTestBuildFlag.h" 00057 #if LAMP_FOR_MAYA_UNIT_TEST_BUILD_FLAG 00058 #include "Test/LampForMayaTest.h" 00059 #endif 00060 00061 using namespace LampForMaya; 00062 00063 //------------------------------------------------------------------------------ 00064 /** 00065 * プラグイン初期化 00066 * @param object プラグインオブジェクト 00067 * @return プラグインの初期化に成功すればMStatus::kSuccess 00068 */ 00069 MStatus initializePlugin(MObject object){ 00070 //-------------------------------------------------------------------------- 00071 // システム初期化 00072 //-------------------------------------------------------------------------- 00073 // Lamp初期化 00074 LampCore::initialize(); 00075 // Mayaエラー出力初期化 00076 MayaErrorOutput::initialize(); 00077 00078 //-------------------------------------------------------------------------- 00079 MStatus result; 00080 00081 MFnPlugin plugin(object, "Nemunekoya", "0.1", "Any"); 00082 00083 // サーフェースシェーダ分類 00084 MString surfaceShaderClassify("shader/surface"); 00085 00086 // 基本マテリアルの登録 00087 result = plugin.registerNode( 00088 "LampBasicMaterial", // プラグイン名 00089 LampBasicMaterial::id, // タイプID 00090 LampBasicMaterial::creator, // 生成メソッド 00091 LampBasicMaterial::initialize, // 初期化メソッド 00092 MPxNode::kHwShaderNode, // ノードの種類を指定 00093 &surfaceShaderClassify); // シェーダ分類 00094 MayaStatusCheck(result); 00095 00096 // テキストファイル出力プラグインの登録 00097 result = plugin.registerFileTranslator( 00098 "LampTextTranslator", // プラグイン名 00099 "LampTextTranslator.xpm", // アイコンファイル名 00100 LampTextTranslator::creator, // 生成メソッド 00101 "LampTranslatorOptions", // オプションMELスクリプト名 00102 "", // デフォルトオプション 00103 true); // MEL使用フラグ 00104 MayaStatusCheck(result); 00105 00106 // バイナリファイル出力プラグインの登録 00107 result = plugin.registerFileTranslator( 00108 "LampBinaryTranslator", // プラグイン名 00109 "LampBinaryTranslator.xpm", // アイコンファイル名 00110 LampBinaryTranslator::creator, // 生成メソッド 00111 "LampTranslatorOptions", // オプションMELスクリプト名 00112 "", // デフォルトオプション 00113 true); // MEL使用フラグ 00114 MayaStatusCheck(result); 00115 00116 #if LAMP_FOR_MAYA_UNIT_TEST_BUILD_FLAG 00117 // テストコマンドプラグインの登録 00118 result = plugin.registerCommand( 00119 "LampForMayaTest", LampForMayaTest::creator); 00120 MayaStatusCheck(result); 00121 #endif 00122 00123 return result; 00124 } 00125 //------------------------------------------------------------------------------ 00126 /** 00127 * プラグイン後始末 00128 * @param object プラグインオブジェクト 00129 * @return プラグインの後始末に成功すればMStatus::kSuccess 00130 */ 00131 MStatus uninitializePlugin(MObject object){ 00132 MStatus result; 00133 MFnPlugin plugin(object); 00134 00135 #if LAMP_FOR_MAYA_UNIT_TEST_BUILD_FLAG 00136 // テストコマンドプラグインの登録解除 00137 result = plugin.deregisterCommand ("LampForMayaTest"); 00138 MayaStatusCheck(result); 00139 #endif 00140 00141 // バイナリファイル出力プラグインの登録解除 00142 result = plugin.deregisterFileTranslator("LampBinaryTranslator"); 00143 MayaStatusCheck(result); 00144 00145 // テキストファイル出力プラグインの登録解除 00146 result = plugin.deregisterFileTranslator("LampTextTranslator"); 00147 MayaStatusCheck(result); 00148 00149 // 基本マテリアルの登録解除 00150 result = plugin.deregisterNode(LampBasicMaterial::id); 00151 MayaStatusCheck(result); 00152 00153 // Lamp後始末 00154 LampCore::finalize(); 00155 00156 //-------------------------------------------------------------------------- 00157 return result; 00158 } 00159 //------------------------------------------------------------------------------