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_h-source.html | 419 +++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 docs/doxygen/nel/landscape_h-source.html (limited to 'docs/doxygen/nel/landscape_h-source.html') diff --git a/docs/doxygen/nel/landscape_h-source.html b/docs/doxygen/nel/landscape_h-source.html new file mode 100644 index 00000000..563da6de --- /dev/null +++ b/docs/doxygen/nel/landscape_h-source.html @@ -0,0 +1,419 @@ + + + + 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.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 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 #ifndef NL_LANDSCAPE_H
+00027 #define NL_LANDSCAPE_H
+00028 
+00029 
+00030 #include "nel/misc/types_nl.h"
+00031 #include "nel/misc/class_id.h"
+00032 #include "nel/misc/smart_ptr.h"
+00033 #include "nel/misc/triangle.h"
+00034 #include "nel/3d/zone.h"
+00035 #include "nel/3d/tile_bank.h"
+00036 #include "nel/3d/patch_rdr_pass.h"
+00037 #include "nel/3d/vertex_buffer.h"
+00038 #include "nel/3d/primitive_block.h"
+00039 #include "nel/3d/material.h"
+00040 #include "nel/3d/tile_far_bank.h"
+00041 #include "nel/3d/texture_near.h"
+00042 #include <map>
+00043 
+00044 #define NL_MAX_SIZE_OF_TEXTURE_EDGE_SHIFT (NL_MAX_TILES_BY_PATCH_EDGE_SHIFT+NL_NUM_PIXELS_ON_FAR_TILE_EDGE_SHIFT)
+00045 #define NL_MAX_SIZE_OF_TEXTURE_EDGE (1<<NL_MAX_SIZE_OF_TEXTURE_EDGE_SHIFT)              // Size max of a far texture edge in pixel
+00046 
+00047 
+00048 namespace NL3D 
+00049 {
+00050 
+00051 
+00052 class   CHeightMap;
+00053 
+00054 
+00055 // ***************************************************************************
+00056 // The maximum amount of different tiles in world.
+00057 const   sint    NbTilesMax= 65536;
+00058 // Size of a CTextureNear. 256 by default (works everywhere).
+00059 // Texures must be square, because of uvscalebias...
+00060 const   sint    TextureNearSize= 256;
+00061 const   sint    NbTilesByLine= TextureNearSize/NL_TILE_LIGHTMAP_SIZE;
+00062 const   sint    NbTilesByTexture= NbTilesByLine*NbTilesByLine;
+00063 
+00064 
+00065 
+00066 // ***************************************************************************
+00073 struct EBadBind : public Exception
+00074 {
+00075 private:
+00076         mutable std::string             _Output;
+00077 
+00078 public:
+00079         struct  CBindError
+00080         {
+00081                 CBindError(sint z, sint p) {ZoneId= z; PatchId= p;}
+00082                 sint    ZoneId;
+00083                 sint    PatchId;
+00084         };
+00085 
+00086 
+00087         // The result list of bind errors.
+00088         std::list<CBindError>   BindErrors;
+00089 
+00090 public:
+00091         EBadBind() : Exception( "Landscape Bind Error in (3DSMax indices!! (+1) ): " ) {}
+00092         virtual const char      *what() const throw();
+00093 
+00094 };
+00095 
+00096 
+00097 
+00098 // ***************************************************************************
+00119 class CLandscape : public NLMISC::CRefCount
+00120 {
+00121 public:
+00122         // The bank of tiles information.
+00123         CTileBank               TileBank;
+00124         CTileFarBank    TileFarBank;
+00125 
+00126 public:
+00127 
+00129         CLandscape();
+00131         ~CLandscape();
+00132 
+00133 
+00135         // @{
+00137         void                    init();
+00138 
+00144         bool                    addZone(const CZone     &newZone);
+00145         
+00151         bool                    removeZone(uint16 zoneId);
+00152         
+00154         void                    clear();
+00155 
+00157         void                    checkBinds() throw(EBadBind);
+00159         void                    checkBinds(uint16 zoneId) throw(EBadBind);
+00160 
+00166         bool                    initTileBanks ();
+00167         // @}
+00168 
+00169         
+00171         // @{
+00173         void                    setTileNear (float tileNear);
+00175         float                   getTileNear () const    {return _TileDistNear;}
+00177         void                    setThreshold (float thre)       {_Threshold= thre;}
+00179         float                   getThreshold () const   {return _Threshold;}
+00180         void                    setRefineMode(bool enabled) {_RefineMode= enabled;}
+00181         bool                    getRefineMode() const {return _RefineMode;}
+00183         void                    setTileMaxSubdivision (uint tileDiv);
+00185         uint                    getTileMaxSubdivision ();
+00186 
+00187         // TODO: other landscape param setup (Transition etc...).
+00188         // Store it by landscape, and not only globally in CTessFace statics.
+00189         // @}
+00190 
+00191 
+00193         // @{
+00197         void                    clip(const CVector &refineCenter, const std::vector<CPlane>     &pyramid);
+00199         void                    refine(const CVector &refineCenter);
+00201         void                    render(IDriver *drv, const CVector &refineCenter, const std::vector<CPlane>     &pyramid, bool doTileAddPass=false);
+00203         void                    refineAll(const CVector &refineCenter);
+00204         // @}
+00205 
+00206 
+00208         // @{
+00216         void                    buildCollideFaces(const CAABBoxExt &bbox, std::vector<CTriangle> &faces, bool faceSplit);
+00220         void                    buildCollideFaces(sint zoneId, sint patch, std::vector<CTriangle> &faces);
+00221         // @}
+00222 
+00223 
+00224 
+00226         // @{
+00232         CZone*                  getZone (sint zoneId);
+00238         const CZone*    getZone (sint zoneId) const;
+00239         // @}
+00240 
+00241 
+00243         // @{
+00245         void                    flushTiles(IDriver *drv, uint16 tileStart, uint16 nbTiles);
+00247         void                    releaseTiles(uint16 tileStart, uint16 nbTiles);
+00248 
+00250         NLMISC::CSmartPtr<ITexture>             getTileTexture(uint16 tileId, CTile::TBitmap bitmapType, CVector &uvScaleBias);
+00251         // @}
+00252 
+00254         // @{
+00262         void setupStaticLight (const CRGBA &diffuse, const CRGBA &ambiant, float multiply);
+00268         const CRGBA* getStaticLight () const
+00269         {
+00270                 return _LightValue;
+00271         }
+00272         // @}
+00273 
+00274 
+00276         // @{
+00278         CVector         getHeightFieldDeltaZ(float x, float y) const;
+00284         void            setHeightField(const CHeightMap &hf);
+00285         // @}
+00286 
+00287 
+00288 
+00289 // ********************************
+00290 private:
+00291         // Private part used by CPatch.
+00292         friend class    CPatch;
+00293         friend class    CZone;
+00294 
+00295         // Return the render pass for a far texture here.
+00296         CPatchRdrPass   *getFarRenderPass(CPatch* pPatch, uint farIndex, float& far1UScale, float& far1VScale, float& far1UBias, float& far1VBias, bool& bRot);
+00297         // Free the render pass for a far texture here.
+00298         void freeFarRenderPass (CPatch* pPatch, CPatchRdrPass* pass, uint farIndex);
+00299         // Return the render pass for a tile Id, and a patch Lightmap.
+00300         CPatchRdrPass   *getTileRenderPass(uint16 tileId, bool additiveRdrPass);
+00301         // Return the UvScaleBias for a tile Id. uv.z has the scale info. uv.x has the BiasU, and uv.y has the BiasV.
+00302         // if bitmap type is CTile::alpha, Return also the additionla rot for alpha (else 0).
+00303         void                    getTileUvScaleBiasRot(uint16 tileId, CTile::TBitmap bitmapType, CVector &uvScaleBias, uint8 &rotAlpha);
+00304 
+00305         // release Far render pass/reset Tile/Far render.
+00306         void                    resetRenderFar();
+00308         void                    forceMergeAtTileLevel();
+00309 
+00310         // Update globals value to CTessFace
+00311         void updateGlobals (const CVector &refineCenter) const;
+00312 
+00313 private:
+00314         TZoneMap                Zones;
+00315 
+00316         // Parameters.
+00317         float                   _TileDistNear;
+00318         float                   _Threshold;
+00319         bool                    _RefineMode;
+00320         float                   _FarTransition;
+00321         uint                    _TileMaxSubdivision;
+00322 
+00323         // The temp VB for tiles and far passes.
+00324         CVertexBuffer   FarVB;
+00325         CVertexBuffer   TileVB;
+00326 
+00327 
+00328         // Tiles Types.
+00329         //=============
+00330         // Texture Map. Use a RefPtr because TileTextureMap must not reference the object, but the ptr.
+00331         typedef NLMISC::CRefPtr<ITexture>                       RPTexture;
+00332         typedef std::map<std::string, RPTexture>        TTileTextureMap;
+00333         typedef TTileTextureMap::iterator                       ItTileTextureMap;
+00334         // RdrPass Set.
+00335         typedef std::set<CPatchRdrPass>                         TTileRdrPassSet;
+00336         typedef TTileRdrPassSet::iterator                       ItTileRdrPassSet;
+00337         typedef NLMISC::CSmartPtr<CPatchRdrPass>        TSPRenderPass;
+00338 
+00339         // The additional realtime structure for a tile.
+00340         struct  CTileInfo
+00341         {
+00342                 // NB: CSmartPtr are not used for simplicity, and because of TTileRdrPassSet...
+00343                 // CPatchRdrPass::RefCount are excplictly incremented/decremented...
+00344                 // The rdrpass for diffuse+Alpha material.
+00345                 CPatchRdrPass   *DiffuseRdrPass;
+00346                 // The rdrpass for additive material (may be NULL if no additive part).
+00347                 CPatchRdrPass   *AdditiveRdrPass;
+00348                 // The scale/Bias to access those tiles in the big texture.
+00349                 // uv.z has the scale info. uv.x has the BiasU, and uv.y has the BiasV.
+00350                 // Manages the demi-texel on tile border too.
+00351                 CVector                 DiffuseUvScaleBias;
+00352                 CVector                 AlphaUvScaleBias;
+00353                 CVector                 AdditiveUvScaleBias;
+00354                 // The additional rotation for this tile, in alpha.
+00355                 uint8                   RotAlpha;
+00356         };
+00357 
+00358 
+00359         // Tiles Data.
+00360         //=============
+00361         // The map of tile texture loaded.
+00362         TTileTextureMap                         TileTextureMap;
+00363         // The set of tile Rdr Pass.
+00364         TTileRdrPassSet                         TileRdrPassSet;
+00365         // The parrallel array of tile of those existing in TileBank. size of NbTilesMax.
+00366         std::vector<CTileInfo*>         TileInfos;
+00367         // The Lightmap rdrpass for tiles.
+00368         // must have a vector of pointer, because of vector reallocation.
+00369         std::vector<TSPRenderPass>              _TextureNears;
+00370         uint                                                    _NFreeLightMaps;
+00371 
+00372 
+00373         // The Tile material.
+00374         CMaterial               TileMaterial;
+00375 
+00376         // The Far material.
+00377         CMaterial               FarMaterial;
+00378 
+00379 
+00380         // *** Far texture      
+00381 
+00382         // ** Some types
+00383 
+00384         // The vector of set of far render pass
+00385         typedef std::set<TSPRenderPass>                         TSPRenderPassSet;
+00386         typedef TSPRenderPassSet::iterator                      ItSPRenderPassSet;
+00387         typedef std::vector<TSPRenderPassSet>           TSPRdrPassSetVector;
+00388         TSPRenderPassSet                                                        _FarRdrPassSet;                                 // Contain all the render pass not empty for pass0 and pass1
+00389         TSPRdrPassSetVector                                                     _FarRdrPassSetVectorFree;               // Contain the render pass not filled yet sorted by size for pass0 and pass1
+00390         bool                                                                            _FarInitialized;
+00391 
+00392         // Used internaly by initTileBanks
+00393         bool                                                                            eraseTileFarIfNotGood (uint tileNumber, uint sizeOrder0, uint sizeOrder1, uint sizeOrder2);
+00394 
+00395         // ** Some private methods
+00396         static uint                                                                     getRdrPassIndexWithSize (uint width, uint height);
+00397         void                                                                            addPatch ();
+00398         void                                                                            removePatch ();
+00399 
+00400 
+00401         // *** Lighting
+00402         CRGBA                   _LightValue[256];
+00403 
+00404 private:
+00405         // Internal only. Force load of the tile (with TileBank).
+00406         void                    loadTile(uint16 tileId);
+00407         void                    releaseTile(uint16 tileId);
+00408         ITexture                *findTileTexture(const std::string &textName);
+00409         CPatchRdrPass   *findTileRdrPass(const CPatchRdrPass &pass);
+00410 
+00411         // Tile LightMap mgt.
+00412         // @{
+00413         // Compute and get a lightmapId/lightmap renderpass.
+00414         // lightmap returned is to be uses with getTileRenderPass(). The id returned must be stored.
+00415         uint            getTileLightMap(CRGBA  map[NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE], CPatchRdrPass *&lightmapRdrPass);
+00416         // tileLightMapId must be the id returned  by getTileLightMap().
+00417         void            getTileLightMapUvInfo(uint tileLightMapId, CVector &uvScaleBias);
+00418         // tileLightMapId must be the id returned  by getTileLightMap().
+00419         void            releaseTileLightMap(uint tileLightMapId);
+00420         // @}
+00421 
+00422 
+00423         // check a zone, adding error to exception.
+00424         void                    checkZoneBinds(CZone &curZone, EBadBind &bindError);
+00425 
+00426 
+00430         struct  CBezierPatchZ
+00431         {
+00433                 float           Vertices[4];            
+00435                 float           Tangents[8];            
+00437                 float           Interiors[4];           
+00438 
+00440                 void            makeInteriors();
+00442                 float           eval(float s, float t) const;                   // s,t coordinates for quad.
+00443         };
+00444 
+00445 
+00446         // HeightFields.
+00447         struct  CHeightField
+00448         {
+00449                 std::vector<CBezierPatchZ>              ZPatchs;
+00450 
+00452                 float                   OriginX, OriginY;
+00454                 float                   SizeX, SizeY;
+00455                 float                   OOSizeX, OOSizeY;
+00457                 uint                    Width, Height;
+00458         };
+00459         CHeightField    _HeightField;
+00460 
+00461 };
+00462 
+00463 
+00464 
+00465 } // NL3D
+00466 
+00467 
+00468 #endif // NL_LANDSCAPE_H
+00469 
+00470 /* End of landscape.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1