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

ExCMeshBilboarded.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 "ExCMeshBilboarded.h"
00025 
00026 ExCMeshBilboarded::ExCMeshBilboarded()
00027 {
00028 Guard(ExCMeshBilboarded::ExCMeshBilboarded())
00029         SetName("ExCMeshBilboarded");
00030         SetType(typeid(this).name());
00031 UnGuard
00032 }
00033 
00034 ExCMeshBilboarded::~ExCMeshBilboarded()
00035 {
00036 Guard(ExCMeshBilboarded::~ExCMeshBilboarded())
00037 UnGuard
00038 }
00039 
00040 void ExCMeshBilboarded::Draw(void)
00041 {
00042 Guard(void ExCMeshBilboarded::Draw(void))
00043 if(!m_Visible)return;
00044 //      std::cout<<"Draw fire MEsh "<<std::endl;
00045         ExCVec3D v1,v2,v3,v4,up,right,CollisionResult;
00046         GLfloat viewMatrix[16];
00047         //glPushMatrix();
00048         
00049                 glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix);
00050 
00051                         right.SetValue(viewMatrix[0],viewMatrix[4],viewMatrix[8]);
00052                         up.SetValue(viewMatrix[1],viewMatrix[5],viewMatrix[9]);
00053                         
00054                         glEnable(GL_TEXTURE_2D);
00055                         glDisable(GL_LIGHTING);
00056                         glColor4f(1, 1, 1, 1);
00057                         //glDisable(GL_DEPTH_TEST);
00058                         glBlendFunc(GL_DST_COLOR,GL_ZERO);
00059                         glEnable(GL_BLEND);             
00060                         
00061 
00062                 glColor4f(1.0f,1.0f,1.0f,1.0f);
00063 
00064                         v1=m_Position+(right+up)*-m_Size;
00065                         v2=m_Position+(right-up)*m_Size;
00066                         v3=m_Position+(right+up)*m_Size;
00067                         v4=m_Position+(up-right)*m_Size;
00068                 
00069                 ManagerTexture->SetCurrentObject(m_Mask);
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                 glBlendFunc(GL_ONE,GL_ONE);
00079                 ManagerTexture->SetCurrentObject(m_Texture);
00080 
00081                 glBegin(GL_QUADS);
00082                         glTexCoord2f(0.0f, 0.0f); glVertex3fv(v1.m_Vector);
00083                         glTexCoord2f(1.0f, 0.0f); glVertex3fv(v2.m_Vector);
00084                         glTexCoord2f(1.0f, 1.0f); glVertex3fv(v3.m_Vector);
00085                         glTexCoord2f(0.0f, 1.0f); glVertex3fv(v4.m_Vector);
00086                 glEnd();
00087 
00088                 glDisable(GL_BLEND);
00089                 glDisable(GL_TEXTURE_2D);
00090                 //glEnable(GL_DEPTH_TEST);
00091         //glPopMatrix();
00092 
00093 UnGuard
00094 }
00095 
00096 bool ExCMeshBilboarded::Load(std::string FileName)
00097 {
00098 Guard(bool ExCMeshBilboarded::Load(std::string FileName))
00099         char                    buffer[255];
00100         #ifdef UNIX_SRC
00101         sprintf(buffer, PREFIX "/ExNihilo/Data/Mesh/%s", FileName.data());
00102         #else
00103         sprintf(buffer, "../Data/Mesh/%s", FileName.data());
00104         #endif
00105         std::ifstream fin;
00106         std::string buffstring;
00107         char b[256];
00108         fin.open(buffer,std::ios::in);
00109         if(fin.is_open())
00110         {
00111                 try
00112                 {
00113                         //----Read type
00114                         memset(b,0,255);fin.getline(b,256,'\n');
00115                         //----Read size
00116                         memset(b,0,255);fin.getline(b,256,'\n');
00117                         m_Size=ExNihilo::ExtractFloatValueFromSring(b,"<Size>","<#Size>");
00118                         //----Read texture
00119                         memset(b,0,255);fin.getline(b,256,'\n');
00120                         m_Texture=ExNihilo::ExtracValueFromSring(b,"<Texture>","<#Texture>");
00121                         //----Read Mask
00122                         memset(b,0,255);fin.getline(b,256,'\n');
00123                         m_Mask=ExNihilo::ExtracValueFromSring(b,"<Mask>","<#Mask>");
00124                 }catch(...){throw ExCExpFileReadError();}
00125         }else throw   ExCExpFileNotFound();     
00126         return true;
00127 UnGuard
00128 }

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