13static constexpr float D { 256.0F };
20static std::array<grid3d *,nbgrid>
grille;
31 v3d center = {0,-17.0,0};
43static inline unsigned char
47 float t = (float) val * log10f(power) / 2.0F;
51 return std::min(val, 255);
59 auto *color = (
unsigned char *) col;
60 *color =
lighten (*color, power);
62 *color =
lighten (*color, power);
64 *color =
lighten (*color, power);
66 *color =
lighten (*color, power);
70static inline int ShiftRight(
int x,
int s) {
return (x<0) ? -((-x)>>s) : (x>>s); }
73int evolutecolor (
unsigned int src,
unsigned int dest,
unsigned int mask,
unsigned int incr) {
74 int color = src & (~mask);
84 return (src&mask)|color;
87static void pretty_move (
float lcycle,
float *dist,
float *dist2,
float *rotangle) {
88 static float s_distT = 10.0F;
89 static float s_distT2 = 0.0F;
90 static float s_rot = 0.0F;
91 static int s_happens = 0;
92 static int s_lock = 0;
96 else if (s_lock == 0) {
98 s_lock = s_happens * 3 / 2;
105 float tmp = s_happens?8.0F:0;
106 *dist2 = s_distT2 = (
tmp + 15.0F*s_distT2)/16.0F;
108 tmp = 30+
D-(90.0F*(1.0F+sinf(lcycle*19/20)));
112 *dist = s_distT = (
tmp + 3.0F*s_distT)/4.0F;
118 static bool s_rotation {
false};
127 if (fabsf(
tmp-s_rot) > fabsf(
tmp-(s_rot+2.0F*
M_PI_F))) {
128 s_rot = (
tmp + 15.0F*(s_rot+2*
M_PI_F)) / 16.0F;
133 else if (fabsf(
tmp-s_rot) > fabsf(
tmp-(s_rot-2.0F*
M_PI_F))) {
134 s_rot = (
tmp + 15.0F*(s_rot-2.0F*
M_PI_F)) / 16.0F;
140 *rotangle = s_rot = (
tmp + 15.0F*s_rot) / 16.0F;
145 static std::array<int,3> s_colors {
150 static float s_lig = 1.15F;
151 static float s_ligs = 0.1F;
155 float rotangle = NAN;
157 if ((!drawit) && (s_ligs>0.0F))
163 if ((s_lig>10.0F) || (s_lig<1.1F))
166 static int s_col = (0x28<<(
ROUGE*8))|(0x2c<<(
VERT*8))|(0x5f<<(
BLEU*8));
167 static int s_dstCol = 0;
172 s_col =
evolutecolor(s_col,s_colors[s_dstCol],0xff,0x01);
173 s_col =
evolutecolor(s_col,s_colors[s_dstCol],0xff00,0x0100);
174 s_col =
evolutecolor(s_col,s_colors[s_dstCol],0xff0000,0x010000);
175 s_col =
evolutecolor(s_col,s_colors[s_dstCol],0xff000000,0x01000000);
178 int colorlow = s_col;
183 rapport = 1.0F + (2.0F * (rapport - 1.0F));
185 rapport = std::min(rapport, 1.12F);
std::array< GoomSingleData, 2 > GoomDualData
#define ROUGE
position des composantes
Convenience inline random number generator functions.
int MythRandomInt(int min, int max)
generate a uniformly distributed random signed int in the closed interval [min, max].
bool rand_bool(uint32_t chance=2)
return a random bool with P(true) = 1/chance
void grid3d_free(grid3d **grid)
void grid3d_draw(grid3d *g, int color, int colorlow, int dist, int *buf, int *back, int W, int H)
grid3d * grid3d_new(int sizex, int defx, int sizez, int defz, v3d center)
void grid3d_update(grid3d *g, float angle, const float *vals, float dist)
static constexpr int8_t definitionx
static std::array< grid3d *, nbgrid > grille
static constexpr size_t nbgrid
static void lightencolor(int *col, float power)
static void pretty_move(float lcycle, float *dist, float *dist2, float *rotangle)
static int evolutecolor(unsigned int src, unsigned int dest, unsigned int mask, unsigned int incr)
static int ShiftRight(int x, int s)
static constexpr int8_t definitionz
void tentacle_update(int *buf, int *back, int W, int H, GoomDualData &data, float rapport, int drawit)
static unsigned char lighten(unsigned char value, float power)