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

Model.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 "LampBasic.h"
00026 #include "Graphics/Model/Model.h"
00027 #include "Graphics/Model/ModelManager.h"
00028 #include "Graphics/Mesh/Mesh.h"
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 // コンストラクタ
00034 Model::Model(const String& name, Scene* scene) : SceneLeaf(name, scene){
00035 }
00036 //------------------------------------------------------------------------------
00037 // デストラクタ
00038 Model::~Model(){
00039 }
00040 //------------------------------------------------------------------------------
00041 // モデルの値コピー
00042 void Model::copyModelValue(Model* destination, u_int copyMask) const{
00043     // シーンリーフの値コピー
00044     copySceneLeafValue(destination);
00045     // メッシュのコピー
00046     int meshCount = getMeshCount();
00047     for(int i = 0; i < meshCount; i++){
00048         destination->addMesh(getMesh(i)->copy(copyMask));
00049     }
00050 }
00051 //------------------------------------------------------------------------------
00052 // 再帰的破棄
00053 int Model::recursiveDestroy(Model* model){
00054     Assert(model != NULL);
00055     int result = 0;
00056     // メッシュの破棄
00057     for(int i = model->getMeshCount() - 1; i >= 0; i--){
00058         result += Mesh::recursiveDestroy(model->getMesh(i));
00059     }
00060     // 引数の破棄
00061     ModelManager* manager = model->getScene()->getModelManager();
00062     if(manager->destroy(model) == 0){ result++; }
00063     return result;
00064 }
00065 //------------------------------------------------------------------------------
00066 // 走査
00067 void Model::traverse(const Matrix34& parentMatrix,
00068     bool parentEnabled, bool parentScaled, bool parentChanged){
00069     SceneLeaf::traverse(parentMatrix,
00070         parentEnabled, parentScaled, parentChanged);
00071     // メッシュ
00072     int meshCount = getMeshCount();
00073     for(int i = 0; i < meshCount; i++){
00074         getMesh(i)->traverse(parentMatrix,
00075             isGlobalEnabled(), parentScaled, parentChanged);
00076     }
00077 }
00078 //------------------------------------------------------------------------------
00079 // メッシュの追加
00080 void Model::addMesh(Mesh* mesh){
00081     mesh->setParent(this);
00082     meshes_.add(mesh);
00083 }
00084 //------------------------------------------------------------------------------
00085 // メッシュの削除
00086 void Model::removeMesh(Mesh* mesh){
00087     mesh->removeParent(this);
00088     meshes_.removeByValue(mesh);
00089 }
00090 //------------------------------------------------------------------------------
00091 } // End of namespace Lamp
00092 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:33 2005 for Lamp by doxygen 1.3.2