Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TranslationModelInstance.cpp

Go to the documentation of this file.
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  * 変換モデルインスタンス実装
00022  * @author Junpee
00023  */
00024 
00025 #include "System/stdafx.h"
00026 #include "Translator/Instance/TranslationModelInstance.h"
00027 #include "Graphics/Model/ModelManager.h"
00028 #include "Graphics/SceneNode/SceneNodeManager.h"
00029 
00030 namespace LampForMaya{
00031 
00032 //------------------------------------------------------------------------------
00033 // コンストラクタ
00034 TranslationModelInstance::TranslationModelInstance(
00035     const MDagPath& initializePath, const String& initializeName) :
00036     TranslationInstance(initializePath, initializeName),
00037     source_(NULL), destination_(NULL){
00038 }
00039 //------------------------------------------------------------------------------
00040 // デストラクタ
00041 TranslationModelInstance::~TranslationModelInstance(){
00042 }
00043 //------------------------------------------------------------------------------
00044 // Lampへの変換
00045 bool TranslationModelInstance::convertToLamp(Scene* scene){
00046     // 親シーンノードの検索
00047     SceneNodeManager* sceneNodeManager = scene->getSceneNodeManager();
00048     SceneNode* target = sceneNodeManager->search(parentSceneNodeName_);
00049     if(target == NULL){
00050         MayaErrorOut(String("TranslationModelInstance::convertToLamp() "
00051             "インスタンス先のシーンノードが見つかりません ") +
00052             parentSceneNodeName_);
00053         return false;
00054     }
00055 
00056     // モデルインスタンス
00057     ModelManager* modelManager = scene->getModelManager();
00058     Model* model = modelManager->search(name_);
00059     if(model == NULL){
00060         MayaErrorOut(String("TranslationModelInstance::convertToLamp() "
00061             "インスタンス元のモデル" + name_ + "が見つかりません ") +
00062             parentSceneNodeName_);
00063         return false;
00064     }
00065     source_ = model;
00066     Model* copyModel = model->copyModel(0);
00067     destination_ = copyModel;
00068 
00069     // 値のコピー
00070     copyModel->setEnabled(visibility_);
00071     target->addSceneLeaf(copyModel);
00072     return true;
00073 }
00074 //------------------------------------------------------------------------------
00075 // アニメーションの変換
00076 bool TranslationModelInstance::convertAnimation(
00077     AnimationManager* animationManager, AnimationSet* animationSet){
00078     return convertSceneLeafAnimation(
00079         animationManager, animationSet, source_, destination_);
00080 }
00081 //------------------------------------------------------------------------------
00082 } // End of namespace LampForMaya
00083 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:56 2005 for LampForMaya by doxygen 1.3.2