forked from gildor2/UEViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeshInstance.cpp
More file actions
46 lines (39 loc) · 1.26 KB
/
Copy pathMeshInstance.cpp
File metadata and controls
46 lines (39 loc) · 1.26 KB
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
#include "Core.h"
#include "UnrealClasses.h"
#if RENDERING
#include "MeshInstance.h"
#include "GlWindow.h" // for RGB macro
//!! This code is based on GetBoneInfColor(). Should place both in some place (utility functions)
//!! and rename to "DebugColorByIndex()" etc. 2 versions: RGBA and float3.
unsigned CMeshInstance::GetMaterialDebugColor(int Index)
{
// most of this code is targetted to make maximal color combinations
// which are maximally different for adjancent BoneIndex values
static const byte table[] = { byte(255*0.9f), byte(255*0.3f), byte(255*0.6f), byte(255*0.0f) };
static const int table2[] = { 0, 1, 2, 4, 7, 3, 5, 6 };
Index = (Index & 0xFFF8) | table2[Index & 7] ^ 7;
#define C(x) ( (x) & 1 ) | ( ((x) >> 2) & 2 )
return RGB255(table[C(Index)], table[C(Index >> 1)], table[C(Index >> 2)]);
#undef C
}
void CMeshInstance::SetMaterial(UUnrealMaterial *Mat, int Index)
{
guard(CMeshInstance::SetMaterial);
if (!bColorMaterials)
{
glColor3f(1, 1, 1);
if (Mat)
Mat->SetMaterial();
else
BindDefaultMaterial();
}
else
{
BindDefaultMaterial(true);
glDisable(GL_CULL_FACE);
unsigned color = GetMaterialDebugColor(Index);
glColor4ubv((GLubyte*)&color);
}
unguard;
}
#endif // RENDERING