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

# ExCMeshSummonCylenderEffect.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 "ExCMeshSummonCylenderEffect.h"
    00025
    00026 ExCMeshSummonCylenderEffect::ExCMeshSummonCylenderEffect()
    00027 {
    00028 Guard(ExCMeshSummonCylenderEffect::ExCMeshSummonCylenderEffect())
    00029         SetName("ExCMeshSummonCylenderEffect");
    00030         SetType(typeid(this).name());
    00031         m_NumberFace=4;
    00032         m_Rayon=10;
    00033         m_Height=150;
    00034         m_NumberCircle=5;
    00035         m_SizeBetwenCircle=2;
    00036         m_Texture="wave.dds";
    00037         m_TextureMouvingVec.SetValue(0,-0.0001);
    00038         m_TextureNextMouvingVec.SetValue(0,0.00005);
    00039         m_StartBlending=0.1f;
    00040         m_BlendingStep=0.5;
    00041         m_Color.SetValue(0.2f,0.2f,0.8f);
    00042 UnGuard
    00043 }
    00044
    00045 ExCMeshSummonCylenderEffect::~ExCMeshSummonCylenderEffect()
    00046 {
    00047 Guard(ExCMeshSummonCylenderEffect::~ExCMeshSummonCylenderEffect())
    00048 UnGuard
    00049 }
    00050
    00051 void ExCMeshSummonCylenderEffect::Draw(void)
    00052 {
    00053 Guard(void ExCMeshSummonCylenderEffect::Draw(void))
    00054 if(!m_Visible)return;
    00055         ExCVec3D        Vec;
    00056         glPushAttrib(GL_ALL_ATTRIB_BITS);
    00057         glDisable(GL_LIGHTING);
    00058         glEnable(GL_TEXTURE_2D);
    00059         glDisable(GL_CULL_FACE);
    00060         //blending
    00061         glEnable(GL_BLEND);
    00062         glBlendFunc(GL_ONE,GL_ONE);
    00063         glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    00064         //glTranslatef(0,-6,0);
    00065         for(int j=0;j<m_NumberCircle;j++)
    00066         {
    00067                 glColor4f(m_Color.GetX(),m_Color.GetY(),m_Color.GetZ(),m_StartBlending+j*m_BlendingStep);
    00068                 ManagerTexture->SetCurrentObject(m_Texture);
    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                 glMatrixMode(GL_MODELVIEW);
    00073                 glBegin(GL_QUADS);
    00074                 for(int i=0;i<m_NumberFace;i++)
    00075                 {
    00076
    00077                                 glTexCoord2f(1,0);
    00078                                 Vec.SetX(Cos[(i)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00079                                 Vec.SetZ(Sin[(i)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00080                                 Vec.SetY(0);
    00081                                 glVertex3fv(Vec.m_Vector);
    00082                                 glTexCoord2f(1,1);
    00083                                 Vec.SetY(m_Height);
    00084                                 glVertex3fv(Vec.m_Vector);
    00085
    00086                                 glTexCoord2f(0,1);
    00087                                 Vec.SetX(Cos[(i+1)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00088                                 Vec.SetZ(Sin[(i+1)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00089                                 Vec.SetY(m_Height);
    00090
    00091                                 //glColor4f(0,0,0,m_StartBlending+j*m_BlendingStep);
    00092
    00093                                 if(i==m_NumberFace-1)
    00094                                 {
    00095                                         Vec.SetX(Cos[(0)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00096                                         Vec.SetZ(Sin[(0)*(360/m_NumberFace)]*(m_Rayon+(j*m_SizeBetwenCircle)));
    00097                                 }
    00098                                 glVertex3fv(Vec.m_Vector);
    00099                                 glTexCoord2f(0,0);
    00100                                 Vec.SetY(0);
    00101                                 glVertex3fv(Vec.m_Vector);
    00102
    00103                 }
    00104
    00105                 glEnd();
    00106         }
    00107         glMatrixMode(GL_TEXTURE);
    00108         glLoadIdentity();
    00109         glMatrixMode(GL_MODELVIEW);
    00110
    00111         glDisable(GL_TEXTURE_2D);
    00112         glPopAttrib();
    00113 UnGuard
    00114 }
    00115
    00116 bool ExCMeshSummonCylenderEffect::Load(std::string FileName)
    00117 {
    00118 Guard(bool ExCMeshSummonCylenderEffect::Load(std::string FileName))
    00119         FileName="../Data/Mesh/"+FileName;
    00120         m_NumberFace=ExNihilo::ExtractIntValueFromFile(FileName,"<NumberFace>","<#NumberFace>");
    00121         m_Rayon=ExNihilo::ExtractFloatValueFromFile(FileName,"<Rayon>","<#Rayon>");
    00122         m_Height=ExNihilo::ExtractFloatValueFromFile(FileName,"<Height>","<#Height>");
    00123         m_NumberCircle=ExNihilo::ExtractIntValueFromFile(FileName,"<NumberCircle>","<#NumberCircle>");
    00124         m_SizeBetwenCircle=ExNihilo::ExtractFloatValueFromFile(FileName,"<SizeBetwenCircle>","<#SizeBetwenCircle>");
    00125         m_Texture=ExNihilo::ExtracStringValueFromFile(FileName,"<Texture>","<#Texture>");
    00126         m_TextureMouvingVec.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureMouvingVecX>","<#TextureMouvingVecX>"),
    00127                 ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureMouvingVecY>","<#TextureMouvingVecY>"));
    00128         m_TextureNextMouvingVec.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureNextMouvingVecX>","<#TextureNextMouvingVecX>"),
    00129                 ExNihilo::ExtractFloatValueFromFile(FileName,"<TextureNextMouvingVecY>","<#TextureNextMouvingVecY>"));
    00130         m_StartBlending=ExNihilo::ExtractFloatValueFromFile(FileName,"<StartBlending>","<#StartBlending>");
    00131         m_BlendingStep=ExNihilo::ExtractFloatValueFromFile(FileName,"<BlendingStep>","<#BlendingStep>");
    00132         m_Color.SetValue(ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorR>","<#ColorR>")
    00133                 ,ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorG>","<#ColorG>")
    00134                 ,ExNihilo::ExtractFloatValueFromFile(FileName,"<ColorB>","<#ColorB>"));
    00135         ManagerTexture->Add(m_Texture);
    00136         return true;
    00137 UnGuard
    00138 }