#include <point_light_named_array.h>
Nevrax France
Definition at line 45 of file point_light_named_array.h.
Public Member Functions | |
void | build (const std::vector< CPointLightNamed > &pointLights, std::vector< uint > &indexRemap) |
void | clear () |
clear All: pointLights and map. | |
CPointLightNamedArray () | |
Constructor. | |
std::vector< CPointLightNamed > & | getPointLights () |
get the pointLights sorted (mutable version). Be sure what you do! | |
const std::vector< CPointLightNamed > & | getPointLights () const |
get the pointLights sorted (const version). | |
void | initAnimatedLightIndex (const CScene &scene) |
void | serial (NLMISC::IStream &f) |
void | setPointLightFactor (const CScene &scene) |
update the Light factor for all pointLights (animated and unanimated one) | |
Private Types | |
typedef std::vector< CPointLightGroup > | TPLGVec |
Private Attributes | |
TPLGVec | _PointLightGroupMap |
Info for LightGroupName and setPointLightFactor. | |
std::vector< CPointLightNamed > | _PointLights |
List of pointLight. |
|
Definition at line 125 of file point_light_named_array.h. |
|
Constructor.
Definition at line 40 of file point_light_named_array.cpp.
00041 { 00042 } |
|
sort pointLights and make Groups by name for setFactor(). indexRemap gets news Ids for pointLights. eg: old PointLight nb 0 is now at indexRemap[0]. Definition at line 71 of file point_light_named_array.cpp. References _PointLightGroupMap, _PointLights, and uint. Referenced by NL3D::CZone::build(), and NL3D::CInstanceGroup::buildPointLightList().
00072 { 00073 uint i; 00074 00075 // sort by name. 00076 //---------- 00077 // Fill Sort array 00078 vector<CPointLightNamedSort> pointLightSorts; 00079 pointLightSorts.resize(pointLights.size()); 00080 for(i=0; i<pointLightSorts.size(); i++) 00081 { 00082 pointLightSorts[i].PointLight= &pointLights[i]; 00083 pointLightSorts[i].SrcId= i; 00084 } 00085 // sort 00086 sort(pointLightSorts.begin(), pointLightSorts.end()); 00087 // Copy data, and Fill indexRemap array 00088 _PointLights.resize(pointLights.size()); 00089 indexRemap.resize(pointLights.size()); 00090 for(i=0; i<pointLightSorts.size(); i++) 00091 { 00092 // Copy yhe PointLight to its new destination 00093 _PointLights[i]= *pointLightSorts[i].PointLight; 00094 // set the new index at the old position. 00095 indexRemap[pointLightSorts[i].SrcId]= i; 00096 } 00097 00098 // Regroup. 00099 // --------- 00100 _PointLightGroupMap.clear(); 00101 if(_PointLights.size() > 0 ) 00102 { 00103 bool first= true; 00104 string precName; 00105 uint precGroup; 00106 // for all sorted pointLights 00107 uint i; 00108 for(i=0;i<_PointLights.size();i++) 00109 { 00110 const std::string &curName = _PointLights[i].AnimatedLight; 00111 const uint curGroup = _PointLights[i].LightGroup; 00112 if ( first || (precName!=curName) || (precGroup != curGroup) ) 00113 { 00114 // End last group 00115 if(first) 00116 first= false; 00117 else 00118 _PointLightGroupMap.back ().EndId= i; 00119 00120 // Start new group 00121 _PointLightGroupMap.push_back (CPointLightGroup ()); 00122 _PointLightGroupMap.back ().StartId= i; 00123 _PointLightGroupMap.back ().AnimationLight = curName; 00124 _PointLightGroupMap.back ().LightGroup = curGroup; 00125 precName = curName; 00126 precGroup = curGroup; 00127 } 00128 } 00129 // End last group. 00130 _PointLightGroupMap.back ().EndId= i; 00131 } 00132 } |
|
clear All: pointLights and map.
Definition at line 63 of file point_light_named_array.cpp. References _PointLightGroupMap, and _PointLights. Referenced by NL3D::CInstanceGroup::serial().
00064 { 00065 _PointLights.clear(); 00066 _PointLightGroupMap.clear(); 00067 } |
|
get the pointLights sorted (mutable version). Be sure what you do!
Definition at line 66 of file point_light_named_array.h. References _PointLights.
00066 {return _PointLights;} |
|
get the pointLights sorted (const version).
Definition at line 63 of file point_light_named_array.h. References _PointLights. Referenced by NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded(), NL3D::CPatch::appendTileLightInfluences(), NL3D::CZone::build(), NL3D::CInstanceGroup::buildPointLightList(), NL3D::CPatch::getCurrentTileTLIColors(), NL3D::CInstanceGroup::getNumPointLights(), NL3D::CInstanceGroup::getPointLightList(), NL3D::CInstanceGroup::getPointLightNamed(), NL3D::CInstanceGroup::removeFromScene(), and NL3D::CZone::retrieve().
00063 {return _PointLights;} |
|
Definition at line 183 of file point_light_named_array.cpp. References _PointLightGroupMap, NL3D::CPointLightNamedArray::CPointLightGroup::AnimationLight, NL3D::CPointLightNamedArray::CPointLightGroup::AnimationLightIndex, count, NL3D::CScene::getAnimatedLightNameToIndex(), and uint. Referenced by NL3D::CInstanceGroup::addToScene(), NL3D::CInstanceGroup::addToSceneAsync(), and NL3D::CLandscape::addZone().
00184 { 00185 // Search in the map. 00186 const uint count = _PointLightGroupMap.size (); 00187 uint i; 00188 for (i=0; i<count; i++) 00189 { 00190 // Ref 00191 CPointLightGroup &lightGroup = _PointLightGroupMap[i]; 00192 lightGroup.AnimationLightIndex = scene.getAnimatedLightNameToIndex (lightGroup.AnimationLight); 00193 } 00194 } |
|
Definition at line 164 of file point_light_named_array.cpp. References _PointLightGroupMap, _PointLights, NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), and sint.
00165 { 00166 sint ver = f.serialVersion(1); 00167 00168 f.serialCont(_PointLights); 00169 00170 if (ver == 0) 00171 { 00172 std::map<string, CPointLightGroupV0> oldMap; 00173 f.serialCont(oldMap); 00174 } 00175 else 00176 { 00177 f.serialCont(_PointLightGroupMap); 00178 } 00179 } |
|
update the Light factor for all pointLights (animated and unanimated one)
Definition at line 135 of file point_light_named_array.cpp. References _PointLightGroupMap, _PointLights, NL3D::CPointLightNamedArray::CPointLightGroup::AnimationLightIndex, count, NL3D::CPointLightNamedArray::CPointLightGroup::EndId, NL3D::CScene::getAnimatedLightFactor(), NL3D::CScene::getLightmapGroupColor(), NL3D::CPointLightNamedArray::CPointLightGroup::LightGroup, nlassert, NL3D::CPointLightNamedArray::CPointLightGroup::StartId, and uint. Referenced by NL3D::CLandscape::addZone(), and NL3D::CInstanceGroup::setPointLightFactor().
00136 { 00137 // Search in the map. 00138 const uint count = _PointLightGroupMap.size (); 00139 uint i; 00140 for (i=0; i<count; i++) 00141 { 00142 // Ref 00143 CPointLightGroup &lightGroup = _PointLightGroupMap[i]; 00144 00145 // Get the factor 00146 CRGBA factorAnimated= scene.getAnimatedLightFactor (lightGroup.AnimationLightIndex, lightGroup.LightGroup); 00147 CRGBA factorNotAnimated= scene.getLightmapGroupColor (lightGroup.LightGroup);; 00148 00149 // Found the group. what entries in the array? 00150 uint startId= lightGroup.StartId; 00151 const uint endId= lightGroup.EndId; 00152 nlassert(endId<=_PointLights.size()); 00153 00154 // for all entries, setLightFactor 00155 for(uint i=startId;i<endId;i++) 00156 { 00157 _PointLights[i].setLightFactor (factorAnimated, factorNotAnimated); 00158 } 00159 } 00160 } |
|
Info for LightGroupName and setPointLightFactor.
Definition at line 127 of file point_light_named_array.h. Referenced by build(), clear(), initAnimatedLightIndex(), serial(), and setPointLightFactor(). |
|
List of pointLight.
Definition at line 84 of file point_light_named_array.h. Referenced by build(), clear(), getPointLights(), serial(), and setPointLightFactor(). |