00001 00005 /* Copyright, 2001 Nevrax Ltd. 00006 * 00007 * This file is part of NEVRAX NEL. 00008 * NEVRAX NEL is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2, or (at your option) 00011 * any later version. 00012 00013 * NEVRAX NEL is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 00018 * You should have received a copy of the GNU General Public License 00019 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00021 * MA 02111-1307, USA. 00022 */ 00023 00024 #include "std3d.h" 00025 00026 #include "nel/3d/light_influence_interpolator.h" 00027 #include "nel/misc/debug.h" 00028 #include "nel/3d/point_light_named.h" 00029 00030 00031 namespace NL3D 00032 { 00033 00034 00035 // *************************************************************************** 00036 void CLightInfluenceInterpolator::interpolate(std::vector<CPointLightInfluence> &pointLightList, float subX, float subY) 00037 { 00038 uint crn; 00039 // UnRolled loops. 00040 nlassert(NumLightPerCorner==2); 00041 00042 // Reset index for each light. 00043 for(crn= 0; crn<4; crn++) 00044 { 00045 CCorner &corner= Corners[crn]; 00046 // UnRolled. 00047 if(corner.Lights[0]) 00048 corner.Lights[0]->_IdInInfluenceList= -1; 00049 if(corner.Lights[1]) 00050 corner.Lights[1]->_IdInInfluenceList= -1; 00051 } 00052 00053 // Compute biLinear influence on each corner 00054 Corners[0].Influence= (1-subX) * (1-subY); 00055 Corners[1].Influence= subX * (1-subY); 00056 Corners[2].Influence= (1-subX) * subY; 00057 Corners[3].Influence= subX * subY; 00058 00059 // For each light of each corner 00060 for(crn= 0; crn<4; crn++) 00061 { 00062 CCorner &corner= Corners[crn]; 00063 // UnRolled. 00064 // light 0. 00065 if(corner.Lights[0]) 00066 { 00067 if(corner.Lights[0]->_IdInInfluenceList==-1) 00068 { 00069 // append a PointLightInfluence 00070 pointLightList.push_back(CPointLightInfluence()); 00071 sint id= pointLightList.size()-1; 00072 // setup the PointLightInfluence 00073 corner.Lights[0]->_IdInInfluenceList= id; 00074 pointLightList[id].PointLight= corner.Lights[0]; 00075 pointLightList[id].Influence= corner.Influence; 00076 } 00077 else 00078 { 00079 // get the PointLightInfluence 00080 sint id= corner.Lights[0]->_IdInInfluenceList; 00081 // increment the influence of the PointLightInfluence 00082 pointLightList[id].Influence+= corner.Influence; 00083 } 00084 } 00085 // light 1. 00086 if(corner.Lights[1]) 00087 { 00088 if(corner.Lights[1]->_IdInInfluenceList==-1) 00089 { 00090 // append a PointLightInfluence 00091 pointLightList.push_back(CPointLightInfluence()); 00092 sint id= pointLightList.size()-1; 00093 // setup the PointLightInfluence 00094 corner.Lights[1]->_IdInInfluenceList= id; 00095 pointLightList[id].PointLight= corner.Lights[1]; 00096 pointLightList[id].Influence= corner.Influence; 00097 } 00098 else 00099 { 00100 // get the PointLightInfluence 00101 sint id= corner.Lights[1]->_IdInInfluenceList; 00102 // increment the influence of the PointLightInfluence 00103 pointLightList[id].Influence+= corner.Influence; 00104 } 00105 } 00106 } 00107 } 00108 00109 00110 00111 } // NL3D
1.6.1