//////////////////////////////////////////////////////////////////////////////// // Scorched3D (c) 2000-2003 // // This file is part of Scorched3D. // // Scorched3D is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // Scorched3D is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Scorched3D; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include InfoMap *InfoMap::instance_ = 0; InfoMap *InfoMap::instance() { if (!instance_) { instance_ = new InfoMap; } return instance_; } InfoMap::InfoMap() { new GLConsoleRuleMethodIAdapter( Landscape::instance(), &Landscape::restoreLandscapeTexture, "LandscapeInfoOff"); new GLConsoleRuleMethodIAdapter( this, &InfoMap::showHeightBands, "LandscapeInfoHeightBands"); new GLConsoleRuleMethodIAdapter( this, &InfoMap::showGrid, "LandscapeInfoGrid"); } InfoMap::~InfoMap() { } void InfoMap::showHeightBands() { GLBitmap newMap( Landscape::instance()->getMainMap().getWidth(), Landscape::instance()->getMainMap().getHeight()); float *heights = new float[ Landscape::instance()->getMainMap().getWidth() * Landscape::instance()->getMainMap().getHeight()]; const float width = (float) ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getMapWidth(); const float height = (float) ScorchedClient::instance()->getLandscapeMaps().getGroundMaps().getMapHeight(); const float sqSizeWidth = width / float(newMap.getWidth()); const float sqSizeHeight = height / float(newMap.getHeight()); const float heightSep = 3.0f; int y; for (y=0; ygetLandscapeMaps(). getGroundMaps().getInterpHeight(posX, posY); } } GLubyte *dest = newMap.getBits(); GLubyte *src = Landscape::instance()->getMainMap().getBits(); for (y=0; y baseHeight2 || baseHeight > baseHeight3 || baseHeight > baseHeight4 || baseHeight > baseHeight5) { r = g = b = 255; } } dest[0] = r; dest[1] = g; dest[2] = b; dest+=3; src+=3; } } Landscape::instance()->getMainTexture().replace(newMap, GL_RGB, false); Landscape::instance()->setTextureType(Landscape::eOther); delete [] heights; } void InfoMap::showGrid() { GLBitmap newMap( Landscape::instance()->getMainMap().getWidth(), Landscape::instance()->getMainMap().getHeight()); GLubyte *dest = newMap.getBits(); GLubyte *src = Landscape::instance()->getMainMap().getBits(); for (int y=0; ygetMainTexture().replace(newMap, GL_RGB, false); Landscape::instance()->setTextureType(Landscape::eOther); }