@@ -78,21 +78,31 @@ LightManager::LightManager()
7878 m_lightTimers.push_back (Framework::Timer (Framework::Timer::TT_LOOP, 15 .0f ));
7979}
8080
81+ struct UpdateTimer
82+ {
83+ void operator ()(Framework::Timer &timer) {timer.Update ();}
84+ void operator ()(std::pair<const std::string, Framework::Timer> &timeData)
85+ {timeData.second .Update ();}
86+ };
87+
88+ struct PauseTimer
89+ {
90+ void operator ()(Framework::Timer &timer) {timer.TogglePause ();}
91+ void operator ()(std::pair<const std::string, Framework::Timer> &timeData)
92+ {timeData.second .TogglePause ();}
93+ };
94+
8195void LightManager::UpdateTime ()
8296{
8397 m_keyLightTimer.Update ();
84- for (size_t loop = 0 ; loop < m_lightTimers.size (); loop++)
85- {
86- m_lightTimers[loop].Update ();
87- }
98+ std::for_each (m_lightTimers.begin (), m_lightTimers.end (), UpdateTimer ());
99+ std::for_each (m_extraTimers.begin (), m_extraTimers.end (), UpdateTimer ());
88100}
89101
90102bool LightManager::TogglePause ()
91103{
92- for (size_t loop = 0 ; loop < m_lightTimers.size (); loop++)
93- {
94- m_lightTimers[loop].TogglePause ();
95- }
104+ std::for_each (m_lightTimers.begin (), m_lightTimers.end (), PauseTimer ());
105+ std::for_each (m_extraTimers.begin (), m_extraTimers.end (), PauseTimer ());
96106
97107 return m_keyLightTimer.TogglePause ();
98108}
@@ -105,7 +115,7 @@ LightBlock LightManager::GetLightPositions( const glm::mat4 &worldToCameraMat )
105115 lightData.lightAttenuation = g_fLightAttenuation;
106116
107117 lightData.lights [0 ].cameraSpaceLightPos =
108- worldToCameraMat * glm::vec4 (0 .0f , 1 . 0f , 0 .0f , 0 .0f );
118+ worldToCameraMat * glm::vec4 (0 .0f , 0 . 981f , 0 .196f , 0 .0f );
109119
110120 lightData.lights [0 ].lightIntensity = glm::vec4 (0 .1f , 0 .1f , 0 .1f , 1 .0f );
111121
@@ -116,7 +126,7 @@ LightBlock LightManager::GetLightPositions( const glm::mat4 &worldToCameraMat )
116126 glm::vec4 lightPosCameraSpace = worldToCameraMat * worldLightPos;
117127
118128 lightData.lights [light].cameraSpaceLightPos = lightPosCameraSpace;
119- lightData.lights [light].lightIntensity = glm::vec4 (0 .3f , 0 .3f , 0 .3f , 1 .0f );
129+ lightData.lights [light].lightIntensity = glm::vec4 (0 .2f , 0 .2f , 0 .2f , 1 .0f );
120130 }
121131
122132 return lightData;
@@ -131,3 +141,20 @@ glm::vec3 LightManager::GetWorldLightPosition( int lightIx ) const
131141{
132142 return m_lightPos[lightIx].Interpolate (m_lightTimers[lightIx].GetAlpha ());
133143}
144+
145+ void LightManager::CreateTimer ( const std::string &timerName,
146+ Framework::Timer::Type eType, float fDuration )
147+ {
148+ m_extraTimers[timerName] = Framework::Timer (eType, fDuration );
149+ }
150+
151+ float LightManager::GetTimerValue ( const std::string &timerName ) const
152+ {
153+ ExtraTimerMap::const_iterator loc = m_extraTimers.find (timerName);
154+
155+ if (loc == m_extraTimers.end ())
156+ return -1 .0f ;
157+
158+ return loc->second .GetAlpha ();
159+ }
160+
0 commit comments