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

ExCMeshFireEffect.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 
00021  *
00022  */
00023 
00024 #include "ExCMeshFireEffect.h"
00025 
00026 ExCMeshFireEffect::ExCMeshFireEffect()
00027 {
00028 Guard(ExCMeshFireEffect::ExCMeshFireEffect())
00029         SetName("ExCMeshFireEffect");
00030         SetType(typeid(this).name());
00031         m_CurrentAnimationTexture=0;
00032         m_LastTime=0;
00033         m_DelayNextFrame=75;
00034 UnGuard
00035 }
00036 
00037 ExCMeshFireEffect::~ExCMeshFireEffect()
00038 {
00039 Guard(ExCMeshFireEffect::~ExCMeshFireEffect())
00040 UnGuard
00041 }
00042 
00043 void ExCMeshFireEffect::Draw(void)
00044 {
00045 Guard(void ExCMeshFireEffect::Draw(void))
00046 if(!m_Visible)return;
00047 //      std::cout<<"Draw fire MEsh "<<std::endl;
00048         ExCVec3D v1,v2,v3,v4,up,right,CollisionResult;
00049         GLfloat viewMatrix[16];
00050         //glPushMatrix();
00051         //glPushAttrib(GL_ALL_ATTRIB_BITS);
00052                 glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);
00053 
00054                         right.SetValue(viewMatrix[0],viewMatrix[4],viewMatrix[8]);
00055                         up.SetValue(viewMatrix[1],viewMatrix[5],viewMatrix[9]);
00056                         
00057                         glEnable(GL_BLEND);
00058                         glBlendFunc(GL_SRC_ALPHA,GL_ONE);
00059                         glEnable(GL_TEXTURE_2D);
00060                         glDisable(GL_LIGHTING);
00061                         glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
00062                         ManagerTexture->SetCurrentObject(m_VecAnimTexture.at(m_CurrentAnimationTexture));       
00063 
00064                 glColor4f(1.0f,1.0f,1.0f,1.0f);
00065 
00066                         v1=m_Position+(right+up)*-m_Size;
00067                         v2=m_Position+(right-up)*m_Size;
00068                         v3=m_Position+(right+up)*m_Size;
00069                         v4=m_Position+(up-right)*m_Size;
00070 
00071                 glBegin(GL_QUADS);
00072                         glTexCoord2f(0.0f, 0.0f); glVertex3fv(v1.m_Vector);
00073                         glTexCoord2f(1.0f, 0.0f); glVertex3fv(v2.m_Vector);
00074                         glTexCoord2f(1.0f, 1.0f); glVertex3fv(v3.m_Vector);
00075                         glTexCoord2f(0.0f, 1.0f); glVertex3fv(v4.m_Vector);
00076                 glEnd();
00077                 
00078                 glDisable(GL_TEXTURE_2D);
00079                 glDisable(GL_BLEND);
00080         //glPopAttrib();
00081         //glPopMatrix();
00082         if(m_LastTime+m_DelayNextFrame<glutGet(GLUT_ELAPSED_TIME))//next second
00083         {
00084                 if (m_CurrentAnimationTexture<m_VecAnimTexture.size()-1)
00085                 {
00086                         m_CurrentAnimationTexture++;
00087                 }else m_CurrentAnimationTexture=0;
00088                 m_LastTime=glutGet(GLUT_ELAPSED_TIME);
00089         }
00090 
00091 UnGuard
00092 }
00093 
00094 bool ExCMeshFireEffect::Load(std::string FileName)
00095 {
00096 Guard(bool ExCMeshFireEffect::Load(std::string FileName))
00097         char                    buffer[255];
00098         #ifdef UNIX_SRC
00099         sprintf(buffer, PREFIX "/ExNihilo/Data/Mesh/%s", FileName.data());
00100         #else
00101         sprintf(buffer, "../Data/Mesh/%s", FileName.data());
00102         #endif
00103         std::ifstream fin;
00104         std::string buffstring;
00105         char b[256];
00106         fin.open(buffer,std::ios::in);
00107         if(fin.is_open())
00108         {
00109                 try
00110                 {
00111                         //----Read type
00112                         memset(b,0,255);
00113                         fin.getline(b,256,'\n');
00114 
00115                         //----Read size
00116                         memset(b,0,255);
00117                         fin.getline(b,256,'\n');
00118                         m_Size=ExNihilo::ExtractFloatValueFromSring(b,"<Size>","<#Size>");
00119                         //----Read all frame
00120                         do
00121                         {
00122                                 memset(b,0,255);
00123                                 fin.getline(b,256,'\n');
00124                                 try
00125                                 {
00126                                         buffstring=ExNihilo::ExtracValueFromSring(b,"<Frame>","<#Frame>");
00127                                         //ManagerTexture->Add(buffstring);
00128                                         m_VecAnimTexture.push_back(buffstring);
00129                                         //std::cout<<ExNihilo::ExtracValueFromSring(b,"<Frame>","<#Frame>")<<std::endl;
00130                                 }catch(ExCExpStringNotFound){}
00131                         }while(!fin.eof());
00132                         fin.close();
00133                 }catch(...){throw ExCExpFileReadError();}
00134         }else throw   ExCExpFileNotFound();     
00135         return true;
00136 UnGuard
00137 }

Généré le Tue Oct 28 12:43:31 2003 pour ExNihilo par doxygen 1.3.4