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

# ExCHeightMap.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 "ExCHeightMap.h"
    00025
    00026 ExCHeightMap::ExCHeightMap(void)
    00027 {
    00028         m_FogDepthLevel = 55.0f;
    00029         m_MapDetailLevel = 8;
    00030         m_MapResolution = 1024;
    00031         m_Texture2Repetition = 50;
    00032         m_Fog=true;
    00033         m_MapScale=4;
    00034 }
    00035
    00036 ExCHeightMap::~ExCHeightMap(void)
    00037 {
    00038 }
    00039
    00040
    00041 void ExCHeightMap::Load(std::string FileName)
    00042 {
    00043 Guard(void ExCHeightMap::Load(std::string FileName))
    00044         g_HeightMap = new byte[m_MapResolution*m_MapResolution];
    00045         char                    buffer[255],b[255];
    00046         std::string buffstring;
    00047         std::ifstream file;
    00048
    00049         #ifdef UNIX_SRC
    00050         sprintf(buffer, PREFIX "/ExNihilo/Data/Map/%s", FileName.data());
    00051         #else
    00052         sprintf(buffer, "../Data/Map/%s", FileName.data());
    00053         #endif
    00054         file.open(buffer,std::ios::in);
    00055         if(file.is_open())
    00056         {
    00057                 memset(b,0,255);file.getline(b,256,'\n');
    00058                 try
    00059                 {
    00060                         std::cout<<"Plok1"<<std::endl;
    00061                         if(ExNihilo::ExtractIntValueFromSring(b,"<FogEnable>","<#FogEnable>")==1)
    00062                         {
    00063                                 m_Fog=true;
    00064                         }else
    00065                         {
    00066                                 m_Fog=false;
    00067                         }
    00068                         memset(b,0,255);file.getline(b,256,'\n');
    00069                         m_FogDepthLevel=ExNihilo::ExtractFloatValueFromSring(b,"<FogDepthLevel>","<#FogDepthLevel>");
    00070                         memset(b,0,255);file.getline(b,256,'\n');
    00071                         m_MapDetailLevel=ExNihilo::ExtractFloatValueFromSring(b,"<MapDetailLevel>","<#MapDetailLevel>");
    00072                         memset(b,0,255);file.getline(b,256,'\n');
    00073                         m_MapResolution=ExNihilo::ExtractFloatValueFromSring(b,"<MapResolution>","<#MapResolution>");
    00074                         memset(b,0,255);file.getline(b,256,'\n');
    00075                         m_MapScale=ExNihilo::ExtractFloatValueFromSring(b,"<MapScale>","<#MapScale>");
    00076                         memset(b,0,255);file.getline(b,256,'\n');
    00077                         m_TextureMap="../Data/Map/"+ExNihilo::ExtracValueFromSring(b,"<HeightTexture>","<#HeightTexture>");
    00078                         FILE *pFile = NULL;
    00079                         pFile = fopen(m_TextureMap.data(), "rb" );
    00080                         if ( pFile == NULL )
    00081                         {
    00082                                 std::cout<<"Can't find the height map! Error"<<std::endl;
    00083                                 return;
    00084                         }
    00085
    00086                         fread( g_HeightMap, 1, m_MapResolution * m_MapResolution, pFile );
    00087                         if(ferror( pFile ))
    00088                         {
    00089                                 std::cout<<"Can't get data! Error"<<std::endl;
    00090                         }
    00091                         fclose(pFile);
    00092
    00093                         m_VecTexture.resize(ManagerTexture->GetMaxMultitexturingLevel());
    00094                         memset(b,0,255);file.getline(b,256,'\n');
    00095                         SetTextureLand(0,ExNihilo::ExtracValueFromSring(b,"<TextureLand1>","<#TextureLand1>"));
    00096                         memset(b,0,255);file.getline(b,256,'\n');
    00097                         SetTextureLand(1,ExNihilo::ExtracValueFromSring(b,"<TextureLand2>","<#TextureLand2>"));
    00098                         memset(b,0,255);file.getline(b,256,'\n');
    00099                         SetTextureLand(2,ExNihilo::ExtracValueFromSring(b,"<TextureLand3>","<#TextureLand3>"));
    00100                         memset(b,0,255);file.getline(b,256,'\n');
    00101                         SetTextureLand(3,ExNihilo::ExtracValueFromSring(b,"<TextureLand4>","<#TextureLand4>"));
    00102
    00103                         //Read position
    00104                         memset(b,0,255);file.getline(b,256,'\n');
    00105                         buffstring=ExNihilo::ExtracValueFromSring(b,"<Position>","<#Position>");
    00106                         m_Position.SetX(ExNihilo::ExtractFloatValueFromSring(buffstring,"<X>","<#X>"));
    00107                         m_Position.SetY(ExNihilo::ExtractFloatValueFromSring(buffstring,"<Y>","<#Y>"));
    00108                         m_Position.SetZ(ExNihilo::ExtractFloatValueFromSring(buffstring,"<Z>","<#Z>"));
    00109
    00110                 }catch(ExCExpStringNotFound){std::cout<<"Bad file type "<<buffer<<std::endl;}
    00111         }else
    00112         {
    00113                 std::cout<<"File not found:"<<buffer<<std::endl;
    00114                 throw   ExCExpFileNotFound();
    00115         }
    00116         m_Position.SetX(m_Position.GetX()-(m_MapResolution*m_MapScale/2));
    00117         m_Position.SetZ(m_Position.GetZ()-(m_MapResolution*m_MapScale/2));
    00118
    00119         //BuildArray();
    00120 UnGuard
    00121 }
    00122
    00123 void ExCHeightMap::SetTextureLand(unsigned int Number,std::string FileName)
    00124 {
    00125 Guard(void ExCHeightMap::SetTextureLand(unsigned int Number,std::string FileName))
    00126         if (m_VecTexture.size()>Number)
    00127         {
    00128                 m_VecTexture.at(Number)=FileName;
    00129         }
    00130 UnGuard
    00131 }
    00132
    00133 void ExCHeightMap::Draw(void)
    00134 {
    00135 Guard(void ExCHeightMap::Draw(void))
    00136         glPushAttrib(GL_ALL_ATTRIB_BITS);
    00137                 glPushMatrix();
    00138                         glTranslatef(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
    00139                         glScalef(m_MapScale,m_MapScale,m_MapScale);
    00140                         glDisable(GL_LIGHTING);
    00141                         glEnable(GL_TEXTURE_2D);
    00142                         glColor3f(1.0f,1.0f,1.0f);
    00143                         /*if(m_Array)
    00144                         {
    00145                                 RenderArray();
    00146                         }else*/
    00147                         try
    00148                         {
    00149                                 RenderHeightMap();
    00150                         }catch (...)
    00151                         {
    00152                                 std::cout<<"Exception render heigtmap"<<std::endl;
    00153                         }
    00154                 glPopMatrix();
    00155         glPopAttrib();
    00156 UnGuard
    00157 }
    00158
    00159 void ExCHeightMap::IncreaseDetailLevel(void)
    00160 {
    00161 Guard(void ExCHeightMap::IncreaseDetailLevel(void))
    00162         m_MapDetailLevel=m_MapDetailLevel*2;
    00163         if(m_MapDetailLevel>=m_MapResolution)m_MapDetailLevel=m_MapResolution;
    00164 UnGuard
    00165 }
    00166
    00167 void ExCHeightMap::DereaseDetailLevel(void)
    00168 {
    00169 Guard(void ExCHeightMap::DereaseDetailLevel(void))
    00170         m_MapDetailLevel=m_MapDetailLevel/2;
    00171         if (m_MapDetailLevel<=0)m_MapDetailLevel=1;
    00172 UnGuard
    00173 }
    00174
    00175 void ExCHeightMap::IncreaseFogDepthLevel(void)
    00176 {
    00177 Guard(void ExCHeightMap::IncreaseFogDepthLevel(void))
    00178         m_FogDepthLevel++;
    00179 UnGuard
    00180 }
    00181
    00182 void ExCHeightMap::DereaseFogDepthLevel(void)
    00183 {
    00184 Guard(void ExCHeightMap::DereaseFogDepthLevel(void))
    00185         m_FogDepthLevel--;
    00186         if (m_FogDepthLevel<=0)m_FogDepthLevel=1;
    00187 UnGuard
    00188 }
    00189
    00190 void ExCHeightMap::IncreaseTexture2Repetition(void)
    00191 {
    00192 Guard(void ExCHeightMap::IncreaseTexture2Repetition(void))
    00193         m_Texture2Repetition++;
    00194 UnGuard
    00195 }
    00196
    00197 void ExCHeightMap::DereaseTexture2Repetition(void)
    00198 {
    00199 Guard(void ExCHeightMap::DereaseTexture2Repetition(void))
    00200         m_Texture2Repetition--;
    00201         if (m_Texture2Repetition<=0)m_Texture2Repetition=1;
    00202 UnGuard
    00203 }
    00204
    00205
    00211
    00212 int ExCHeightMap::Height(int X, int Y)
    00213 {
    00214         // This is used to index into our height map array.
    00215         // When ever we are dealing with arrays, we want to make sure
    00216         // that we don't go outside of them, so we make sure that doesn't
    00217         // happen with a %.  This way x and y will cap out at (MAX_SIZE - 1)
    00218
    00219         int x = X % m_MapResolution;                                    // Error check our x value
    00220         int y = Y % m_MapResolution;                                    // Error check our y value
    00221
    00222         if(!g_HeightMap) return 0;                              // Make sure our data is valid
    00223
    00224         // Below, we need to treat the single array like a 2D array.
    00225         // We can use the equation: index = (x + (y * arrayWidth) ).
    00226         // This is assuming we are using this assumption array[x][y]
    00227         // otherwise it's the opposite.  Now that we have the correct index,
    00228         // we will return the height in that index.
    00229
    00230         return g_HeightMap[x + (y * m_MapResolution)];  // Index into our height array and return the height
    00231 }
    00232
    00233 void ExCHeightMap::SetTextureCoord(float CoordU,float CoordV)
    00234 {
    00235 Guard(void ExCHeightMap::SetTextureCoord(float CoordU,float CoordV))
    00236         for(unsigned int i=0;i<m_VecTexture.size();i++){ManagerTexture->SetTextureCoord(i,CoordU,CoordV);}
    00237 UnGuard
    00238 }
    00239 void ExCHeightMap::BuildArray(void)
    00240 {
    00241         int verticecount=0;
    00242         float xmul=1;
    00243         float ymul=1.5;
    00244         float zmul=1;
    00245         int X = 0, Y = 0;                                               // Create some variables to walk the array with.
    00246         int x, y, z;                                                    // Create some variables for readability
    00247         float fogY = 0;
    00248         bool bSwitchSides = false;
    00249
    00250         ExCVec3D Vec;
    00251
    00252         TabVertices= new float[6*(33282)];
    00253         TabTextures= new float[4*(33282)];
    00254
    00255
    00256         int i=0;
    00257         for ( X = 0; X <= m_MapResolution; X += m_MapDetailLevel )
    00258         {
    00259
    00260                 if(bSwitchSides)
    00261                 {
    00262                         for ( Y = m_MapResolution; Y >= 0; Y -= m_MapDetailLevel )
    00263                         {
    00264                                 x = X;//X+=MapdetailLevel
    00265                                 y = Height(X, Y );
    00266                                 z = Y;//Y = m_MapResolution ;Y-=MapdetailLevel
    00267                                 //SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00268                                 TabTextures[0+i*4]=(float)x / (float)m_MapResolution;
    00269                                 TabTextures[1+i*4]=-(float)z / (float)m_MapResolution;
    00270                                 //glVertex3i(x*xmul, y*ymul, z*zmul);
    00271                                 Vec.SetValue(x*xmul, y*ymul, z*zmul);
    00272                                 TabVertices[0+i*6]=Vec.GetX();
    00273                                 TabVertices[1+i*6]=Vec.GetY();
    00274                                 TabVertices[2+i*6]=Vec.GetZ();
    00275                                 //std::cout<<Vec;
    00276                                 verticecount++;
    00277                                 x = X + m_MapDetailLevel;
    00278                                 y = Height(X + m_MapDetailLevel, Y );
    00279                                 z = Y;
    00280                                 //SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00281                                 TabTextures[2+i*4]=(float)x / (float)m_MapResolution;
    00282                                 TabTextures[3+i*4]=-(float)z / (float)m_MapResolution;
    00283                                 //glVertex3i(x*xmul, y*ymul, z*zmul);
    00284                                 Vec.SetValue(x*xmul, y*ymul, z*zmul);
    00285                                 TabVertices[3+i*6]=Vec.GetX();
    00286                                 TabVertices[4+i*6]=Vec.GetY();
    00287                                 TabVertices[5+i*6]=Vec.GetZ();
    00288                                 //std::cout<<Vec;
    00289                                 verticecount++;
    00290                                 i++;
    00291                         }
    00292                 }
    00293                 else
    00294                 {
    00295                         for ( Y = 0; Y <= m_MapResolution; Y += m_MapDetailLevel )
    00296                         {
    00297                                 x = X + m_MapDetailLevel;
    00298                                 y = Height(X + m_MapDetailLevel, Y );
    00299                                 z = Y;
    00300                                 //SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00301                                 TabTextures[0+i*4]=(float)x / (float)m_MapResolution;
    00302                                 TabTextures[1+i*4]=-(float)z / (float)m_MapResolution;
    00303                                 //glVertex3i(x, y*ymul, z);
    00304                                 Vec.SetValue(x, y*ymul, z);
    00305                                 TabVertices[0+i*6]=Vec.GetX();
    00306                                 TabVertices[1+i*6]=Vec.GetY();
    00307                                 TabVertices[2+i*6]=Vec.GetZ();
    00308                                 //std::cout<<Vec;
    00309                                 verticecount++;
    00310                                 x = X;
    00311                                 y = Height(X, Y );
    00312                                 z = Y;
    00313                                 //SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00314                                 TabTextures[2+i*4]=(float)x / (float)m_MapResolution;
    00315                                 TabTextures[3+i*4]=-(float)z / (float)m_MapResolution;
    00316                                 //glVertex3i(x*xmul, y*ymul, z*zmul);
    00317                                 Vec.SetValue(x*xmul, y*ymul, z*zmul);
    00318                                 TabVertices[3+i*6]=Vec.GetX();
    00319                                 TabVertices[4+i*6]=Vec.GetY();
    00320                                 TabVertices[5+i*6]=Vec.GetZ();
    00321                                 //std::cout<<Vec;
    00322                                 verticecount++;
    00323                                 i++;
    00324                         }
    00325                 }
    00326                 bSwitchSides = !bSwitchSides;
    00327                 std::cout<<i<<":"<<verticecount<<std::endl;
    00328         }
    00329
    00330         m_Array=true;
    00331 }
    00332 void ExCHeightMap::RenderArray()
    00333 {
    00334 Guard(void ExCHeightMap::RenderArray())
    00335         glPushMatrix();
    00336                 glTranslatef(0,-10,0);
    00337                 glScalef(1.4,1.5,3);
    00338                 ManagerTexture->SetTexture(0,m_VecTexture.at(0));
    00339                 ManagerTexture->SetTexture(1,m_VecTexture.at(1));
    00340
    00341                 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
    00342                 glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
    00343                 glMatrixMode(GL_TEXTURE);
    00344                 glPushMatrix();
    00345                         glLoadIdentity();
    00346                         glScalef((float)m_Texture2Repetition, (float)m_Texture2Repetition, 1);
    00347                         glMatrixMode(GL_MODELVIEW);
    00348                         ManagerTexture->SetTexture(2,m_VecTexture.at(2));
    00349                         ManagerTexture->SetTexture(3,m_VecTexture.at(3));
    00350
    00351                         //call array
    00352                         glTexCoordPointer(2,GL_FLOAT,0,TabTextures);
    00353                         glVertexPointer(2,GL_FLOAT,0,TabVertices);
    00354                         glDrawArrays( GL_TRIANGLE_STRIP, 0, 11094 );
    00355
    00356                 glMatrixMode(GL_TEXTURE);
    00357                 ManagerTexture->SetTexture(1,m_VecTexture.at(1));
    00358                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00359                 glPopMatrix();
    00360                 glMatrixMode(GL_MODELVIEW);
    00361                 glMatrixMode(GL_TEXTURE);
    00362                 ManagerTexture->SetTexture(2,m_VecTexture.at(2));
    00363                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00364                 glPopMatrix();
    00365                 glMatrixMode(GL_MODELVIEW);
    00366                 ManagerTexture->ResetMultitexture();
    00367
    00368         glPopMatrix();
    00369 UnGuard
    00370 }
    00371
    00372 void ExCHeightMap::RenderHeightMap()
    00373 {
    00374 Guard(void ExCHeightMap::RenderHeightMap())
    00375         float xmul=1;
    00376         float ymul=1.5;
    00377         float zmul=1;
    00378         //float xmul=1.4;
    00379         //float ymul=1.5*1.5;
    00380         //float zmul=3;
    00381         int X = 0, Y = 0;                                               // Create some variables to walk the array with.
    00382         int x, y, z;                                                    // Create some variables for readability
    00383         float fogY = 0;
    00384         bool bSwitchSides = false;
    00385
    00386 glPushMatrix();
    00387         glTranslatef(0,-10,0);
    00388         glScalef(1.4,1.5,3);
    00389
    00390         if(m_Fog){ManagerFog->EnableFog();}
    00391
    00392         ManagerTexture->SetTexture(0,m_VecTexture.at(0));
    00393         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00394
    00395
    00396         // If we want detail texturing on, let's render the second texture
    00397         ManagerTexture->SetTexture(1,m_VecTexture.at(1));
    00398         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00399
    00400         // Here we turn on the COMBINE properties and increase our RGB
    00401         // gamma for the detail texture.  2 seems to work just right.
    00402         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
    00403         glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
    00404         glMatrixMode(GL_TEXTURE);
    00405                 glPushMatrix();
    00406                 glLoadIdentity();
    00407                 glScalef((float)m_Texture2Repetition, (float)m_Texture2Repetition, 1);
    00408         glMatrixMode(GL_MODELVIEW);
    00409
    00410
    00411 //      ManagerTexture->SetTexture(2,m_VecTexture.at(2));
    00412 //      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00413 /*      glMatrixMode(GL_TEXTURE);
    00414                 glPushMatrix();
    00415                 glLoadIdentity();
    00416                 glTranslatef(0.0f,-0.00001*glutGet(GLUT_ELAPSED_TIME),0.0f);
    00417         glMatrixMode(GL_MODELVIEW);*/
    00418
    00419 //      ManagerTexture->SetTexture(3,m_VecTexture.at(3));
    00420 //      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00421
    00422         glBegin( GL_TRIANGLE_STRIP );
    00423         // Go through all of the rows of the height map
    00424         for ( X = 0; X <= m_MapResolution; X += m_MapDetailLevel )
    00425         {
    00426                 // Check if we need to render the opposite way for this column
    00427                 if(bSwitchSides)
    00428                 {
    00429                         //glColor3f(0.0f,0.0f,1.0f);
    00430                         // Render a column of the terrain, for this current X.
    00431                         // We start at m_MapResolution and render down to 0.
    00432                         for ( Y = m_MapResolution; Y >= 0; Y -= m_MapDetailLevel )
    00433                         {
    00434                                 // Get the (X, Y, Z) value for the bottom left vertex
    00435                                 x = X;//X+=MapdetailLevel
    00436                                 y = Height(X, Y );
    00437                                 z = Y;//Y = m_MapResolution ;Y-=MapdetailLevel
    00438                                 // Set the fog coordinate for this vertex, depending on it's height
    00439                                 // and the current depth of the fog.
    00440                                 if(m_Fog)
    00441                                         y > m_FogDepthLevel ? ManagerFog->SetVolumetricFogCoord(0) : ManagerFog->SetVolumetricFogCoord( -((float)y - m_FogDepthLevel));
    00442
    00443                                 // Set the current texture coordinate and render the vertex
    00444                                 SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00445                                 glVertex3i(x*xmul, y*ymul, z*zmul);
    00446                                 // Get the (X, Y, Z) value for the bottom right vertex
    00447                                 x = X + m_MapDetailLevel;
    00448                                 y = Height(X + m_MapDetailLevel, Y );
    00449                                 z = Y;
    00450                                 // Set the fog coordinate for this vertex
    00451                                 if(m_Fog)
    00452                                         y > m_FogDepthLevel ? ManagerFog->SetVolumetricFogCoord(0) : ManagerFog->SetVolumetricFogCoord( -((float)y - m_FogDepthLevel));
    00453                                 // Set the current texture coordinate and render the vertex
    00454                                 SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00455                                 glVertex3i(x*xmul, y*ymul, z*zmul);
    00456                         }
    00457                 }
    00458                 else
    00459                 {
    00460                         //glColor3f(1.0f,0.0f,0.0f);
    00461                         // Render a column of the terrain, for this current X.
    00462                         // We start at 0 and render down up to m_MapResolution.
    00463                         for ( Y = 0; Y <= m_MapResolution; Y += m_MapDetailLevel )
    00464                         {
    00465                                 // Get the (X, Y, Z) value for the bottom right vertex
    00466                                 x = X + m_MapDetailLevel;
    00467                                 y = Height(X + m_MapDetailLevel, Y );
    00468                                 z = Y;
    00469                                 // Set the fog coordinate for this vertex
    00470                                 if(m_Fog)
    00471                                         y > m_FogDepthLevel ? ManagerFog->SetVolumetricFogCoord(0) : ManagerFog->SetVolumetricFogCoord( -((float)y - m_FogDepthLevel));
    00472                                 // Set the current texture coordinate and render the vertex
    00473                                 SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00474                                 glVertex3i(x, y*ymul, z);
    00475                                 // Get the (X, Y, Z) value for the bottom left vertex
    00476                                 x = X;
    00477                                 y = Height(X, Y );
    00478                                 z = Y;
    00479                                 if(m_Fog)
    00480                                         y > m_FogDepthLevel ? ManagerFog->SetVolumetricFogCoord(0) : ManagerFog->SetVolumetricFogCoord( -((float)y - m_FogDepthLevel));
    00481
    00482                                 // Set the current texture coordinate and render the vertex
    00483                                 SetTextureCoord((float)x / (float)m_MapResolution,-(float)z / (float)m_MapResolution);
    00484                                 glVertex3i(x*xmul, y*ymul, z*zmul);
    00485                         }
    00486                 }
    00487                 // Switch the direction the column renders to allow the fluid tri strips
    00488                 bSwitchSides = !bSwitchSides;
    00489         }
    00490         glEnd();
    00491         if(m_Fog)ManagerFog->DisableFog();
    00492         glMatrixMode(GL_TEXTURE);
    00493                         ManagerTexture->SetTexture(1,m_VecTexture.at(1));
    00494                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00495                 glPopMatrix();
    00496         glMatrixMode(GL_MODELVIEW);
    00497         /*
    00498         glMatrixMode(GL_TEXTURE);
    00499                         ManagerTexture->SetTexture(2,m_VecTexture.at(2));
    00500                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    00501                 glPopMatrix();
    00502         glMatrixMode(GL_MODELVIEW);*/
    00503         ManagerTexture->ResetMultitexture();
    00504 glPopMatrix();
    00505 UnGuard
    00506 }
    00507