blob: 98fcb6c512750f15f0e01c02de2d9eec73bd7444 (
plain)
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
|
#include "nw4r/g3d.h" // IWYU pragma: export
#include <algorithm>
namespace nw4r {
namespace g3d {
void AnmScn::GetLightSetting(LightSetting *pSetting) {
const u32 numLightSet = GetLightSetMaxRefNumber();
const u32 numAmbLight = GetAmbLightMaxRefNumber();
const u32 numDiffLight = GetDiffuseLightMaxRefNumber();
if (numLightSet > 0) {
const u32 numLightSetObj = pSetting->GetNumLightSet();
const u32 numLoadableSet = std::min(numLightSet, numLightSetObj);
for (u32 i = 0; i < numLoadableSet; i++) {
LightSet set = pSetting->GetLightSet(i);
GetLightSet(set, i);
}
}
if (numAmbLight > 0) {
AmbLightObj *pAmbObjArray = pSetting->GetAmbLightObjArray();
const u32 numAmbObj = pSetting->GetNumLightObj();
const u32 numLoadableAmb = std::min(numAmbLight, numAmbObj);
for (u32 i = 0; i < numLoadableAmb; i++) {
AmbLightObj *pAmbObj = &pAmbObjArray[i];
*reinterpret_cast<u32 *>(&pAmbObj->r) = GetAmbLightColor(i);
}
}
if (numDiffLight > 0) {
LightObj *pLightObjArray = pSetting->GetLightObjArray();
const u32 numLightObj = pSetting->GetNumLightObj();
const u32 numSpecLight = GetNumSpecularLight();
const u32 numLight = numDiffLight + numSpecLight;
const u32 numLoadableDiffLight = std::min(numDiffLight, numLightObj);
const u32 numLoadableLight = std::min(numLight, numLightObj);
for (u32 i = 0; i < numLoadableDiffLight; i++) {
LightObj *pObj = &pLightObjArray[i];
pObj->Disable();
}
for (u32 i = 0; i < numLoadableDiffLight; i++) {
LightObj *pDiffObj = &pLightObjArray[i];
LightObj *pSpecObj = NULL;
if (pDiffObj->IsEnable()) {
continue;
}
if (HasSpecularLight(i)) {
const u32 specId = GetSpecularLightID(i);
if (specId < numLoadableLight) {
pSpecObj = &pLightObjArray[specId];
}
}
GetLight(pDiffObj, pSpecObj, i);
}
}
}
} // namespace g3d
} // namespace nw4r
|