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
72
73
74
75
76
|
#include <base/vmath.hpp>
#include <game/generated/g_protocol.hpp>
#include <game/gamecore.hpp>
#include <game/client/gc_render.hpp>
// sound channels
enum
{
CHN_GUI=0,
CHN_MUSIC,
CHN_WORLD,
CHN_GLOBAL,
};
extern TUNING_PARAMS tuning;
// predicted players
extern CHARACTER_CORE predicted_prev_char;
extern CHARACTER_CORE predicted_char;
// extra projs
enum
{
MAX_EXTRA_PROJECTILES=32,
};
extern NETOBJ_PROJECTILE extraproj_projectiles[MAX_EXTRA_PROJECTILES];
extern int extraproj_num;
void extraproj_reset();
// various helpers
void snd_play_random(int chn, int setid, float vol, vec2 pos);
void chat_enable_mode(int team);
inline vec2 random_dir() { return normalize(vec2(frandom()-0.5f, frandom()-0.5f)); }
inline float hue_to_rgb(float v1, float v2, float h)
{
if(h < 0) h += 1;
if(h > 1) h -= 1;
if((6 * h) < 1) return v1 + ( v2 - v1 ) * 6 * h;
if((2 * h) < 1) return v2;
if((3 * h) < 2) return v1 + ( v2 - v1 ) * ((2.0f/3.0f) - h) * 6;
return v1;
}
inline vec3 hsl_to_rgb(vec3 in)
{
float v1, v2;
vec3 out;
if(in.s == 0)
{
out.r = in.l;
out.g = in.l;
out.b = in.l;
}
else
{
if(in.l < 0.5f)
v2 = in.l * (1 + in.s);
else
v2 = (in.l+in.s) - (in.s*in.l);
v1 = 2 * in.l - v2;
out.r = hue_to_rgb(v1, v2, in.h + (1.0f/3.0f));
out.g = hue_to_rgb(v1, v2, in.h);
out.b = hue_to_rgb(v1, v2, in.h - (1.0f/3.0f));
}
return out;
}
|