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

instance_lighter.h

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 #ifndef NL_INSTANCE_LIGHTER_H
+00027 #define NL_INSTANCE_LIGHTER_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/vector.h"
+00031 #include "nel/misc/triangle.h"
+00032 #include "nel/misc/plane.h"
+00033 #include "nel/misc/matrix.h"
+00034 #include "3d/scene_group.h"
+00035 #include "3d/landscape.h"
+00036 #include "3d/shape.h"
+00037 #include "3d/mesh.h"
+00038 #include "3d/mesh_mrm.h"
+00039 #include "3d/cube_grid.h"
+00040 #include "3d/ig_surface_light_build.h"
+00041 
+00042 
+00043 namespace NL3D 
+00044 {
+00045 
+00046 
+00047 // ***************************************************************************
+00055 class CInstanceLighter
+00056 {
+00057 public:
+00058 
+00059         enum    {MaxOverSamples= 16};
+00060 
+00061 public:
+00062 
+00063         // Light Options decription structure
+00064         class CLightDesc
+00065         {
+00066         public:
+00067                 // Default Ctor
+00068                 CLightDesc ();
+00069 
+00070                 // Disable Sun contribution: ie set 0 to all contributions of sun on instances and surfaces?? false by default
+00071                 bool                                    DisableSunContribution;
+00072 
+00073                 // Sun direction
+00074                 NLMISC::CVector                 LightDirection;
+00075 
+00076                 // Grid size
+00077                 uint                                    GridSize;
+00078 
+00079                 // Grid size
+00080                 float                                   GridCellSize;
+00081 
+00082                 // Project shadows on instances.
+00083                 bool                                    Shadow;
+00084 
+00085                 // Number of samples For sun shadowing only. Must be: 0 (disable), 2, 4, 8, 16
+00086                 uint                                    OverSampling;
+00087 
+00088                 // This is a user shapeMap.
+00089                 std::map<std::string, IShape*>                          UserShapeMap;
+00090 
+00091         };
+00092 
+00093         // A triangle used to light the zone
+00094         class CTriangle
+00095         {
+00096                 friend class CInstanceLighter;
+00097         public:
+00098                 // Ctors
+00099                 CTriangle (const NLMISC::CTriangle& triangle, sint instanceId)
+00100                 {
+00101                         Triangle=triangle;
+00102                         InstanceId= instanceId;
+00103                 }
+00104 
+00105                 // The triangle
+00106                 NLMISC::CTriangle       Triangle;
+00107 
+00108                 // which instance owns this triangle. -1 if none (landscape or others ig).
+00109                 sint                            InstanceId;
+00110 
+00111                 // Other info
+00112                 const NLMISC::CPlane            &getPlane() const {return Plane;}
+00113 
+00114         private:
+00115                 NLMISC::CPlane          Plane;
+00116         };
+00117 
+00118 
+00119 public:
+00120 
+00124         static  void    lightIgSimple(CInstanceLighter &instLighter, const CInstanceGroup &igIn, CInstanceGroup &igOut, const CLightDesc &lightDesc);
+00125 
+00126 public:
+00127 
+00129         CInstanceLighter();
+00131         virtual ~CInstanceLighter() {}
+00132 
+00133         // Init the system
+00134         void init ();
+00135 
+00146         void light (const CInstanceGroup &igIn, CInstanceGroup &igOut, const CLightDesc &lightDesc, std::vector<CTriangle>& obstacles, 
+00147                 CLandscape *landscape= NULL, CIGSurfaceLightBuild *igSurfaceLightBuild= NULL);
+00148 
+00149 
+00150         // Add triangles from a landscape
+00151         static void addTriangles (CLandscape &landscape, std::vector<uint> &listZone, uint order, std::vector<CTriangle>& triangleArray);
+00152 
+00156         static void addTriangles (const IShape &shape, const NLMISC::CMatrix& modelMT, std::vector<CTriangle>& triangleArray, sint instanceId);
+00157 
+00158         // Progress callback
+00159         virtual void progress (const char *message, float progress) {};
+00160 
+00161 
+00163 
+00164 
+00168         void                    addStaticPointLight(const CPointLightNamed &pln);
+00169 
+00171 
+00172 
+00173 // ********************************
+00174 private:
+00175 
+00176 
+00177         static void addTriangles (const CMeshGeom &meshGeom, const NLMISC::CMatrix& modelMT, std::vector<CTriangle>& triangleArray, sint instanceId);
+00178         static void addTriangles (const CMeshMRMGeom &meshGeom, const NLMISC::CMatrix& modelMT, std::vector<CTriangle>& triangleArray, sint instanceId);
+00179         static void excludeAllPatchFromRefineAll (CLandscape &landscape, std::vector<uint> &listZone, bool exclude);
+00180 
+00181 
+00182         // light / rayTrace against sun.
+00183         void    computeSunContribution(const CLightDesc &lightDesc, std::vector<CTriangle>& obstacles, CLandscape *landscape);
+00184 
+00185         void    dilateLightingOnSurfaceCells();
+00186 
+00187 private:
+00188         struct  CPointLightRT;
+00189 
+00190         struct  CInstanceInfo
+00191         {
+00192                 // Center of the mesh to compute lighting.
+00193                 CVector                 CenterPos;
+00194 
+00195                 // Pos of samples, for overSampling. if none, OverSamples[0]== CenterPos
+00196                 CVector                 OverSamples[MaxOverSamples];
+00197 
+00198                 // Temp light which influence this instance.
+00199                 CPointLightRT   *Light[CInstanceGroup::NumStaticLightPerInstance];
+00200 
+00201                 // Temp Ambient light which influence this instance.
+00202                 CPointLightRT   *LocalAmbientLight;
+00203         };
+00204 
+00205         // Instance of the current ig to be lighted.
+00206         std::vector<CInstanceGroup::CInstance>  _Instances;
+00207         // Instance Lighting Info of the current ig to be lighted.
+00208         std::vector<CInstanceInfo>                              _InstanceInfos;
+00209         // The current instance computed. Used to skip it in raytracing
+00210         sint                                                                    _CurrentInstanceComputed;
+00211         // CIGSurfaceLight Info.
+00212         CIGSurfaceLightBuild                                    *_IGSurfaceLightBuild;
+00213         // The RetrieverGridMap currently builded.
+00214         CIGSurfaceLight::TRetrieverGridMap              _IGRetrieverGridMap;
+00215 
+00216 
+00218         struct  CPointLightRT
+00219         {
+00220                 CPointLightNamed                PointLight;
+00221                 float                                   OODeltaAttenuation;
+00222                 // BBox of the pointLight
+00223                 NLMISC::CBSphere                BSphere;
+00224 
+00225                 // Faces that may occlude the light. Only Back Faces (from the light pov) are inserted
+00226                 CCubeGrid<const CTriangle*>             FaceCubeGrid;
+00227                 // Number of TileLightInfluences which use this PointLight.
+00228                 uint                                    RefCount;
+00229                 // Final id of the pointLight in the Ig.
+00230                 uint                                    DstId;
+00231 
+00232                 CPointLightRT();
+00233 
+00239                 bool            testRaytrace(const CVector &v, sint instanceComputed= -1);
+00240         };
+00241 
+00242 
+00244         struct          CPredPointLightToPoint
+00245         {
+00246                 CVector         Point;
+00247 
+00248                 bool    operator() (CPointLightRT *pla, CPointLightRT *plb) const;
+00249         };
+00250 
+00251 
+00253         std::vector<CPointLightRT>              _StaticPointLights;
+00255         CQuadGrid<CPointLightRT*>               _StaticPointLightQuadGrid;
+00256 
+00257 
+00259         void                    compilePointLightRT(uint gridSize, float gridCellSize, std::vector<CTriangle>& obstacles, bool doShadow);
+00260 
+00264         void                    processIGPointLightRT(std::vector<CPointLightNamed> &listPointLight);
+00265 
+00266 
+00267 private:
+00268 
+00270         // @{
+00271 
+00272         void                    beginCell();
+00273         void                    nextCell();
+00274         bool                    isEndCell();
+00275         // get current cell iterated.
+00276         CSurfaceLightGrid::CCellCorner          &getCurrentCell();
+00277         // get current cellInfo iterated.
+00278         CIGSurfaceLightBuild::CCellCorner       &getCurrentCellInfo();
+00279         // Neighboring of the cell
+00280         bool                    isCurrentNeighborCellInSurface(sint xnb, sint ynb);
+00281         CSurfaceLightGrid::CCellCorner          &getCurrentNeighborCell(sint xnb, sint ynb);
+00282         CIGSurfaceLightBuild::CCellCorner       &getCurrentNeighborCellInfo(sint xnb, sint ynb);
+00283 
+00284         uint                    getCurrentCellNumber() const {return _ItCurrentCellNumber;}
+00285         uint                    getTotalCellNumber() const      {return _TotalCellNumber;}
+00286         void                    progressCell(const char *message);
+00287 
+00288         // Iteration Data.
+00289         CIGSurfaceLight::ItRetrieverGridMap                     _ItRetriever;
+00290         CIGSurfaceLightBuild::ItRetrieverGridMap        _ItRetrieverInfo;
+00291         uint                                                                            _ItSurfId;
+00292         uint                                                                            _ItCellId;
+00293         bool                                                                            _IsEndCell;
+00294         uint                                                                            _ItCurrentCellNumber;
+00295         uint                                                                            _TotalCellNumber;
+00296         float                                                                           _LastCellProgress;
+00297 
+00298         // @}
+00299 
+00300 };
+00301 
+00302 
+00303 } // NL3D
+00304 
+00305 
+00306 #endif // NL_INSTANCE_LIGHTER_H
+00307 
+00308 /* End of instance_lighter.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1