From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../nel/ig__surface__light__build_8cpp-source.html | 218 +++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 docs/doxygen/nel/ig__surface__light__build_8cpp-source.html (limited to 'docs/doxygen/nel/ig__surface__light__build_8cpp-source.html') diff --git a/docs/doxygen/nel/ig__surface__light__build_8cpp-source.html b/docs/doxygen/nel/ig__surface__light__build_8cpp-source.html new file mode 100644 index 00000000..809e94f9 --- /dev/null +++ b/docs/doxygen/nel/ig__surface__light__build_8cpp-source.html @@ -0,0 +1,218 @@ + + + + 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  
+

ig_surface_light_build.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000-2002 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 "3d/ig_surface_light_build.h"
+00029 
+00030 
+00031 using namespace NLMISC;
+00032 using namespace std;
+00033 
+00034 namespace NL3D 
+00035 {
+00036 
+00037 
+00038 // ***************************************************************************
+00039 void                    CIGSurfaceLightBuild::buildSunDebugMesh(CMesh::CMeshBuild &meshBuild, 
+00040         CMeshBase::CMeshBaseBuild &meshBaseBuild, const CVector &deltaPos)
+00041 {
+00042         contReset(meshBuild);
+00043         contReset(meshBaseBuild);
+00044         meshBaseBuild.Materials.resize(1);
+00045         meshBaseBuild.Materials[0].initUnlit();
+00046         meshBaseBuild.Materials[0].setBlend(true);
+00047         meshBaseBuild.Materials[0].setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
+00048 
+00049         meshBuild.VertexFlags= CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag;
+00050 
+00051         // For all grids.
+00052         ItRetrieverGridMap      it;
+00053         for(it= RetrieverGridMap.begin(); it!= RetrieverGridMap.end(); it++)
+00054         {
+00055                 for(uint iSurf= 0; iSurf<it->second.Grids.size(); iSurf++)
+00056                 {
+00057                         CSurface        &surface= it->second.Grids[iSurf];
+00058 
+00059                         // Resize vector and faces.
+00060                         uint    wVert= surface.Width;
+00061                         uint    hVert= surface.Height;
+00062                         uint    wCell= wVert-1;
+00063                         uint    hCell= hVert-1;
+00064                         uint    vId0= meshBuild.Vertices.size();
+00065                         // Allocate vertices / colors
+00066                         meshBuild.Vertices.resize(vId0 + wVert*hVert);
+00067                         vector<CRGBA>   colors;
+00068                         colors.resize(wVert*hVert);
+00069                         // Allocate enough space for faces.
+00070                         meshBuild.Faces.reserve(meshBuild.Faces.size() + wCell*hCell *2);
+00071 
+00072                         // Build vertices pos and colors.
+00073                         uint    x, y;
+00074                         for(y=0;y<hVert; y++)
+00075                         {
+00076                                 for(x=0;x<wVert; x++)
+00077                                 {
+00078                                         uint    vId= y*wVert + x;
+00079                                         // Copy Pos.
+00080                                         meshBuild.Vertices[vId0 + vId]= surface.Cells[vId].CenterPos + deltaPos;
+00081                                         // Copy Color.
+00082                                         uint8   col= surface.Cells[vId].SunContribution;
+00083                                         colors[vId].set(col, col, col, 128);
+00084                                         // Force Blue color, to simulate ambiant.
+00085                                         colors[vId].B= 128 + colors[vId].B/2;
+00086                                         // OutSurface => green is 128.
+00087                                         if(!surface.Cells[vId].InSurface)
+00088                                                 colors[vId].G= 128;
+00089 
+00090                                 }
+00091                         }
+00092 
+00093                         // Build faces
+00094                         for(y=0;y<hCell; y++)
+00095                         {
+00096                                 for(x=0;x<wCell; x++)
+00097                                 {
+00098                                         uint    v00= y*wVert + x;
+00099                                         uint    v10= y*wVert + x+1;
+00100                                         uint    v01= (y+1)*wVert + x;
+00101                                         uint    v11= (y+1)*wVert + x+1;
+00102 
+00103                                         // Skip this cell??
+00104                                         bool    skip= false;
+00105                                         if(!surface.Cells[v00].InSurface && !surface.Cells[v00].Dilated)        skip= true;
+00106                                         if(!surface.Cells[v10].InSurface && !surface.Cells[v10].Dilated)        skip= true;
+00107                                         if(!surface.Cells[v01].InSurface && !surface.Cells[v01].Dilated)        skip= true;
+00108                                         if(!surface.Cells[v11].InSurface && !surface.Cells[v11].Dilated)        skip= true;
+00109 
+00110 
+00111                                         if(!skip)
+00112                                         {
+00113                                                 // 1st triangle.
+00114                                                 CMesh::CFace    face0;
+00115                                                 face0.MaterialId= 0;
+00116                                                 face0.Corner[0].Vertex= vId0+ v00;
+00117                                                 face0.Corner[0].Color= colors[v00];
+00118                                                 face0.Corner[1].Vertex= vId0+ v10;
+00119                                                 face0.Corner[1].Color= colors[v10];
+00120                                                 face0.Corner[2].Vertex= vId0+ v01;
+00121                                                 face0.Corner[2].Color= colors[v01];
+00122 
+00123                                                 // 2nd triangle.
+00124                                                 CMesh::CFace    face1;
+00125                                                 face1.MaterialId= 0;
+00126                                                 face1.Corner[0].Vertex= vId0+ v10;
+00127                                                 face1.Corner[0].Color= colors[v10];
+00128                                                 face1.Corner[1].Vertex= vId0+ v11;
+00129                                                 face1.Corner[1].Color= colors[v11];
+00130                                                 face1.Corner[2].Vertex= vId0+ v01;
+00131                                                 face1.Corner[2].Color= colors[v01];
+00132 
+00133                                                 // Add 2 triangles
+00134                                                 meshBuild.Faces.push_back(face0);
+00135                                                 meshBuild.Faces.push_back(face1);
+00136                                         }
+00137                                 }
+00138                         }
+00139 
+00140 
+00141                 }
+00142         }
+00143 
+00144 
+00145 }
+00146 
+00147 
+00148 
+00149 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1