-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightFader.cpp
More file actions
42 lines (33 loc) · 963 Bytes
/
LightFader.cpp
File metadata and controls
42 lines (33 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "LightFader.h"
//#include <Logging/Logger.h>
LightFader::LightFader(Light* from, Light* to, Light* lightNode, float time) {
this->from = from;
this->to = to;//todo to.Clone();
this->lightNode = lightNode;
this->time = time;
done = false;
timeSpend = 0.0;
timer.Start();
}
LightFader::~LightFader(){
delete from;
delete to;
}
void LightFader::Handle(ProcessEventArg arg) {
unsigned int dt = timer.GetElapsedTimeAndReset().AsInt();
float deltaTime = ((float)dt)/1000.0;
if(done) return;
if (timeSpend >= time) {
timeSpend = time;
done = true;
}
else
timeSpend += deltaTime;
double pctDone = timeSpend/time;
lightNode->ambient =
from->ambient + (to->ambient - from->ambient) * pctDone;
lightNode->diffuse =
from->diffuse + (to->diffuse - from->diffuse) * pctDone;
lightNode->specular =
from->specular + (to->specular - from->specular) * pctDone;
}