From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/landscape__user_8cpp-source.html | 516 ++++++++++++++++++++++ 1 file changed, 516 insertions(+) create mode 100644 docs/doxygen/nel/landscape__user_8cpp-source.html (limited to 'docs/doxygen/nel/landscape__user_8cpp-source.html') diff --git a/docs/doxygen/nel/landscape__user_8cpp-source.html b/docs/doxygen/nel/landscape__user_8cpp-source.html new file mode 100644 index 00000000..86346162 --- /dev/null +++ b/docs/doxygen/nel/landscape__user_8cpp-source.html @@ -0,0 +1,516 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

landscape_user.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 #include "3d/landscape_user.h"
+00029 #include "nel/misc/file.h"
+00030 #include "nel/misc/path.h"
+00031 #include "nel/misc/hierarchical_timer.h"
+00032 
+00033 using namespace NLMISC;
+00034 
+00035 namespace NL3D
+00036 {
+00037 
+00038 H_AUTO_DECL( NL3D_UI_Landscape )
+00039 H_AUTO_DECL( NL3D_Render_Landscape_updateLightingAll )
+00040 H_AUTO_DECL( NL3D_Load_Landscape )
+00041 
+00042 #define NL3D_HAUTO_UI_LANDSCAPE                                         H_AUTO_USE( NL3D_UI_Landscape )
+00043 #define NL3D_HAUTO_LANDSCAPE_UPDATE_LIGHTING_ALL        H_AUTO_USE( NL3D_Render_Landscape_updateLightingAll )
+00044 #define NL3D_HAUTO_LOAD_LANDSCAPE                                       H_AUTO_USE( NL3D_Load_Landscape )
+00045 
+00046 
+00047 //****************************************************************************
+00048 void    CLandscapeUser::setZonePath(const std::string &zonePath)
+00049 {
+00050         NL3D_MEM_LANDSCAPE
+00051         NL3D_HAUTO_UI_LANDSCAPE;
+00052         _ZoneManager.setZonePath(zonePath);
+00053 }
+00054 //****************************************************************************
+00055 void    CLandscapeUser::loadBankFiles(const std::string &tileBankFile, const std::string &farBankFile)
+00056 {
+00057         NL3D_MEM_LANDSCAPE
+00058         NL3D_HAUTO_LOAD_LANDSCAPE;
+00059 
+00060         // First, load the banks.
+00061         //=======================
+00062         CIFile bankFile(CPath::lookup(tileBankFile));
+00063         _Landscape->Landscape.TileBank.serial(bankFile);
+00064         // All textures path are relative!
+00065         _Landscape->Landscape.TileBank.makeAllPathRelative();
+00066         // Use DDS!!!
+00067         _Landscape->Landscape.TileBank.makeAllExtensionDDS();
+00068         // No absolute path
+00069         _Landscape->Landscape.TileBank.setAbsPath ("");
+00070 
+00071         // After loading the TileBank, and before initTileBanks(), must load the vegetables descritpor
+00072         _Landscape->Landscape.TileBank.loadTileVegetableDescs();
+00073 
+00074         CIFile farbankFile(CPath::lookup(farBankFile));
+00075         _Landscape->Landscape.TileFarBank.serial(farbankFile);
+00076         if ( ! _Landscape->Landscape.initTileBanks() )
+00077         {
+00078                 nlwarning( "You need to recompute bank.farbank for the far textures" );
+00079         }
+00080         bankFile.close();
+00081         farbankFile.close();
+00082 
+00083 
+00084         // Second, temporary, flushTiles.
+00085         //===============================
+00086         sint    ts;
+00087         for (ts=0; ts<_Landscape->Landscape.TileBank.getTileSetCount (); ts++)
+00088         {
+00089                 CTileSet *tileSet=_Landscape->Landscape.TileBank.getTileSet (ts);
+00090                 sint tl;
+00091                 for (tl=0; tl<tileSet->getNumTile128(); tl++)
+00092                         _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTile128(tl), 1);
+00093                 for (tl=0; tl<tileSet->getNumTile256(); tl++)
+00094                         _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTile256(tl), 1);
+00095                 for (tl=0; tl<CTileSet::count; tl++)
+00096                         _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTransition(tl)->getTile (), 1);
+00097         }
+00098 
+00099 }
+00100 
+00101 
+00102 //****************************************************************************
+00103 void    CLandscapeUser::loadAllZonesAround(const CVector &pos, float radius, std::vector<std::string> &zonesAdded)
+00104 {
+00105         NL3D_MEM_LANDSCAPE
+00106         NL3D_HAUTO_LOAD_LANDSCAPE;
+00107 
+00108         zonesAdded.clear();
+00109 
+00110         _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);
+00111         while (_ZoneManager.isWorking())
+00112         {
+00113                 CZoneManager::SZoneManagerWork Work;
+00114                 if (_ZoneManager.isWorkComplete(Work))
+00115                 {
+00116                         nlassert(!Work.ZoneRemoved);
+00117                         if (Work.ZoneAdded)
+00118                         {
+00119                                 if (Work.Zone == (CZone*)-1)
+00120                                 {
+00121                                         nlwarning ("Can't load zone %s", Work.NameZoneAdded.c_str ());
+00122                                 }
+00123                                 else
+00124                                 {
+00125                                         _Landscape->Landscape.addZone (*Work.Zone);
+00126 
+00127                                         delete Work.Zone;
+00128                                         std::string zoneadd = Work.NameZoneAdded;
+00129                                         zoneadd = zoneadd.substr(0, zoneadd.find('.'));
+00130                                         zonesAdded.push_back(zoneadd);
+00131                                 }
+00132                         }
+00133                 }
+00134                 else
+00135                 {
+00136                         nlSleep (1);
+00137                 }
+00138                 _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);
+00139         }
+00140         // Yoyo: must check the binds of the zones.
+00141         _Landscape->Landscape.checkBinds();
+00142 }
+00143 
+00144 //****************************************************************************
+00145 void    CLandscapeUser::refreshAllZonesAround(const CVector &pos, float radius, std::vector<std::string> &zonesAdded, std::vector<std::string> &zonesRemoved)
+00146 {
+00147         NL3D_MEM_LANDSCAPE
+00148         NL3D_HAUTO_LOAD_LANDSCAPE;
+00149 
+00150         zonesAdded.clear();
+00151         zonesRemoved.clear();
+00152         std::string             za, zr;
+00153 
+00154         _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);
+00155         while (_ZoneManager.isWorking())
+00156         {
+00157                 refreshZonesAround (pos, radius, za, zr);
+00158 
+00159                 // some zone added or removed??
+00160                 if(za != "")
+00161                         zonesAdded.push_back(za);
+00162                 if(zr != "")
+00163                         zonesRemoved.push_back(zr);
+00164                 
+00165                 _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);
+00166         }
+00167 }
+00168 
+00169 // ***************************************************************************
+00170 void    CLandscapeUser::getAllZoneLoaded(std::vector<std::string>       &zoneLoaded) const
+00171 {
+00172         NL3D_MEM_LANDSCAPE
+00173         // Build the list of zoneId.
+00174         std::vector<uint16>     zoneIds;
+00175         _Landscape->Landscape.getZoneList(zoneIds);
+00176 
+00177         // transcript
+00178         zoneLoaded.clear();
+00179         zoneLoaded.resize(zoneIds.size());
+00180         for(uint i=0;i<zoneLoaded.size();i++)
+00181         {
+00182                 CLandscape::buildZoneName(zoneIds[i], zoneLoaded[i]);
+00183         }
+00184 }
+00185 
+00186 //****************************************************************************
+00187 void    CLandscapeUser::loadAllZonesAround(const CVector &pos, float radius)
+00188 {
+00189         NL3D_MEM_LANDSCAPE
+00190         std::vector<std::string>        dummy;
+00191         loadAllZonesAround(pos, radius, dummy);
+00192 }
+00193 
+00194 
+00195 //****************************************************************************
+00196 void    CLandscapeUser::refreshZonesAround(const CVector &pos, float radius)
+00197 {
+00198         NL3D_MEM_LANDSCAPE
+00199         NL3D_HAUTO_LOAD_LANDSCAPE;
+00200 
+00201         std::string     dummy1, dummy2;
+00202         refreshZonesAround(pos, radius, dummy1, dummy2);
+00203 }
+00204 //****************************************************************************
+00205 void    CLandscapeUser::refreshZonesAround(const CVector &pos, float radius, std::string &zoneAdded, std::string &zoneRemoved)
+00206 {
+00207         NL3D_MEM_LANDSCAPE
+00208         NL3D_HAUTO_LOAD_LANDSCAPE;
+00209 
+00210         zoneRemoved= "";
+00211         zoneAdded= "";
+00212         CZoneManager::SZoneManagerWork Work;
+00213         // Check if new zone must be added to landscape
+00214         if (_ZoneManager.isWorkComplete(Work))
+00215         {
+00216                 if (Work.ZoneAdded)
+00217                 {
+00218                         if (Work.Zone == (CZone*)-1)
+00219                         {
+00220                                 nlwarning ("Can't load zone %s", Work.NameZoneAdded.c_str ());
+00221                         }
+00222                         else
+00223                         {
+00224                                 _Landscape->Landscape.addZone(*Work.Zone);
+00225 
+00226                                 // Yoyo: must check the binds of the new inserted zone.
+00227                                 try
+00228                                 {
+00229                                         _Landscape->Landscape.checkBinds(Work.Zone->getZoneId());
+00230                                 }
+00231                                 catch (EBadBind &e)
+00232                                 {
+00233                                         nlwarning ("Bind error : %s", e.what());
+00234                                 }
+00235 
+00236                                 delete Work.Zone;
+00237                                 zoneAdded = Work.NameZoneAdded;
+00238                                 zoneAdded = zoneAdded.substr(0, zoneAdded.find('.'));
+00239                         }
+00240                 }
+00241 
+00242                 // Check if a zone must be removed from landscape
+00243                 if (Work.ZoneRemoved)
+00244                 {
+00245                         _Landscape->Landscape.removeZone (Work.IdZoneToRemove);
+00246                         zoneRemoved = Work.NameZoneRemoved;
+00247                         zoneRemoved = zoneRemoved.substr(0, zoneRemoved.find('.'));
+00248                 }
+00249         }
+00250 
+00251         _ZoneManager.checkZonesAround((uint)pos.x, (uint)(-pos.y), (uint)radius);
+00252 }
+00253 
+00254 
+00255 //****************************************************************************
+00256 void    CLandscapeUser::setupStaticLight (const CRGBA &diffuse, const CRGBA &ambiant, float multiply)
+00257 {
+00258         NL3D_MEM_LANDSCAPE
+00259         NL3D_HAUTO_UI_LANDSCAPE;
+00260         _Landscape->Landscape.setupStaticLight(diffuse, ambiant, multiply);
+00261 }
+00262 
+00263 
+00264 
+00265 //****************************************************************************
+00266 void    CLandscapeUser::setThreshold (float thre)
+00267 {
+00268         NL3D_MEM_LANDSCAPE
+00269         NL3D_HAUTO_UI_LANDSCAPE;
+00270         _Landscape->Landscape.setThreshold(thre);
+00271 }
+00272 //****************************************************************************
+00273 float   CLandscapeUser::getThreshold () const
+00274 {
+00275         NL3D_MEM_LANDSCAPE
+00276         NL3D_HAUTO_UI_LANDSCAPE;
+00277         return _Landscape->Landscape.getThreshold();
+00278 }
+00279 //****************************************************************************
+00280 void    CLandscapeUser::setTileNear (float tileNear)
+00281 {
+00282         NL3D_MEM_LANDSCAPE
+00283         NL3D_HAUTO_UI_LANDSCAPE;
+00284         _Landscape->Landscape.setTileNear(tileNear);
+00285 }
+00286 //****************************************************************************
+00287 float   CLandscapeUser::getTileNear () const
+00288 {
+00289         NL3D_MEM_LANDSCAPE
+00290         NL3D_HAUTO_UI_LANDSCAPE;
+00291         return _Landscape->Landscape.getTileNear();
+00292 }
+00293 //****************************************************************************
+00294 void    CLandscapeUser::setTileMaxSubdivision (uint tileDiv)
+00295 {
+00296         NL3D_MEM_LANDSCAPE
+00297         NL3D_HAUTO_UI_LANDSCAPE;
+00298         _Landscape->Landscape.setTileMaxSubdivision(tileDiv);
+00299 }
+00300 //****************************************************************************
+00301 uint    CLandscapeUser::getTileMaxSubdivision ()
+00302 {
+00303         NL3D_MEM_LANDSCAPE
+00304         NL3D_HAUTO_UI_LANDSCAPE;
+00305         return _Landscape->Landscape.getTileMaxSubdivision();
+00306 }
+00307 
+00308 
+00309 //****************************************************************************
+00310 std::string     CLandscapeUser::getZoneName(const CVector &pos)
+00311 {
+00312         NL3D_MEM_LANDSCAPE
+00313         NL3D_HAUTO_UI_LANDSCAPE;
+00314         return _ZoneManager.getZoneName((uint)pos.x, (uint)(-pos.y), 0, 0).first;
+00315 }
+00316 
+00317 
+00318 //****************************************************************************
+00319 CVector         CLandscapeUser::getHeightFieldDeltaZ(float x, float y) const
+00320 {
+00321         NL3D_MEM_LANDSCAPE
+00322         NL3D_HAUTO_UI_LANDSCAPE;
+00323         return _Landscape->Landscape.getHeightFieldDeltaZ(x,y);
+00324 }
+00325 
+00326 //****************************************************************************
+00327 void            CLandscapeUser::setHeightField(const CHeightMap &hf)
+00328 {
+00329         NL3D_MEM_LANDSCAPE
+00330         NL3D_HAUTO_UI_LANDSCAPE;
+00331         _Landscape->Landscape.setHeightField(hf);
+00332 }
+00333 
+00334 
+00335 //****************************************************************************
+00336 void            CLandscapeUser::enableVegetable(bool enable)
+00337 {
+00338         NL3D_MEM_LANDSCAPE
+00339         NL3D_HAUTO_UI_LANDSCAPE;
+00340         _Landscape->Landscape.enableVegetable(enable);
+00341 }
+00342 
+00343 //****************************************************************************
+00344 void            CLandscapeUser::loadVegetableTexture(const std::string &textureFileName)
+00345 {
+00346         NL3D_MEM_LANDSCAPE
+00347         NL3D_HAUTO_LOAD_LANDSCAPE;
+00348         _Landscape->Landscape.loadVegetableTexture(textureFileName);
+00349 }
+00350 
+00351 //****************************************************************************
+00352 void            CLandscapeUser::setupVegetableLighting(const CRGBA &ambient, const CRGBA &diffuse, const CVector &directionalLight)
+00353 {
+00354         NL3D_MEM_LANDSCAPE
+00355         NL3D_HAUTO_UI_LANDSCAPE;
+00356         _Landscape->Landscape.setupVegetableLighting(ambient, diffuse, directionalLight);
+00357 }
+00358 
+00359 //****************************************************************************
+00360 void            CLandscapeUser::setVegetableWind(const CVector &windDir, float windFreq, float windPower, float windBendMin)
+00361 {
+00362         NL3D_MEM_LANDSCAPE
+00363         NL3D_HAUTO_UI_LANDSCAPE;
+00364         _Landscape->Landscape.setVegetableWind(windDir, windFreq, windPower, windBendMin);
+00365 }
+00366 
+00367 //****************************************************************************
+00368 void            CLandscapeUser::setVegetableUpdateLightingFrequency(float freq)
+00369 {
+00370         NL3D_MEM_LANDSCAPE
+00371         NL3D_HAUTO_UI_LANDSCAPE;
+00372         _Landscape->Landscape.setVegetableUpdateLightingFrequency(freq);
+00373 }
+00374 
+00375 
+00376 //****************************************************************************
+00377 void            CLandscapeUser::setPointLightFactor(const std::string &lightGroupName, NLMISC::CRGBA nFactor)
+00378 {
+00379         NL3D_MEM_LANDSCAPE
+00380         NL3D_HAUTO_UI_LANDSCAPE;
+00381         _Landscape->Landscape.setPointLightFactor(lightGroupName, nFactor);
+00382 }
+00383 
+00384 //****************************************************************************
+00385 void            CLandscapeUser::setUpdateLightingFrequency(float freq)
+00386 {
+00387         NL3D_MEM_LANDSCAPE
+00388         NL3D_HAUTO_UI_LANDSCAPE;
+00389         _Landscape->Landscape.setUpdateLightingFrequency(freq);
+00390 }
+00391 
+00392 
+00393 //****************************************************************************
+00394 void            CLandscapeUser::enableAdditive (bool enable)
+00395 {
+00396         NL3D_MEM_LANDSCAPE
+00397         NL3D_HAUTO_UI_LANDSCAPE;
+00398         _Landscape->enableAdditive(enable);
+00399 }
+00400 //****************************************************************************
+00401 bool            CLandscapeUser::isAdditiveEnabled () const
+00402 {
+00403         NL3D_MEM_LANDSCAPE
+00404         NL3D_HAUTO_UI_LANDSCAPE;
+00405         return _Landscape->isAdditive ();
+00406 }
+00407 
+00408 //****************************************************************************
+00409 void            CLandscapeUser::setPointLightDiffuseMaterial(CRGBA diffuse)
+00410 {
+00411         NL3D_MEM_LANDSCAPE
+00412         NL3D_HAUTO_UI_LANDSCAPE;
+00413         _Landscape->Landscape.setPointLightDiffuseMaterial(diffuse);
+00414 }
+00415 //****************************************************************************
+00416 CRGBA           CLandscapeUser::getPointLightDiffuseMaterial () const
+00417 {
+00418         NL3D_MEM_LANDSCAPE
+00419         NL3D_HAUTO_UI_LANDSCAPE;
+00420         return _Landscape->Landscape.getPointLightDiffuseMaterial();
+00421 }
+00422 
+00423 //****************************************************************************
+00424 void            CLandscapeUser::setDLMGlobalVegetableColor(CRGBA gvc)
+00425 {
+00426         NL3D_MEM_LANDSCAPE
+00427         NL3D_HAUTO_UI_LANDSCAPE;
+00428         _Landscape->Landscape.setDLMGlobalVegetableColor(gvc);
+00429 }
+00430 //****************************************************************************
+00431 CRGBA           CLandscapeUser::getDLMGlobalVegetableColor() const
+00432 {
+00433         NL3D_MEM_LANDSCAPE
+00434         NL3D_HAUTO_UI_LANDSCAPE;
+00435         return _Landscape->Landscape.getDLMGlobalVegetableColor();
+00436 }
+00437 //****************************************************************************
+00438 void            CLandscapeUser::updateLightingAll()
+00439 {
+00440         NL3D_MEM_LANDSCAPE
+00441         NL3D_HAUTO_LANDSCAPE_UPDATE_LIGHTING_ALL;
+00442         _Landscape->Landscape.updateLightingAll();
+00443 }
+00444 
+00445 
+00446 
+00447 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1