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

# TranslationMeshManager.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/Mesh/TranslationMeshManager.h"
    00027
    00028 namespace LampForMaya{
    00029
    00030 //------------------------------------------------------------------------------
    00031 // コンストラクタ
    00032 TranslationMeshManager::TranslationMeshManager() :
    00033     database_(256, 0.75f), array_(256){
    00034 }
    00035 //------------------------------------------------------------------------------
    00036 // デストラクタ
    00037 TranslationMeshManager::~TranslationMeshManager(){
    00038     Assert(database_.getCount() == 0);
    00039     Assert(array_.getCount() == 0);
    00040     if(getCount() != 0){ clear(); }
    00041 }
    00042 //------------------------------------------------------------------------------
    00043 // Lampへの変換
    00044 bool TranslationMeshManager::convertToLamp(Scene* scene) const{
    00045     for(int i = 0; i < getCount(); i++){
    00046         if(!get(i)->convertToLamp(scene)){ return false; }
    00047     }
    00048     return true;
    00049 }
    00050 //------------------------------------------------------------------------------
    00051 // クリア
    00052 int TranslationMeshManager::clear(){
    00053     int result = getCount();
    00054     // 要素の削除
    00055     for(int i = 0; i < result; i++){ delete array_.get(i); }
    00056     array_.clear();
    00057     database_.clear();
    00058     return result;
    00059 }
    00060 //------------------------------------------------------------------------------
    00061 // 剛体メッシュの作成
    00062 TranslationRigidMesh* TranslationMeshManager::createRigidMesh(
    00063     const String& meshName){
    00064     // 名前の重複チェック
    00065     TranslationMesh* exist = search(meshName);
    00066     if(exist != NULL){
    00067         MayaErrorOut(String("TranslationMeshManager::createRigidMesh() "
    00068             "名前が重複しています ") + meshName);
    00069         return NULL;
    00070     }
    00071     // メッシュ生成
    00072     TranslationRigidMesh* mesh = new TranslationRigidMesh(meshName);
    00073     database_.put(meshName, mesh);
    00074     array_.add(mesh);
    00075     return mesh;
    00076 }
    00077 //------------------------------------------------------------------------------
    00078 // キャラクタメッシュの作成
    00079 TranslationCharacterMesh* TranslationMeshManager::createCharacterMesh(
    00080     const String& meshName){
    00081     // 名前の重複チェック
    00082     TranslationMesh* exist = search(meshName);
    00083     if(exist != NULL){
    00084         MayaErrorOut(String("TranslationMeshManager::createCharacterMesh() "
    00085             "名前が重複しています ") + meshName);
    00086         return NULL;
    00087     }
    00088     // メッシュ生成
    00089     TranslationCharacterMesh* mesh = new TranslationCharacterMesh(meshName);
    00090     database_.put(meshName, mesh);
    00091     array_.add(mesh);
    00092     return mesh;
    00093 }
    00094 //------------------------------------------------------------------------------
    00095 } // End of namespace LampForMaya
    00096 //------------------------------------------------------------------------------