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/a06760.html | 378 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 docs/doxygen/nel/a06760.html (limited to 'docs/doxygen/nel/a06760.html') diff --git a/docs/doxygen/nel/a06760.html b/docs/doxygen/nel/a06760.html new file mode 100644 index 00000000..84ca439f --- /dev/null +++ b/docs/doxygen/nel/a06760.html @@ -0,0 +1,378 @@ + + +NeL: zone.h Source File + + + +
+

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 "nel/misc/bit_set.h"
+00034 #include "3d/tessellation.h"
+00035 #include "3d/patch.h"
+00036 #include "3d/bezier_patch.h"
+00037 #include "3d/point_light_named.h"
+00038 #include "3d/point_light_named_array.h"
+00039 #include <stdio.h>
+00040 #include <vector>
+00041 #include <map>
+00042 
+00043 
+00044 namespace NL3D 
+00045 {
+00046 
+00047 
+00048 class CZone;
+00049 class CLandscape;
+00050 class CZoneSymmetrisation;
+00051 class CTileBank;
+00052 
+00053 using NLMISC::CAABBoxExt;
+00054 
+00055 
+00056 // ***************************************************************************
+00057 typedef std::map<uint16, CZone*>                        TZoneMap;
+00058 typedef std::map<uint16, CZone*>::iterator      ItZoneMap;
+00059 
+00060 
+00061 // ***************************************************************************
+00065 struct  CBorderVertex
+00066 {
+00067         // The index of vertex in the current zone to bind.
+00068         uint16                  CurrentVertex;
+00069         // The neighbor zone Id.
+00070         uint16                  NeighborZoneId;
+00071         // The index of vertex in the neighbor zone to bind to CurrentVertex.
+00072         uint16                  NeighborVertex;
+00073 
+00074         void                    serial(NLMISC::IStream &f);
+00075 };
+00076 
+00077 
+00078 // ***************************************************************************
+00086 struct  CPatchInfo
+00087 {
+00088 public:
+00089 
+00095         struct  CBindInfo
+00096         {
+00101                 uint8                   NPatchs;
+00102 
+00104                 uint16                  ZoneId;
+00106                 uint16                  Next[4];
+00108                 uint8                   Edge[4];
+00109 
+00110         public:
+00111                 void                    serial(NLMISC::IStream &f);
+00112                 CBindInfo() {NPatchs=0;}
+00113         };
+00114 
+00115         
+00116 public:
+00118         // @{
+00120         CBezierPatch    Patch;
+00122         uint8                   OrderS, OrderT;
+00124         float                   ErrorSize;
+00126         uint16                  BaseVertices[4];
+00127 
+00130         uint8                   Flags;
+00131 
+00132 
+00134         uint8                   NoiseRotation;
+00135 
+00137         void                    setCornerSmoothFlag(uint corner, bool smooth);
+00138         bool                    getCornerSmoothFlag(uint corner) const;
+00139 
+00140         // @}
+00141 
+00142 
+00144         // @{
+00145 
+00149         std::vector<CTileElement>       Tiles;
+00150 
+00155         std::vector<CTileColor>         TileColors;
+00156 
+00161         std::vector<uint8>                      Lumels;
+00162 
+00171         std::vector<CTileLightInfluence>                TileLightInfluences;
+00172 
+00173         // @}
+00174 
+00176 
+00180         void setSmoothFlag (uint edge, bool flag)
+00181         {
+00182                 // Erase it
+00183                 Flags&=~(1<<edge);
+00184                 
+00185                 // Set it
+00186                 Flags|=(((uint)flag)<<edge);
+00187         }
+00188 
+00192         bool getSmoothFlag (uint edge)
+00193         {
+00194                 // Test it
+00195                 return ((Flags&(1<<edge))!=0);
+00196         }
+00197 
+00213         bool getNeighborTile (uint patchId, uint edge, sint position, uint &patchOut, sint &sOut, sint &tOut, const std::vector<CPatchInfo> &patchInfos) const;
+00214 
+00227         static bool transform (std::vector<CPatchInfo> &patchInfo, NL3D::CZoneSymmetrisation &zoneSymmetry, const NL3D::CTileBank &bank, bool symmetry, uint rotate, float snapCell, float weldThreshold, const NLMISC::CMatrix &toOriginalSpace);
+00228 
+00229         // Transform tile and 256 case with rotation and symmetry parameters
+00230         static bool getTileSymmetryRotate (const NL3D::CTileBank &bank, uint tile, bool &symmetry, uint &rotate);
+00231         static bool transformTile (const NL3D::CTileBank &bank, uint &tile, uint &tileRotation, bool symmetry, uint rotate, bool goofy);
+00232         static void transform256Case (const NL3D::CTileBank &bank, uint8 &case256, uint tileRotation, bool symmetry, uint rotate, bool goofy);
+00233 
+00235         // @{
+00236         CBindInfo               BindEdges[4];
+00237         // @}
+00238 
+00239 
+00240 public:
+00241         CPatchInfo()
+00242         {
+00243                 ErrorSize= 0;
+00244                 // No Rotation / not smooth by default.
+00245                 NoiseRotation= 0;
+00246                 _CornerSmoothFlag= 0;
+00247         }
+00248 
+00249 private:
+00250         // Noise Smooth flags.
+00251         uint8                   _CornerSmoothFlag;
+00252 
+00253 };
+00254 
+00255 
+00256 // ***************************************************************************
+00264 struct  CZoneInfo
+00265 {
+00267         uint16                                          ZoneId;
+00269         std::vector<CPatchInfo>         Patchs;
+00274         std::vector<CBorderVertex>      BorderVertices;
+00275 
+00279         std::vector<CPointLightNamed>   PointLights;
+00280 };
+00281 
+00282 
+00283 // ***************************************************************************
+00297 class CZone
+00298 {
+00299 public:
+00300         // The stored patch structure for compile() - ation.
+00301         struct  CPatchConnect
+00302         {
+00303                 // NB: same meanings than in CPatchInfo.
+00304                 uint8                   OldOrderS, OldOrderT;
+00305                 float                   ErrorSize;
+00306                 uint16                  BaseVertices[4];
+00307                 CPatchInfo::CBindInfo           BindEdges[4];
+00308 
+00309         public:
+00310                 void                    serial(NLMISC::IStream &f);
+00311         };
+00312 
+00313 public:
+00314 
+00316         CZone();
+00318         ~CZone();
+00319 
+00320 
+00332         void                    build(const CZoneInfo &zoneInfo, uint32 numVertices=0);
+00333 
+00334 
+00338         void                    build(uint16 zoneId, const std::vector<CPatchInfo> &patchs, const std::vector<CBorderVertex> &borderVertices, uint32 numVertices=0);
+00339 
+00340 
+00346         void                    build(const CZone &zone);
+00347 
+00348 
+00355         void                    retrieve(CZoneInfo &zoneInfo);
+00356 
+00357 
+00361         void                    retrieve(std::vector<CPatchInfo> &patchs, std::vector<CBorderVertex> &borderVertices);
+00362 
+00363 
+00364 
+00368         void                    debugBinds(FILE *f= stdout);
+00369 
+00370 
+00383         void                    compile(CLandscape *landscape, TZoneMap &loadedZones);
+00384 
+00395         void                    release(TZoneMap &loadedZones);
+00396 
+00397 
+00401         void                    serial(NLMISC::IStream &f);
+00402 
+00403 
+00411         void                    changePatchTextureAndColor (sint numPatch, const std::vector<CTileElement> *tiles, const std::vector<CTileColor> *colors);
+00412 
+00413 
+00425         void                    refreshTesselationGeometry(sint numPatch);
+00426 
+00427 
+00436         const std::vector<CTileElement> &getPatchTexture(sint numPatch) const;
+00437 
+00446         const std::vector<CTileColor> &getPatchColor(sint numPatch) const;
+00447 
+00454         void setTileColor(bool monochrome, float factor);
+00455 
+00461         CLandscape*             getLandscape () const
+00462         {
+00463                 return Landscape;
+00464         }
+00465 
+00466         // NB: for all those function, CTessFace static rendering context must be setup.
+00468         void                    clip(const std::vector<CPlane>  &pyramid);
+00470         void                    preRender();
+00471         // release Far render pass/reset Tile/Far render. Delete also VB, and FaceVectors
+00472         void                    resetRenderFarAndDeleteVBFV();
+00474         void                    forceMergeAtTileLevel();
+00475 
+00477         void                    refineAll();
+00479         void                    excludePatchFromRefineAll(uint patch, bool exclude);
+00482         void                    averageTesselationVertices();
+00483 
+00484         // Accessors.
+00485         const CVector   &getPatchBias() const {return PatchBias;}
+00486         float                   getPatchScale() const {return PatchScale;}
+00487         bool                    compiled() const {return Compiled;}
+00488         uint16                  getZoneId() const {return ZoneId;}
+00489         sint                    getNumPatchs() const {return Patchs.size();}
+00490         // Return the Bounding Box of the zone.
+00491         const CAABBoxExt        &getZoneBB() const {return ZoneBB;}
+00492 
+00499         const CPatch    *getPatch(sint patch) const {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(Patchs[patch]);}
+00500 
+00507         const CPatchConnect     *getPatchConnect(sint patch) const 
+00508                 {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(PatchConnects[patch]);}
+00509 
+00510 
+00515         void                    applyHeightField(const CLandscape &landScape);
+00516 
+00525         void setupColorsFromTileFlags(const NLMISC::CRGBA colors[4]);
+00526         
+00530         void copyTilesFlags(sint destPatchId, const CPatch *srcPatch);
+00531 
+00536         const CBSphere  &getPatchBSphere(uint patch) const;
+00537 
+00539         bool                    isPatchRenderClipped(uint patch) const {return _PatchRenderClipped.get(patch);}
+00540 
+00541 // Private part.
+00542 private:
+00543 /*********************************/
+00544         // A smartptrisable vertex.
+00545         struct  CTessBaseVertex : public NLMISC::CRefCount
+00546         {
+00547                 CTessVertex             Vert;
+00548         };
+00549 
+00550         // Zone vertices.
+00551         typedef NLMISC::CSmartPtr<CTessBaseVertex>      PBaseVertex;
+00552         typedef std::vector<PBaseVertex>                        TBaseVerticesVec;
+00553 
+00554 
+00555 private:
+00556         // The lanscape which own this zone. Usefull for texture management.
+00557         // Filled at compilation only.
+00558         CLandscape              *Landscape;
+00559 
+00560         // Misc.
+00561         uint16                  ZoneId;
+00562         bool                    Compiled;
+00563         CAABBoxExt              ZoneBB;
+00564         CVector                 PatchBias;
+00565         float                   PatchScale;
+00566 
+00567         // The number of vertices she access (maybe on border).
+00568         sint32                          NumVertices;
+00569         // The smartptr on zone vertices.
+00570         TBaseVerticesVec        BaseVertices;
+00571         // The list of border vertices.
+00572         std::vector<CBorderVertex>      BorderVertices;
+00573         // NB: No problem on corners, since zones are compile()-ed with knowledge of neighbors.
+00574 
+00575         // The patchs.
+00576         std::vector<CPatch>                     Patchs;
+00577         std::vector<CPatchConnect>      PatchConnects;
+00578         // Clipped States and BSphere stored here and not in CPatch for faster memory access during clip
+00579         std::vector<CBSphere>           _PatchBSpheres;
+00580         NLMISC::CBitSet                         _PatchRenderClipped;
+00581         NLMISC::CBitSet                         _PatchOldRenderClipped;
+00582 
+00583 
+00586         CPointLightNamedArray                   _PointLightArray;
+00587 
+00588         
+00589 private:
+00590         friend  class CLandscape;
+00591         friend  class CTessFace;
+00592         // Should do this, for texture mgt.
+00593         friend  class CPatch;
+00594 
+00595         sint                    ClipResult;
+00596         enum    TClipResult {ClipIn= 0, ClipOut= 1, ClipSide= 2};
+00597 
+00598 
+00599 private:
+00604         void                    rebindBorder(TZoneMap &loadedZones);
+00605 
+00606         PBaseVertex             getBaseVertex(sint vert) const {return BaseVertices[vert];}
+00607         CPatch                  *getPatch(sint patch) {nlassert(patch>=0 && patch<(sint)Patchs.size()); return &(Patchs[patch]);}
+00608         static CPatch   *getZonePatch(TZoneMap &loadedZones, sint zoneId, sint patch);
+00609         // Bind the patch with ones which are loaded...
+00610         static void             unbindPatch(CPatch &pa);
+00611         static void             bindPatch(TZoneMap &loadedZones, CPatch &pa, CPatchConnect &pc, bool rebind);
+00612         // Is the patch on a border of this zone???
+00613         bool                    patchOnBorder(const CPatchConnect &pc) const;
+00614 
+00615         // compute AABBox, PatchBias and PatchScale, from a bbox.
+00616         void                    computeBBScaleBias(const CAABBox        &bb);
+00617 
+00618 
+00619         // For CPatch: build a bindInfo.
+00620         void                    buildBindInfo(uint patchId, uint edge, CZone *neighborZone, CPatch::CBindInfo   &paBind);
+00621 
+00622         // Patch Array Clip
+00623         void                    clipPatchs(const std::vector<CPlane>    &pyramid);
+00624 };
+00625 
+00626 
+00627 } // NL3D
+00628 
+00629 
+00630 #endif // NL_ZONE_H
+00631 
+00632 /* End of zone.h */
+

Generated on Tue Mar 16 06:41:55 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1