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

# ExCMeshSauronEffect.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 "ExCMeshSauronEffect.h"
    00025
    00026 ExCMeshSauronEffect::ExCMeshSauronEffect()
    00027 {
    00028 Guard(ExCMeshSauronEffect::ExCMeshSauronEffect())
    00029         SetName("ExCMeshSauronEffect");
    00030         SetType(typeid(this).name());
    00031
    00032         m_Rayon=20;
    00033         m_Rayon2=4;
    00034         m_NumberFace=16;
    00035         m_Rotation=0;
    00036         m_NumberLayer=3;
    00037         m_SizeBetwenLayer=0.001;
    00038         m_Texture1="wave.dds";
    00039         m_TextureMouvingVec.SetValue(0,-0.0001);
    00040         m_TextureNextMouvingVec.SetValue(0,-0.00005);
    00041         m_Color.SetValue(0.9,0.0,0.0f);
    00042         u=0;
    00043         v=0.0005;
    00044 UnGuard
    00045 }
    00046
    00047 ExCMeshSauronEffect::~ExCMeshSauronEffect()
    00048 {
    00049 Guard(ExCMeshSauronEffect::~ExCMeshSauronEffect())
    00050 UnGuard
    00051 }
    00052
    00053 void ExCMeshSauronEffect::Draw(void)
    00054 {
    00055 Guard(void ExCMeshSauronEffect::Draw(void))
    00056 if(!m_Visible)return;
    00057
    00058         ExCVec3D        Vec;
    00059         glPushAttrib(GL_ALL_ATTRIB_BITS);
    00060         glPushMatrix();
    00061
    00062         glDisable(GL_LIGHTING);
    00063         glColor3f(m_Color.GetX(),m_Color.GetY(),m_Color.GetZ());
    00064         glEnable(GL_TEXTURE_2D);
    00065
    00066         for(int j=0;j<m_NumberLayer+0;j++)
    00067         {
    00068
    00069         /*      glMatrixMode(GL_TEXTURE);
    00070                 glTranslatef((m_TextureMouvingVec.GetX()+(j*m_TextureNextMouvingVec.GetX()))*glutGet(GLUT_ELAPSED_TIME)
    00071                         ,(m_TextureMouvingVec.GetY()+(j*m_TextureNextMouvingVec.GetY()))*glutGet(GLUT_ELAPSED_TIME),0.0f);
    00072                 glRotatef(45,0,0,1);
    00073                 glMatrixMode(GL_MODELVIEW);
    00074
    00075                 ManagerTexture->SetCurrentObject(m_Texture1);
    00076
    00077                 glEnable(GL_BLEND);
    00078                 glBlendFunc(GL_ONE,GL_ONE);
    00079                 glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    00080 */
    00081                 glBegin(GL_QUADS);
    00082
    00083                 //glActiveTexture(GL_TEXTURE0_ARB);
    00084                 glEnable(GL_TEXTURE_2D);
    00085                 //glBindTexture(GL_TEXTURE_2D, textureName);
    00086                 ManagerTexture->SetTexture(1,"Lotrback2");
    00087                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00088                 // RGB
    00089                 glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);
    00090
    00091                 glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE);
    00092                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_TEXTURE);
    00093                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
    00094                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_PREVIOUS_EXT);
    00095                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
    00096
    00097                 // alpha
    00098                 glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_ALPHA_EXT,GL_REPLACE);
    00099                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_ALPHA_EXT,GL_TEXTURE);
    00100                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_ALPHA_EXT,GL_SRC_ALPHA);
    00101
    00102                 //glActiveTexture(GL_TEXTURE1_ARB);
    00103                 glEnable(GL_TEXTURE_2D);
    00104                 //glBindTexture(GL_TEXTURE_2D, textureName);
    00105                 ManagerTexture->SetTexture(0,"Lotrback2DOT3");
    00106                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00107                 // RGB
    00108                 glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_EXT);
    00109                 glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_REPLACE);
    00110                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);
    00111                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
    00112
    00113                 // alpha
    00114                 glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_ALPHA_EXT,GL_ADD_SIGNED_EXT);
    00115                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_ALPHA_EXT,GL_TEXTURE);
    00116                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_ALPHA_EXT,GL_ONE_MINUS_SRC_ALPHA);
    00117                 glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE1_ALPHA_EXT,GL_PREVIOUS_EXT);
    00118                 glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND1_ALPHA_EXT,GL_SRC_ALPHA);
    00119
    00120                 glEnable(GL_BLEND);
    00121
    00122                 // src * srcAlpha + 0
    00123                 glBlendFunc(GL_SRC_ALPHA, GL_ZERO);
    00124
    00125                 ManagerTexture->SetTextureCoord(0,0.0f, 0.0f);
    00126                 ManagerTexture->SetTextureCoord(1,0.0f, 0.0f);
    00127                 glVertex3f(-10.0f, -10.0f,  1.0f);      // Bottom Left Of The Texture and Quad
    00128                 ManagerTexture->SetTextureCoord(0,1.0f, 0.0f);
    00129                 ManagerTexture->SetTextureCoord(1,1.0f, 0.0f);
    00130                 glVertex3f( 10.0f, -10.0f,  1.0f);      // Bottom Right Of The Texture and Quad
    00131                 ManagerTexture->SetTextureCoord(0,1.0f, 1.0f);
    00132                 ManagerTexture->SetTextureCoord(1,1.0f, 1.0f);
    00133                 glVertex3f( 10.0f,  10.0f,  1.0f);      // Top Right Of The Texture and Quad
    00134                 ManagerTexture->SetTextureCoord(0,0.0f, 1.0f);
    00135                 ManagerTexture->SetTextureCoord(1,0.0f, 1.0f);
    00136                 glVertex3f(-10.0f,  10.0f,  1.0f);      // Top Left Of The Texture and Quad
    00137
    00138
    00139                 glDisable(GL_BLEND);
    00140
    00141
    00142                 glEnd();
    00143 /*
    00144                 glMatrixMode(GL_TEXTURE);
    00145                 glLoadIdentity();
    00146                 glMatrixMode(GL_MODELVIEW);*/
    00147         }
    00148 ManagerTexture->ResetMultitexture();
    00149
    00150         glDisable(GL_TEXTURE_2D);
    00151         glPopMatrix();
    00152         glPopAttrib();
    00153
    00154 UnGuard
    00155 }
    00156
    00157 bool ExCMeshSauronEffect::Load(std::string FileName)
    00158 {
    00159 Guard(bool ExCMeshSauronEffect::Load(std::string FileName))
    00160         FileName="../Data/Mesh/"+FileName;
    00161         m_NumberFace=ExNihilo::ExtractIntValueFromFile(FileName,"<NumberFace>","<#NumberFace>");
    00162         m_Rayon=ExNihilo::ExtractFloatValueFromFile(FileName,"<Rayon>","<#Rayon>");
    00163         m_NumberLayer=ExNihilo::ExtractIntValueFromFile(FileName,"<NumberLayer>","<#NumberLayer>");
    00164         m_SizeBetwenLayer=ExNihilo::ExtractFloatValueFromFile(FileName,"<SizeBetwenLayer>","<#SizeBetwenLayer>");
    00165         m_Texture1=ExNihilo::ExtracStringValueFromFile(FileName,"<Texture>","<#Texture>");
    00166         m_TextureMouvingVec.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureMouvingVecX>","<#TextureMouvingVecX>"),
    00167                                                                 ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureMouvingVecY>","<#TextureMouvingVecY>"));
    00168         m_TextureNextMouvingVec.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureNextMouvingVecX>","<#TextureNextMouvingVecX>"),
    00169                                                                         ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureNextMouvingVecY>","<#TextureNextMouvingVecY>"));
    00170         m_Color.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorR>","<#ColorR>")
    00171                                         ,ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorG>","<#ColorG>")
    00172                                         ,ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorB>","<#ColorB>"));
    00173         ManagerTexture->Add(m_Texture1);
    00174         ManagerTexture->Add("Lotrback2");
    00175         ManagerTexture->Add("Lotrback2DOT3");
    00176 UnGuard
    00177 }