Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / client / r2_islands_textures / screenshot_islands.h
blobbb3df34b149ad8f9a36f09e5328c28b1908e3251
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef CL_SCRRENSHOT_ISLANDS_H
21 #define CL_SCRRENSHOT_ISLANDS_H
23 // Misc
24 #include "nel/misc/singleton.h"
25 #include "nel/misc/vector_2f.h"
26 #include "nel/misc/rgba.h"
27 #include "nel/misc/bitmap.h"
29 #include <stdio.h>
31 namespace NL3D
33 class UScene;
34 class ULandscape;
37 namespace R2
39 class CProximityZone;
41 typedef uint16 TBufferEntry;
42 typedef std::vector<TBufferEntry> TBuffer;
43 typedef std::vector<uint32> TOffsetsVector;
45 //-----------------------------------------------------------------------------
46 // class CScreenshotIslands
47 //-----------------------------------------------------------------------------
48 struct CIslandData
50 NLMISC::CVector2f EntryPoint;
51 NLMISC::CVector2f Max;
52 NLMISC::CVector2f Min;
54 CIslandData()
56 EntryPoint = NLMISC::CVector2f(0, 0);
57 Max = NLMISC::CVector2f(0, 0);
58 Min = NLMISC::CVector2f(0, 0);
61 CIslandData(float x, float y)
63 EntryPoint = NLMISC::CVector2f(x, y);
64 Max = NLMISC::CVector2f(0, 0);
65 Min = NLMISC::CVector2f(0, 0);
69 struct CContinentData
71 std::string SmallBank;
72 std::string FarBank;
73 std::string IGFile;
74 std::string CoarseMeshMap;
75 NLMISC::CVector2f ZoneMin;
76 NLMISC::CVector2f ZoneMax;
77 std::list< std::string > Islands;
78 NLMISC::CRGBA Ambiant;
79 NLMISC::CRGBA Diffuse;
81 CContinentData() {}
84 typedef std::map< const std::string, CProximityZone> TIslandsData;
85 typedef std::map< NLMISC::CVector2f, bool > TIslandsMap;
86 typedef std::map< const std::string, CContinentData > TContinentsData;
87 typedef std::map< std::string, std::list< NLMISC::CVector2f > > TIslandsBordersMap;
89 class CScreenshotIslands : public NLMISC::CSingleton<CScreenshotIslands>
92 public:
94 CScreenshotIslands();
96 void buildScreenshots();
98 private:
100 void init();
102 void loadIslands();
104 void buildIslandsTextures();
106 void getBuffer(NL3D::UScene * scene, NL3D::ULandscape * landscape, NLMISC::CBitmap &btm);
108 bool getPosFromZoneName(const std::string &name, NLMISC::CVector2f &dest);
110 void writeProximityBufferToTgaFile(const std::string& fileName,const TBuffer& buffer,
111 uint32 scanWidth,uint32 scanHeight);
113 void processProximityBuffer(TBuffer& inputBuffer, uint32 lineLength, TBuffer& resultBuffer);
115 void buildBackTextureHLS(const std::string & islandName, const NLMISC::CBitmap & islandBitmap);
117 void searchIslandsBorders();
119 void attenuateIslandBorders(const std::string & islandName, NLMISC::CBitmap & islandBitmap, const CProximityZone & islandData);
121 TIslandsData _IslandsData;
122 TIslandsMap _IslandsMap;
123 TContinentsData _ContinentsData;
124 std::list< std::string > _SeasonSuffixes;
125 int _MeterPixelSize;
126 std::string _OutDirectory;
127 std::list< std::string > _TempFileNames;
128 TIslandsBordersMap _BorderIslands;
129 bool _Vegetation;
130 bool _InverseZTest;
132 NLMISC::CRGBA _BackColor;
133 NLMISC::CBitmap _BackBitmap;
134 std::string _CompleteIslandsFile;
142 class CProximityZone
144 public:
145 typedef std::vector<uint32> TOffsets;
147 // ctor
148 // scanWidth and scanHeight define the dimentions of the buffer that this zone is being extracted from
149 // xOffset and yOffset are for re-mapping coordinates from buffer-relative to absolute ryzom world coordinates
150 CProximityZone(uint32 scanWidth=0,uint32 scanHeight=0,sint32 xOffset=0, sint32 yOffset=0);
152 // add an 'accessible position' to a zone (offset is y*scanWidth+x)
153 bool add(uint32 offset);
155 // zone dimention accessors (note that zone dimentions line up with 160x160 world zones)
156 // note that this means that the zone bounds may extend outside the scan area
157 uint32 getZoneWidth() const;
158 uint32 getZoneHeight() const;
159 sint32 getZoneXMin() const;
160 sint32 getZoneYMin() const;
161 uint32 getZoneXMax() const;
162 uint32 getZoneYMax() const;
164 // read accessors for the bounding limits that define the area occupied by the accessible points
165 uint32 getBoundXMin() const;
166 uint32 getBoundYMin() const;
167 uint32 getBoundXMax() const;
168 uint32 getBoundYMax() const;
170 // read accessor for the _Offsets vector
171 // this is a vector of offsets into the scan area. It needs to be remapped to zone offsets
172 // via the remapOffset() routine in order to be used to index into a zone buffer
173 const TOffsets& getOffsets() const;
175 // remap a scan buffer offset to a zone offset by decomposing into x and y parts and
176 // subtracting getZoneXMin() and getZoneYMin()
177 uint32 remapOffset(uint32 bufferOffset) const;
179 private:
180 // parameters setup at construction time, giving info on the context that we're in
181 uint32 _ScanWidth;
182 uint32 _ScanHeight;
183 sint32 _XOffset;
184 sint32 _YOffset;
185 uint32 _MaxOffset;
187 // the vector of points that are part of this zone
188 TOffsets _Offsets;
190 // the min and max coords of the points that are part of this zone
191 uint32 _XMax;
192 uint32 _XMin;
193 uint32 _YMax;
194 uint32 _YMin;
196 // border add to bouding zone (pixels number)
197 int _BorderPixels;
200 //-------------------------------------------------------------------------------------------------
201 // class CProximityMapBuffer
202 //-------------------------------------------------------------------------------------------------
204 class CProximityMapBuffer
206 public:
207 typedef std::vector<CProximityZone> TZones;
209 // load a cwmap2 file and setup this object from its contents
210 // the 'name' parameter is the full file name of the file to load with path and extension
211 void load(const std::string& name);
213 // scan the buffer to generate the set of non-connecting zones that it contains
214 void calculateZones(TZones& zones);
216 // generate the proximity map for a given zone
217 void generateZoneProximityMap(const CProximityZone& zone,TBuffer& zoneBuffer);
219 // read accessors...
220 const TBuffer& getBuffer() const;
221 uint32 getScanHeight() const;
222 uint32 getScanWidth() const;
224 // buffer coordinate to world coordinate offsets...
225 sint32 _XOffset;
226 sint32 _YOffset;
228 private:
229 // private routine used by generateZoneProximityMap() to setup the zoneBuffer with the accessible points set
230 void _prepareBufferForZoneProximityMap(const CProximityZone& zone,TBuffer& zoneBuffer,TOffsetsVector& accessiblePoints);
232 private:
233 // the width and heilght of the scan zone (ie the dimentions of the buffer)
234 uint32 _ScanWidth;
235 uint32 _ScanHeight;
237 // vector representing 2d array of points [_ScanHeight][_ScanWidth]
238 TBuffer _Buffer;
244 #endif