-
Notifications
You must be signed in to change notification settings - Fork 11
/
Ligthing.cpp
72 lines (65 loc) · 1.74 KB
/
Ligthing.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Lighting.h"
#include <vector>
#include <algorithm>
std::vector<SpotLightColor> spotLightColors = {
{ "White",256,256,256 },
{ "Silver",192,192,192 },
{ "Gray" ,128,128,128 },
{ "Maroon",128,0,0 },
{ "Red",256,0,0 },
{ "Purple",128,0,128 },
{ "Fuchsia",256,0,256 },
{ "Green", 0,128,0 },
{ "Lime",0,256,0 },
{ "Olive",128,128,0 },
{ "Yellow",256,256,0 },
{ "Navy",0,0,128 },
{ "Blue",0,0,256 },
{ "Teal",0,128,128 },
{ "Aqua",0,256,256 },
};
std::vector<SpotLightColor> getSpotLightColors() {
return spotLightColors;
}
SpotLightColor getDefaultSpotLightColor() {
return SpotLightColor{ "White",256,256,256 };
}
SpotLightColor getNextSpotLightColor(SpotLightColor spotLightColor) {
//int foundIndex = find(spotLightColors.begin(), spotLightColors.end(), spotLightColor) - spotLightColors.begin();
//see http://stackoverflow.com/questions/14225932/search-for-a-struct-item-in-a-vector-by-member-data
int foundIndex = std::find_if(spotLightColors.begin(), spotLightColors.end(), [=](SpotLightColor const& color) {
return (color.r == spotLightColor.r && color.g == spotLightColor.g && color.b == spotLightColor.b);
}) - spotLightColors.begin();
if (foundIndex +1 >= spotLightColors.size()) {//color not found or in last element
return spotLightColors[0];
}
else {
return spotLightColors[foundIndex +1];
}
}
std::string getNameForSpotLightType(SPOT_LIGHT_TYPE type) {
switch (type)
{
case SPOT_LIGHT_NONE:
return "None";
break;
case SPOT_LIGHT_ACTOR_ABOVE:
return "Above";
break;
case SPOT_LIGHT_WEST:
return "West";
break;
case SPOT_LIGHT_EAST:
return "East";
break;
case SPOT_LIGHT_NORTH:
return "North";
break;
case SPOT_LIGHT_SOUTH:
return "South";
break;
default:
return "Error";
break;
}
}