1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
20 // ---------------------------------------------------------------------------
22 #include "nel/misc/config_file.h"
23 #include "nel/misc/vector.h"
27 // ---------------------------------------------------------------------------
39 class CVisualCollisionManager
;
40 class CVisualCollisionEntity
;
43 struct SPlantInstance
;
46 // ---------------------------------------------------------------------------
48 // ---------------------------------------------------------------------------
50 // ---------------------------------------------------------------------------
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 // =======================================================================
71 bool loadcf (NLMISC::CConfigFile
&cf
);
75 // ---------------------------------------------------------------------------
77 // ---------------------------------------------------------------------------
81 virtual bool isCanceled () = 0; // Tell the exporter if it must end as quick as possible
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 // ---------------------------------------------------------------------------
92 // ---------------------------------------------------------------------------
93 struct SExportPrimitive
95 std::string FullPrimName
;
96 std::string PrimitiveName
;
98 bool operator == (const SExportPrimitive
&rRightArg
);
101 // ---------------------------------------------------------------------------
103 // ---------------------------------------------------------------------------
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 // ---------------------------------------------------------------------------
117 // ---------------------------------------------------------------------------
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
);
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
);
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
;
151 std::string _LandFile
;
152 std::string _GameElemDir
;
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
163 struct SFloraToUpdate
165 std::string FloraFile
;
166 std::vector
<std::string
> PrimFile
;
171 std::string PrimFile
;
172 std::vector
<std::string
> FloraFile
;
175 // All the functions to generate the igs from flora
176 // ************************************************
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);
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
);
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