LandscapePoints.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 <landscape/LandscapePoints.h>
00022 #include <landscapemap/LandscapeMaps.h>
00023 #include <landscape/MapPoints.h>
00024 #include <client/ScorchedClient.h>
00025 #include <common/OptionsTransient.h>
00026 #include <graph/ModelRendererSimulator.h>
00027 #include <graph/ModelRendererMesh.h>
00028 #include <GLEXT/GLGlobalState.h>
00029 
00030 LandscapePoints::LandscapePoints()
00031 {
00032 }
00033 
00034 LandscapePoints::~LandscapePoints()
00035 {
00036 }
00037 
00038 void LandscapePoints::draw()
00039 {
00040         GLGlobalState currentState(GLState::TEXTURE_OFF);
00041         for (int i=0; i<(int) points_.size(); i++)
00042         {
00043                 Vector &current = points_[i];
00044                 current[2] = 
00045                         ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getHeight(
00046                                 (int) current[0], (int) current[1]).asFloat();
00047                 glPushMatrix();
00048                         glTranslatef(current[0], current[1], current[2]);
00049                         glScalef(0.15f, 0.15f, 0.15f);
00050                         switch(ScorchedClient::instance()->getOptionsTransient().getWallType())
00051                         {
00052                         case OptionsTransient::wallWrapAround:
00053                                 MapPoints::instance()->getBorderModelWrap()->draw();
00054                                 break;
00055                         case OptionsTransient::wallBouncy:
00056                                 MapPoints::instance()->getBorderModelBounce()->draw();
00057                                 break;
00058                         case OptionsTransient::wallConcrete:
00059                                 MapPoints::instance()->getBorderModelConcrete()->draw();
00060                                 break;
00061                         default:
00062                                 break;
00063                         }
00064                 glPopMatrix();
00065         }
00066 }
00067 
00068 void LandscapePoints::generate()
00069 {
00070         points_.clear();
00071 
00072         int arenaX = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaX();
00073         int arenaY = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaY();
00074         int arenaWidth = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaWidth();
00075         int arenaHeight = ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getArenaHeight();
00076 
00077         int pointsX = arenaWidth / 32; // Each point is 32 units appart
00078         int pointsY = arenaHeight / 32; // Each point is 32 units appart
00079         
00080         int i;
00081         for (i=0; i<=pointsX; i++)
00082         {
00083                 int pos = 32 * i;
00084 
00085                 points_.push_back(Vector(arenaX + pos, arenaY));
00086                 points_.push_back(Vector(arenaX + pos, arenaY + arenaHeight));
00087         }
00088         for (i=1; i<=pointsY-1; i++)
00089         {
00090                 int pos = 32 * i;
00091 
00092                 points_.push_back(Vector(arenaX, arenaY + pos));
00093                 points_.push_back(Vector(arenaX + arenaWidth, arenaY + pos));
00094         }
00095 }
00096 

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