Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / leveldesign / export / export.h
blob2b55b0eb07d07b645882b6efa598d723a23be106
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef LD_EXPORT_H
18 #define LD_EXPORT_H
20 // ---------------------------------------------------------------------------
22 #include "nel/misc/config_file.h"
23 #include "nel/misc/vector.h"
24 #include <string>
25 #include <vector>
27 // ---------------------------------------------------------------------------
29 namespace NLLIGO
31 class CPrimZone;
32 class CPrimPoint;
33 class CPrimPath;
36 namespace NL3D
38 class CLandscape;
39 class CVisualCollisionManager;
40 class CVisualCollisionEntity;
43 struct SPlantInstance;
44 struct SFormPlant;
46 // ---------------------------------------------------------------------------
48 // ---------------------------------------------------------------------------
49 // Export options
50 // ---------------------------------------------------------------------------
51 struct SExportOptions
53 std::string InLandscapeDir; // Directory where to get .zonew files
54 std::string OutIGDir; // Directory where to put IG
55 std::string LandBankFile; // The .smallbank file associated with the landscape
56 std::string LandFarBankFile; // The .farbank file
57 float CellSize; // Typically 160.0
58 std::string LandTileNoiseDir; // Directory where to get displacement map
60 std::string PrimFloraDir; // Directory to parse for .flora and .prim associated
61 // This is here we get continent.cfg file
63 // Not read for the moment
64 std::string LandFile; // The .land file to get the mask and date of zones
65 std::string DfnDir; // Directory to get georges dfn
66 std::string GameElemDir; // Directory to get georges file (pipoti.plant)
68 // =======================================================================
70 SExportOptions ();
71 bool loadcf (NLMISC::CConfigFile &cf);
72 bool save (FILE *f);
75 // ---------------------------------------------------------------------------
76 // Export callback
77 // ---------------------------------------------------------------------------
78 class IExportCB
80 public:
81 virtual bool isCanceled () = 0; // Tell the exporter if it must end as quick as possible
82 // Display callbacks
83 virtual void dispPass (const std::string &Text) = 0; // Pass (generate land, flora, etc...)
84 virtual void dispPassProgress (float percentage) = 0; // [ 0.0 , 1.0 ]
85 virtual void dispInfo (const std::string &Text) = 0; // Verbose
86 virtual void dispWarning (const std::string &Text) = 0; // Error but not critical
87 virtual void dispError (const std::string &Text) = 0; // Should block (misfunction)
90 // ---------------------------------------------------------------------------
91 // Export Patat
92 // ---------------------------------------------------------------------------
93 struct SExportPrimitive
95 std::string FullPrimName;
96 std::string PrimitiveName;
98 bool operator == (const SExportPrimitive &rRightArg);
101 // ---------------------------------------------------------------------------
102 // Flora export
103 // ---------------------------------------------------------------------------
104 struct SFloraInst
106 NLMISC::CVector Pos;
107 float Rot;
108 float Scale;
110 float Radius;
111 std::string ShapeName; // the .shape stored in the name field of the instance (that represents the shape name)
112 std::string PlantName; // the .plant associated which is stored in the instance name
115 // ---------------------------------------------------------------------------
116 // Export class
117 // ---------------------------------------------------------------------------
118 class CExport
121 public:
123 CExport ();
124 ~CExport ();
126 // EXPORT one region :
127 // Parse the SourceDir find the .land and .prim
128 // newExport is the incremental export
129 bool newExport (SExportOptions &options, IExportCB *expCB = NULL);
130 bool doExport (SExportOptions &options, IExportCB *expCB = NULL, std::vector<SExportPrimitive> *selection = NULL);
132 // HELPERS
133 // Get All files with the extension ext in the current directory and subdirectory
134 static void getAllFiles (const std::string &ext, std::vector<std::string> &files);
135 // Search a file through all subdirectories of the current one (and in the current too)
136 static bool searchFile (const std::string &plantName, std::string &dir);
138 private:
140 SExportOptions *_Options;
141 IExportCB *_ExportCB;
143 // Temp data to generate ig
144 NL3D::CLandscape *_Landscape;
145 NL3D::CVisualCollisionManager *_VCM;
146 NL3D::CVisualCollisionEntity *_VCE;
148 std::vector<SFloraInst> _FloraInsts;
150 std::string _ExeDir;
151 std::string _LandFile;
152 std::string _GameElemDir;
153 std::string _DfnDir;
155 std::string _InLandscapeDir; // Directory where to get .zonew files
156 std::string _OutIGDir; // Directory where to put IG
157 std::string _LandBankFile; // The .smallbank file associated with the landscape
158 std::string _LandFarBankFile; // The .farbank file
159 std::string _LandTileNoiseDir; // Directory where to get displacement map
161 private:
163 struct SFloraToUpdate
165 std::string FloraFile;
166 std::vector<std::string> PrimFile;
169 struct SPrimToUpdate
171 std::string PrimFile;
172 std::vector<std::string> FloraFile;
175 // All the functions to generate the igs from flora
176 // ************************************************
178 // Entry point
179 bool generateIGFromFlora (const std::string &SrcFile, std::vector<SExportPrimitive> *selection = NULL);
181 // Get the altitude from the position in 2D
182 float getZFromXY (float x, float y);
184 // Does the plant is well placed
185 bool isWellPlaced (NLMISC::CVector &pos, SPlantInstance &rPI, SFormPlant &rFP, float scale);
187 // Write zone by zone the instance group of the flora generated in the specific land
188 void writeFloraIG (const std::string &LandFile, bool bTestForWriting = false);
190 // Helpers
191 // *******
193 // Load all zones of a .land
194 void loadLandscape (const std::string &name);
196 bool segmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
197 void delIGZone (sint32 x, sint32 y);
198 void delAllIGZoneUnderPatat (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir);
199 void delAllIGZoneUnderPoint (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir);
200 void delAllIGZoneUnderPath (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir);
201 bool isPatatNeedUpdate (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir);
202 bool isPathNeedUpdate (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir);
203 bool isPointNeedUpdate (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir);
206 public:
208 static std::string getZoneNameFromXY (sint32 x, sint32 y);
209 static sint32 getXFromZoneName (const std::string &ZoneName);
210 static sint32 getYFromZoneName (const std::string &ZoneName);
214 #endif // LD_EXPORT_H