1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/3d/light_influence_interpolator.h"
20 #include "nel/misc/debug.h"
21 #include "nel/3d/point_light_named.h"
31 // ***************************************************************************
32 void CLightInfluenceInterpolator::interpolate(std::vector
<CPointLightInfluence
> &pointLightList
, float subX
, float subY
)
36 nlassert(NumLightPerCorner
==2);
38 // Reset index for each light.
39 for(crn
= 0; crn
<4; crn
++)
41 CCorner
&corner
= Corners
[crn
];
44 corner
.Lights
[0]->_IdInInfluenceList
= -1;
46 corner
.Lights
[1]->_IdInInfluenceList
= -1;
49 // Compute biLinear influence on each corner
50 Corners
[0].Influence
= (1-subX
) * (1-subY
);
51 Corners
[1].Influence
= subX
* (1-subY
);
52 Corners
[2].Influence
= (1-subX
) * subY
;
53 Corners
[3].Influence
= subX
* subY
;
55 // For each light of each corner
56 for(crn
= 0; crn
<4; crn
++)
58 CCorner
&corner
= Corners
[crn
];
63 if(corner
.Lights
[0]->_IdInInfluenceList
==-1)
65 // append a PointLightInfluence
66 pointLightList
.push_back(CPointLightInfluence());
67 sint id
= (sint
)pointLightList
.size()-1;
68 // setup the PointLightInfluence
69 corner
.Lights
[0]->_IdInInfluenceList
= id
;
70 pointLightList
[id
].PointLight
= corner
.Lights
[0];
71 pointLightList
[id
].Influence
= corner
.Influence
;
75 // get the PointLightInfluence
76 sint id
= corner
.Lights
[0]->_IdInInfluenceList
;
77 // increment the influence of the PointLightInfluence
78 pointLightList
[id
].Influence
+= corner
.Influence
;
84 if(corner
.Lights
[1]->_IdInInfluenceList
==-1)
86 // append a PointLightInfluence
87 pointLightList
.push_back(CPointLightInfluence());
88 sint id
= (sint
)pointLightList
.size()-1;
89 // setup the PointLightInfluence
90 corner
.Lights
[1]->_IdInInfluenceList
= id
;
91 pointLightList
[id
].PointLight
= corner
.Lights
[1];
92 pointLightList
[id
].Influence
= corner
.Influence
;
96 // get the PointLightInfluence
97 sint id
= corner
.Lights
[1]->_IdInInfluenceList
;
98 // increment the influence of the PointLightInfluence
99 pointLightList
[id
].Influence
+= corner
.Influence
;