WaterMapPoints.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <water/WaterMapPoints.h>
00022 #include <water/Water2Patches.h>
00023 #include <graph/ModelRendererSimulator.h>
00024 #include <graph/ModelRendererMesh.h>
00025 #include <landscape/MapPoints.h>
00026 #include <landscapemap/LandscapeMaps.h>
00027 #include <GLEXT/GLGlobalState.h>
00028 #include <client/ScorchedClient.h>
00029 #include <common/OptionsTransient.h>
00030 
00031 WaterMapPoints::WaterMapPoints()
00032 {
00033 }
00034 
00035 WaterMapPoints::~WaterMapPoints()
00036 {
00037 }
00038 
00039 void WaterMapPoints::draw(Water2Patches &currentPatch)
00040 {
00041         GLGlobalState currentState(GLState::TEXTURE_OFF);
00042         for (int i=0; i<(int) pts_.size(); i++)
00043         {
00044                 Vector &current = pts_[i];
00045                 Water2Patch::Data *currentData = 
00046                         currentPatch.getPoint(int(current[0]) / 2, int(current[1]) / 2);
00047 
00048                 glPushMatrix();
00049                         glTranslatef(current[0], current[1], currentData->z + 0.6f);
00050                         glRotatef(currentData->nx * 90.0f, 1.0f, 0.0f, 0.0f);
00051                         glRotatef(currentData->ny * 90.0f, 0.0f, 1.0f, 0.0f);
00052                         glScalef(0.15f, 0.15f, 0.15f);
00053                         switch(ScorchedClient::instance()->getOptionsTransient().getWallType())
00054                         {
00055                         case OptionsTransient::wallWrapAround:
00056                                 MapPoints::instance()->getBorderModelWrap()->draw();
00057                                 break;
00058                         case OptionsTransient::wallBouncy:
00059                                 MapPoints::instance()->getBorderModelBounce()->draw();
00060                                 break;
00061                         case OptionsTransient::wallConcrete:
00062                                 MapPoints::instance()->getBorderModelConcrete()->draw();
00063                                 break;
00064                         default:
00065                                 break;
00066                         }
00067                 glPopMatrix();
00068         }
00069 }
00070 
00071 void WaterMapPoints::generate()
00072 {
00073         pts_.clear();
00074 
00075         int arenaX = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaX();
00076         int arenaY = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaY();
00077         int arenaWidth = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaWidth();
00078         int arenaHeight = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaHeight();
00079 
00080         int pointsX = arenaWidth / 32; // Each point is 32 units appart
00081         int pointsY = arenaHeight / 32; // Each point is 32 units appart
00082         
00083         int i;
00084         for (i=0; i<=pointsX; i++)
00085         {
00086                 int pos = 32 * i;
00087 
00088                 pts_.push_back(Vector(arenaX + pos, arenaY));
00089                 pts_.push_back(Vector(arenaX + pos, arenaY + arenaHeight));
00090         }
00091         for (i=1; i<=pointsY-1; i++)
00092         {
00093                 int pos = 32 * i;
00094 
00095                 pts_.push_back(Vector(arenaX, arenaY + pos));
00096                 pts_.push_back(Vector(arenaX + arenaWidth, arenaY + pos));
00097         }
00098 }

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3