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

zone.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_ZONE_H
+00027 #define NL_ZONE_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/smart_ptr.h"
+00031 #include "nel/misc/stream.h"
+00032 #include "nel/misc/debug.h"
+00033 #include "3d/tessellation.h"
+00034 #include "3d/patch.h"
+00035 #include "3d/bezier_patch.h"
+00036 #include "3d/point_light_named.h"
+00037 #include "3d/point_light_named_array.h"
+00038 #include <stdio.h>
+00039 #include <vector>
+00040 #include <map>
+00041 
+00042 
+00043 namespace NL3D 
+00044 {
+00045 
+00046 
+00047 class CZone;
+00048 class CLandscape;
+00049 
+00050 using NLMISC::CAABBoxExt;
+00051 
+00052 
+00053 // ***************************************************************************
+00054 typedef std::map<uint16, CZone*>                        TZoneMap;
+00055 typedef std::map<uint16, CZone*>::iterator      ItZoneMap;
+00056 
+00057 
+00058 // ***************************************************************************
+00062 struct  CBorderVertex
+00063 {
+00064         // The index of vertex in the current zone to bind.
+00065         uint16                  CurrentVertex;
+00066         // The neighbor zone Id.
+00067         uint16                  NeighborZoneId;
+00068         // The index of vertex in the neighbor zone to bind to CurrentVertex.
+00069         uint16                  NeighborVertex;
+00070 
+00071         void                    serial(NLMISC::IStream &f);
+00072 };
+00073 
+00074 
+00075 // ***************************************************************************
+00083 struct  CPatchInfo
+00084 {
+00085 public:
+00086 
+00092         struct  CBindInfo
+00093         {
+00098                 uint8                   NPatchs;
+00099 
+00101                 uint16                  ZoneId;
+00103                 uint16                  Next[4];
+00105                 uint8                   Edge[4];
+00106 
+00107         public:
+00108                 void                    serial(NLMISC::IStream &f);
+00109                 CBindInfo() {NPatchs=0;}
+00110         };
+00111 
+00112         
+00113 public:
+00115         // @{
+00117         CBezierPatch    Patch;
+00119         uint8                   OrderS, OrderT;
+00121         float                   ErrorSize;
+00123         uint16                  BaseVertices[4];
+00124 
+00127         uint8                   Flags;
+00128 
+00129 
+00131         uint8                   NoiseRotation;
+00132 
+00134         void                    setCornerSmoothFlag(uint corner, bool smooth);
+00135         bool                    getCornerSmoothFlag(uint corner) const;
+00136 
+00137         // @}
+00138 
+00139 
+00141         // @{
+00142 
+00146         std::vector<CTileElement>       Tiles;
+00147 
+00152         std::vector<CTileColor>         TileColors;
+00153 
+00158         std::vector<uint8>                      Lumels;
+00159 
+00168         std::vector<CTileLightInfluence>                TileLightInfluences;
+00169 
+00170         // @}
+00171 
+00173 
+00177         void setSmoothFlag (uint edge, bool flag)
+00178         {
+00179                 // Erase it
+00180                 Flags&=~(1<<edge);
+00181                 
+00182                 // Set it
+00183                 Flags|=(((uint)flag)<<edge);
+00184         }
+00185 
+00189         bool getSmoothFlag (uint edge)
+00190         {
+00191                 // Test it
+00192                 return ((Flags&(1<<edge))!=0);
+00193         }
+00194 
+00196         // @{
+00197         CBindInfo               BindEdges[4];
+00198         // @}
+00199 
+00200 
+00201 public:
+00202         CPatchInfo()
+00203         {
+00204                 ErrorSize= 0;
+00205                 // No Rotation / not smooth by default.
+00206                 NoiseRotation= 0;
+00207                 _CornerSmoothFlag= 0;
+00208         }
+00209 
+00210 private:
+00211         // Noise Smooth flags.
+00212         uint8                   _CornerSmoothFlag;
+00213 
+00214 };
+00215 
+00216 
+00217 // ***************************************************************************
+00225 struct  CZoneInfo
+00226 {
+00228         uint16                                          ZoneId;
+00230         std::vector<CPatchInfo>         Patchs;
+00235         std::vector<CBorderVertex>      BorderVertices;
+00236 
+00240         std::vector<CPointLightNamed>   PointLights;
+00241 };
+00242 
+00243 
+00244 // ***************************************************************************
+00258 class CZone
+00259 {
+00260 public:
+00261         // The stored patch structure for compile() - ation.
+00262         struct  CPatchConnect
+00263         {
+00264                 // NB: same meanings than in CPatchInfo.
+00265                 uint8                   OldOrderS, OldOrderT;
+00266                 float                   ErrorSize;
+00267                 uint16                  BaseVertices[4];
+00268                 CPatchInfo::CBindInfo           BindEdges[4];
+00269 
+00270         public:
+00271                 void                    serial(NLMISC::IStream &f);
+00272         };
+00273 
+00274 public:
+00275 
+00277         CZone();
+00279         ~CZone();
+00280 
+00281 
+00293         void                    build(const CZoneInfo &zoneInfo, uint32 numVertices=0);
+00294 
+00295 
+00299         void                    build(uint16 zoneId, const std::vector<CPatchInfo> &patchs, const std::vector<CBorderVertex> &borderVertices, uint32 numVertices=0);
+00300 
+00301 
+00307         void                    build(const CZone &zone);
+00308 
+00309 
+00316         void                    retrieve(CZoneInfo &zoneInfo);
+00317 
+00318 
+00322         void                    retrieve(std::vector<CPatchInfo> &patchs, std::vector<CBorderVertex> &borderVertices);
+00323 
+00324 
+00325 
+00329         void                    debugBinds(FILE *f= stdout);
+00330 
+00331 
+00344         void                    compile(CLandscape *landscape, TZoneMap &loadedZones);
+00345 
+00356         void                    release(TZoneMap &loadedZones);
+00357 
+00358 
+00362         void                    serial(NLMISC::IStream &f);
+00363 
+00364 
+00372         void                    changePatchTextureAndColor (sint numPatch, const std::vector<CTileElement> *tiles, const std::vector<CTileColor> *colors);
+00373 
+00374 
+00386         void                    refreshTesselationGeometry(sint numPatch);
+00387 
+00388 
+00397         const std::vector<CTileElement> &getPatchTexture(sint numPatch) const;
+00398 
+00407         const std::vector<CTileColor> &getPatchColor(sint numPatch) const;
+00408 
+00414         CLandscape*             getLandscape () const
+00415         {
+00416                 return Landscape;
+00417         }
+00418 
+00419         // NB: for all those function, CTessFace static rendering context must be setup.
+00421         void                    clip(const std::vector<CPlane>  &pyramid);
+00423         void                    preRender();
+00424         // release Far render pass/reset Tile/Far render. Delete also VB, and FaceVectors
+00425         void                    resetRenderFarAndDeleteVBFV();
+00427         void                    forceMergeAtTileLevel();
+00428 
+00430         void                    refineAll();
+00432         void                    excludePatchFromRefineAll(uint patch, bool exclude);
+00435         void                    averageTesselationVertices();
+00436 
+00437         // Accessors.
+00438         const CVector   &getPatchBias() const {return PatchBias;}
+00439         float                   getPatchScale() const {return PatchScale;}
+00440         bool                    compiled() const {return Compiled;}
+00441         uint16                  getZoneId() const {return ZoneId;}
+00442         sint                    getNumPatchs() const {return Patchs.size();}
+00443         // Return the Bounding Box of the zone.
+00444         const CAABBoxExt        &getZoneBB() const {return ZoneBB;}
+00445 
+00452         const CPatch    *getPatch(sint patch) const {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(Patchs[patch]);}
+00453 
+00460         const CPatchConnect     *getPatchConnect(sint patch) const 
+00461                 {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(PatchConnects[patch]);}
+00462 
+00463 
+00468         void                    applyHeightField(const CLandscape &landScape);
+00469 
+00478         void setupColorsFromTileFlags(const NLMISC::CRGBA colors[4]);
+00479         
+00483         void copyTilesFlags(sint destPatchId, const CPatch *srcPatch);
+00484 
+00485 // Private part.
+00486 private:
+00487 /*********************************/
+00488         // A smartptrisable vertex.
+00489         struct  CTessBaseVertex : public NLMISC::CRefCount
+00490         {
+00491                 CTessVertex             Vert;
+00492         };
+00493 
+00494         // Zone vertices.
+00495         typedef NLMISC::CSmartPtr<CTessBaseVertex>      PBaseVertex;
+00496         typedef std::vector<PBaseVertex>                        TBaseVerticesVec;
+00497 
+00498 
+00499 private:
+00500         // The lanscape which own this zone. Usefull for texture management.
+00501         // Filled at compilation only.
+00502         CLandscape              *Landscape;
+00503 
+00504         // Misc.
+00505         uint16                  ZoneId;
+00506         bool                    Compiled;
+00507         CAABBoxExt              ZoneBB;
+00508         CVector                 PatchBias;
+00509         float                   PatchScale;
+00510 
+00511         // The number of vertices she access (maybe on border).
+00512         sint32                          NumVertices;
+00513         // The smartptr on zone vertices.
+00514         TBaseVerticesVec        BaseVertices;
+00515         // The list of border vertices.
+00516         std::vector<CBorderVertex>      BorderVertices;
+00517         // NB: No problem on corners, since zones are compile()-ed with knowledge of neighbors.
+00518 
+00519         // The patchs.
+00520         std::vector<CPatch>                     Patchs;
+00521         std::vector<CPatchConnect>      PatchConnects;
+00522 
+00525         CPointLightNamedArray                   _PointLightArray;
+00526 
+00527         
+00528 private:
+00529         friend  class CLandscape;
+00530         friend  class CTessFace;
+00531         // Should do this, for texture mgt.
+00532         friend  class CPatch;
+00533 
+00534         sint                    ClipResult;
+00535         enum    TClipResult {ClipIn= 0, ClipOut= 1, ClipSide= 2};
+00536 
+00537 
+00538 private:
+00543         void                    rebindBorder(TZoneMap &loadedZones);
+00544 
+00545         PBaseVertex             getBaseVertex(sint vert) const {return BaseVertices[vert];}
+00546         CPatch                  *getPatch(sint patch) {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(Patchs[patch]);}
+00547         static CPatch   *getZonePatch(TZoneMap &loadedZones, sint zoneId, sint patch);
+00548         // Bind the patch with ones which are loaded...
+00549         static void             unbindPatch(CPatch &pa);
+00550         static void             bindPatch(TZoneMap &loadedZones, CPatch &pa, CPatchConnect &pc, bool rebind);
+00551         // Is the patch on a border of this zone???
+00552         bool                    patchOnBorder(const CPatchConnect &pc) const;
+00553 
+00554         // compute AABBox, PatchBias and PatchScale, from a bbox.
+00555         void                    computeBBScaleBias(const CAABBox        &bb);
+00556 
+00557 
+00558         // For CPatch: build a bindInfo.
+00559         void                    buildBindInfo(uint patchId, uint edge, CZone *neighborZone, CPatch::CBindInfo   &paBind);
+00560 
+00561 };
+00562 
+00563 
+00564 } // NL3D
+00565 
+00566 
+00567 #endif // NL_ZONE_H
+00568 
+00569 /* End of zone.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1