Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

# ExManagerMesh.cpp

Aller à la documentation de ce fichier.

    00001 /*
    00002  * ExNihilo 3D Engine
    00003  *
    00004  *  This program is free software; you can redistribute it and/or modify
    00005  *  it under the terms of the GNU General Public License as published by
    00006  *  the Free Software Foundation; either version 2 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  This program is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU General Public License
    00015  *  along with this program; if not, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  *
    00018  * Please read AUTHORS file !!!
    00019  *
    00020  * $Id: ExManagerMesh.cpp,v 1.9 2002/12/03 22:40:03 data Exp $
    00021  *
    00022  */
    00023
    00024 #include "ExManagerMesh.h"
    00025
    00026 bool ExManagerMesh::m_flag = false;
    00027 ExManagerMesh* ExManagerMesh::m_instance = NULL;
    00028
    00029 ExManagerMesh* ExManagerMesh::CreateSingleton(void){
    00030 Guard(ExManagerMesh* ExManagerMesh::CreateSingleton(void))
    00031         if(!m_flag)
    00032         {
    00033                 m_flag = true; // We are creating the error log now, so set flag to true
    00034                 m_instance = new ExManagerMesh; // Create the error log
    00035         }else
    00036         {
    00037                 std::cout<<"Error singleton already created"<<std::endl;
    00038         }
    00039         return m_instance;
    00040 UnGuard
    00041 }
    00042
    00043 ExManagerMesh::ExManagerMesh(void)
    00044 {
    00045 }
    00046
    00047 ExManagerMesh::~ExManagerMesh(void)
    00048 {
    00049 }
    00050
    00051 void ExManagerMesh::Reset(void)
    00052 {
    00053         ExManagerObject<ExCMesh *>::Reset();
    00054 }
    00055
    00056 void ExManagerMesh::Init(void)
    00057 {
    00058 Guard(void ExManagerMesh::Init(void))
    00059         ExManagerObject<ExCMesh *>::Init();
    00060
    00061 UnGuard
    00062 }
    00063
    00064 void ExManagerMesh::Draw(void)
    00065 {
    00066         //Draw here only if PVS is not active
    00067         for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++)
    00068         {
    00069                 m_ItMap->second->Draw();
    00070         }
    00071 }
    00072
    00073
    00074 MeshType ExManagerMesh::GetMeshType(std::string FileName)
    00075 {
    00076 Guard(MeshType ExManagerMesh::GetMeshType(std::string FileName))
    00077         std::string buffstring;
    00078         buffstring=ExNihilo::ExtracStringValueFromFile("../Data/Mesh/"+FileName,"<Type>","<#Type>");
    00079         if(strcmpi(buffstring.data(),"ExCMeshFireEffect")==0)return MESH_FIRE_EFFECT;
    00080         if(strcmpi(buffstring.data(),"ExCMeshWaterEffect")==0)return MESH_WATER_EFFECT;
    00081         if(strcmpi(buffstring.data(),"ExCMeshSummonCylenderEffect")==0)return MESH_SUMMON_CYLENDER_EFFECT;
    00082         if(strcmpi(buffstring.data(),"ExCMeshSmogEffect")==0)return MESH_SMOG_EFFECT;
    00083         if(strcmpi(buffstring.data(),"ExCMeshWaterDisqueEffect")==0)return MESH_WATER_DISQUE_EFFECT;
    00084         if(strcmpi(buffstring.data(),"ExCMeshLOD3ds")==0)return MESH_LOD_3DS;
    00085         if(strcmpi(buffstring.data(),"ExCMeshSauronEffect")==0)return MESH_SAURON_EFFECT;
    00086         if(strcmpi(buffstring.data(),"ExCMesh3ds")==0)return MESH_3DS;
    00087         if(strcmpi(buffstring.data(),"ExCMeshBilboarded")==0)return MESH_BILBOARDED;
    00088         return MESH_UNKNOWN;
    00089 UnGuard
    00090 }
    00091
    00092 ExNihilo::ExId ExManagerMesh::Load(std::string FileName)
    00093 {
    00094 Guard(ExNihilo::ExManagerMesh::Load(std::string FileName))
    00095         //std::cout<<"Load file:"<<FileName<<std::endl;
    00096         //Check if model already loaded
    00097         try
    00098         {
    00099                 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++)
    00100                 {
    00101                         if(strcmp(m_ItMap->second->GetName().data(),FileName.data())==0)
    00102                         {
    00103                                 return m_ItMap->second->GetId();
    00104                         }
    00105                 }
    00106         }catch(...){}
    00107         ExCMesh *Mesh;
    00108         switch(GetMeshType(FileName))
    00109         {
    00110         case MESH_FIRE_EFFECT:Mesh = new ExCMeshFireEffect;break;
    00111         case MESH_WATER_EFFECT:Mesh = new ExCMeshWaterEffect;break;
    00112         case MESH_SUMMON_CYLENDER_EFFECT:Mesh = new ExCMeshSummonCylenderEffect;break;
    00113         case MESH_SMOG_EFFECT:Mesh = new ExCMeshSmogEffect;break;
    00114         case MESH_WATER_DISQUE_EFFECT:Mesh = new ExCMeshWaterDisqueEffect;break;
    00115         case MESH_SAURON_EFFECT:Mesh = new ExCMeshSauronEffect;break;
    00116         case MESH_LOD_3DS:Mesh = new ExCMeshLOD3ds;break;
    00117         case MESH_3DS:
    00118                 Mesh = new ExCMesh3ds;
    00119                 ((ExCMesh3ds *)Mesh)->SetManagerModel(ManagerModel);
    00120                 ((ExCMesh3ds *)Mesh)->SetManagerId(ManagerId);
    00121                 break;
    00122         case MESH_BILBOARDED:
    00123                 Mesh = new ExCMeshBilboarded;
    00124                 break;
    00125         }
    00126
    00127         Mesh->SetName(FileName);
    00128         Mesh->SetManagerTexture(ManagerTexture);
    00129         Mesh->Load(FileName);
    00130         Add(Mesh);
    00131         return Mesh->GetId();
    00132 UnGuard
    00133 }
    00134
    00135 ExNihilo::ExId ExManagerMesh::Load(std::string FileName,std::string ObjectName)
    00136 {
    00137 Guard(ExNihilo::ExId ExManagerMesh::Load(std::string FileName,std::string ObjectName))
    00138
    00139 UnGuard
    00140 }
    00141
    00142 ExCAction ExManagerMesh::InputCommand(ExCCommand Command)
    00143 {
    00144 Guard(ExCAction ExManagerMesh::InputCommand(ExCCommand Command))
    00145                 return NOTHING;
    00146 UnGuard
    00147 }
    00148
    00149 ExCAction ExManagerMesh::InputAction(ExCAction Action)
    00150 {
    00151 Guard(ExCAction ExManagerMesh::InputAction(ExCAction Action))
    00152         switch(Action.m_Action)
    00153         {
    00154                 default:
    00155                         *Consol<<"Can not file action in MESH_ACTION_MAP"<<std::endl;
    00156                         break;
    00157         }
    00158         if(Action.m_NextAction){return *Action.m_NextAction;}
    00159         else{return NOTHING;}
    00160 UnGuard
    00161 }
    00162
    00163 ExCMesh * ExManagerMesh::GetObject(ExNihilo::ExId id)
    00164 {
    00165         Guard(ExCMesh *ExManagerMesh::GetObject(ExNihilo::ExId id))
    00166                 for(m_ItMap=m_Map->begin();m_ItMap!=m_Map->end();m_ItMap++)
    00167                 {
    00168                         if(m_ItMap->second->GetId()==id)return m_ItMap->second;
    00169                 }
    00170                 return NULL;
    00171                 UnGuard
    00172 }