12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /*
- Copyright (C) 2015 Marien Raat
- This program 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 3 of the License, or
- (at your option) any later version.
- This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <SFML/Graphics.hpp>
- #include <lightingGenerator.h>
- #include <string>
- #define ONE_LAND_COLOR false
- #define COLOR_WATER sf::Color(0, 0, 200)
- #define COLOR_BEACH sf::Color(255, 255, 0)
- #define COLOR_GRASS sf::Color(0, 255, 0)
- #define COLOR_FOREST sf::Color(0, 150, 0)
- #define COLOR_MOUNTAIN sf::Color(150, 150, 150)
- #define COLOR_ICE sf::Color(255, 255, 255)
- enum MapDisplayType {
- MAP_DISPLAY_TYPE_HEIGHTMAP,
- MAP_DISPLAY_TYPE_SIMPLE_MAP,
- MAP_DISPLAY_TYPE_LAND_MAP,
- MAP_DISPLAY_TYPE_LIGHTED_MAP
- };
- enum SmoothingType {
- SMOOTHING_TYPE_INTERPOLATE,
- SMOOTHING_TYPE_AVERAGE
- };
- class MapDisplayer {
- public:
- MapDisplayer(sf::Vector2u size
- , MapDisplayType mapDisplayType);
- void setMapDisplayType(MapDisplayType mapDisplayType);
- MapDisplayType getMapDisplayType();
- void updateDisplay();
- void setHeightmap(double *heightmap);
- void setHeightmapPassSize(int passSize);
- void setSmoothingType(SmoothingType smoothingType);
- double *normalizedHeightmap;
- void setNamesFont(sf::Font *namesFont);
- void setIslandName(std::string islandName);
- void setLandMap(bool *landMap);
- void setLightMap(Vec3f *lightmap);
- void updateHeightmapDisplay();
- void updateSimpleMapDisplay();
- void updateLandMapDisplay();
- void updateLightMapDisplay();
- void draw(sf::RenderWindow *window);
- private:
- MapDisplayType mapDisplayType;
- SmoothingType smoothingType;
- double *heightmap;
- bool *landMap;
- Vec3f *lightmap;
- int passSize;
- sf::Vector2u size;
- sf::Image heightmapImage, simpleMapImage, landMapImage,
- lightMapImage;
- sf::Texture displayTexture;
- sf::Sprite displaySprite;
- sf::Text islandNameText;
- sf::Color getSimpleMapColor(double value);
- };
|