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

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 #include "std3d.h"
+00027 
+00028 #include <vector>
+00029 #include "nel/misc/hierarchical_timer.h"
+00030 #include "3d/landscape_model.h"
+00031 #include "3d/landscape.h"
+00032 #include "3d/cluster.h"
+00033 #include "3d/scene.h"
+00034 #include "3d/light_trav.h"
+00035 using namespace std;
+00036 using namespace NLMISC;
+00037 
+00038 #define NL3D_MEM_LANDSCAPE                                      NL_ALLOC_CONTEXT( 3dLand )
+00039 
+00040 namespace NL3D 
+00041 {
+00042 
+00043 
+00044 
+00045 // ***************************************************************************
+00046 void    CLandscapeModel::registerBasic()
+00047 {
+00048         CMOT::registerModel(LandscapeModelId, TransformId, CLandscapeModel::creator);
+00049         CMOT::registerObs(ClipTravId, LandscapeModelId, CLandscapeClipObs::creator);
+00050         CMOT::registerObs(RenderTravId, LandscapeModelId, CLandscapeRenderObs::creator);
+00051 }
+00052 
+00053 
+00054 // ***************************************************************************
+00055 CLandscapeModel::CLandscapeModel()
+00056 {
+00057         Landscape.init();
+00058         _ActiveAdditive=false;
+00059         _Additive=1.f;
+00060 
+00061         // The model is renderable
+00062         CTransform::setIsRenderable(true);
+00063 }
+00064 
+00065 
+00066 // ***************************************************************************
+00067 void    CLandscapeModel::initModel()
+00068 {
+00069         CTransform::initModel();
+00070 
+00071         // After creating the landscape (and so the VegetableManager in the ctor).
+00072         // we must init correclty the VegetableManager.
+00073         Landscape.createVegetableBlendLayersModels(safe_cast<CScene*>(_OwnerMot));
+00074 }
+00075 
+00076 
+00077 // ***************************************************************************
+00078 void    CLandscapeClipObs::init()
+00079 {
+00080         CTransformClipObs::init();
+00081 
+00082         // Enable the landscape to be clipped by the Cluster System.
+00083         CClipTrav               *clipTrav= (CClipTrav*)Trav;
+00084         clipTrav->unlink(NULL, Model);
+00085         clipTrav->link(clipTrav->RootCluster, Model);
+00086 }
+00087 
+00088 // ***************************************************************************
+00089 bool    CLandscapeClipObs::clip(IBaseClipObs *caller)
+00090 {
+00091         H_AUTO( NL3D_Landscape_Clip );
+00092 
+00093         CLandscapeModel         *landModel= (CLandscapeModel*)Model;
+00094         CClipTrav               *clipTrav= (CClipTrav*)Trav;
+00095 
+00096         // Before Landscape clip, must setup Driver, for good VB allocation.
+00097         landModel->Landscape.setDriver(clipTrav->RenderTrav->getDriver());
+00098 
+00099         // Use the unClipped pyramid (not changed by cluster System).
+00100         vector<CPlane>  &pyramid= clipTrav->WorldFrustumPyramid;
+00101 
+00102         // We are sure that pyramid has normalized plane normals.
+00103         landModel->Landscape.clip(clipTrav->CamPos, pyramid);
+00104 
+00105         // Yes, this is ugly, but the clip pass is finished in render(), for clipping TessBlocks.
+00106         // This saves an other Landscape patch traversal, so this is faster...
+00107         // Order them in order which clip faster (first horizontal, then vertical).
+00108         landModel->CurrentPyramid[0]= pyramid[NL3D_CLIP_PLANE_LEFT];
+00109         landModel->CurrentPyramid[1]= pyramid[NL3D_CLIP_PLANE_RIGHT];
+00110         landModel->CurrentPyramid[2]= pyramid[NL3D_CLIP_PLANE_TOP];
+00111         landModel->CurrentPyramid[3]= pyramid[NL3D_CLIP_PLANE_BOTTOM];
+00112         nlassert(NL3D_TESSBLOCK_NUM_CLIP_PLANE==4);
+00113 
+00114         // Well, always visible....
+00115         return true;
+00116 }
+00117 
+00118 // ***************************************************************************
+00119 void    CLandscapeRenderObs::traverse(IObs *caller)
+00120 {
+00121         NL3D_MEM_LANDSCAPE
+00122 
+00123         CLandscapeModel         *landModel= (CLandscapeModel*)Model;
+00124 
+00125         CRenderTrav             *trav= (CRenderTrav*)Trav;
+00126 
+00127         // Change the landscape cetner. All Geomorphed pos (in VertexBuffer only or during VertexProgram)
+00128         // substract this position.
+00129         landModel->Landscape.setPZBModelPosition(trav->CamPos);
+00130 
+00131         // setup the model matrix
+00132         CMatrix         m;
+00133         m.identity();
+00134         // ZBuffer Precion: set the modelMatrix to the current landscape PZBModelPosition.
+00135         // NB: don't use trav->CamPos directly because setPZBModelPosition() may modify the position
+00136         m.setPos(landModel->Landscape.getPZBModelPosition());
+00137         trav->getDriver()->setupModelMatrix(m);
+00138 
+00139 
+00140         // Scene Time/Lighting Mgt.
+00141         CScene          *scene= dynamic_cast<CScene*>(landModel->_OwnerMot);
+00142         if(scene)
+00143         {
+00144                 // For vegetable, set the animation Time.
+00145                 landModel->Landscape.setVegetableTime(scene->getCurrentTime());
+00146 
+00147                 // For vegetable updateLighting, set the system Time.
+00148                 landModel->Landscape.setVegetableUpdateLightingTime(scene->getCurrentSystemTime());
+00149 
+00150                 // updateLighting
+00151                 H_BEFORE( NL3D_Landscape_UpdateLighting );
+00152                 landModel->Landscape.updateLighting(scene->getCurrentSystemTime());
+00153                 H_AFTER( NL3D_Landscape_UpdateLighting );
+00154 
+00155                 // if SceneLighting enabled
+00156                 if(scene->isLightingSystemEnabled())
+00157                 {
+00158                         H_AUTO( NL3D_Landscape_DynamicLighting );
+00159 
+00160                         // For vegetable, set the lighting 
+00161                         landModel->Landscape.setupVegetableLighting(scene->getSunAmbient(), scene->getSunDiffuse(), 
+00162                                 scene->getSunDirection());
+00163 
+00164                         // Landscape dynamic lighting: get all pointLights from scene and light landscape with them.
+00165                         IBaseLightObs   *lightObs= static_cast<IBaseLightObs*>(landModel->_LightObs);
+00166                         // current visible Dynamic light list are registered in LightTrav::LightingManager
+00167                         CLightTrav              *lightTrav= (CLightTrav*)lightObs->Trav;
+00168                         // Get all dynamic light list, and light landscape with it.
+00169                         landModel->Landscape.computeDynamicLighting(lightTrav->LightingManager.getAllDynamicLightList());
+00170                 }
+00171         }
+00172 
+00173         // First, refine.
+00174         H_BEFORE( NL3D_Landscape_Refine );
+00175         landModel->Landscape.refine(trav->CamPos);
+00176         H_AFTER( NL3D_Landscape_Refine );
+00177 
+00178         // then render.
+00179         H_BEFORE( NL3D_Landscape_Render );
+00180         landModel->Landscape.render(trav->CamPos, trav->CamLook, landModel->CurrentPyramid, landModel->isAdditive ());
+00181         H_AFTER( NL3D_Landscape_Render );
+00182 }
+00183 
+00184 
+00185 
+00186 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1