From f3da42db0b3c3f01c2f65471c99f1678990c3063 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sun, 14 Sep 2003 15:39:23 +0000 Subject: New files of the "new" goom version. CVS patchset: 5377 CVS date: 2003/09/14 15:39:23 --- src/post/goom/tentacle3d.c | 221 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100755 src/post/goom/tentacle3d.c (limited to 'src/post/goom/tentacle3d.c') diff --git a/src/post/goom/tentacle3d.c b/src/post/goom/tentacle3d.c new file mode 100755 index 000000000..e90da7b58 --- /dev/null +++ b/src/post/goom/tentacle3d.c @@ -0,0 +1,221 @@ +#include + +#include "v3d.h" +#include "surf3d.h" +#include "goom_tools.h" +#include "goom_config.h" + +#define D 256.0f + +#define nbgrid 6 +#define definitionx 15 +#define definitionz 45 + +static float cycle = 0.0f; +static grid3d *grille[nbgrid]; +static float *vals; + +void tentacle_free () { + /* TODO : un vrai FREE GRID!! */ + free (vals); +// free (grille); +} + +void tentacle_new () { + int tmp; + + v3d center = {0,-17.0,0}; + vals = malloc ((definitionx+20)*sizeof(float)); + + for (tmp=0;tmp 0) { + val = (int) t; // (32.0f * log (t)); + if (val > 255) + val = 255; + if (val < 0) + val = 0; + return val; + } + else { + return 0; + } +} + +static void +lightencolor (int *col, float power) +{ + unsigned char *color; + + color = (unsigned char *) col; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); + color++; + *color = lighten (*color, power); +} + +// retourne x>>s , en testant le signe de x +#define ShiftRight(_x,_s) ((_x<0) ? -(-_x>>_s) : (_x>>_s)) + +static +int evolutecolor (unsigned int src,unsigned int dest, + unsigned int mask, unsigned int incr) { + int color = src & (~mask); + src &= mask; + dest &= mask; + + if ((src!=mask) + &&(srcdest) + src -= incr; + return (src&mask)|color; +} + +static void pretty_move (float cycle, + float *dist,float *dist2, + float *rotangle) { + static float distt = 10.0f; + static float distt2 = 0.0f; + static float rot = 0.0f; // entre 0 et 2 * M_PI + static int happens = 0; + float tmp; + static int rotation = 0; + static int lock = 0; + + if (happens) + happens -= 1; + else if (lock == 0) { + happens = iRAND(200)?0:100+iRAND(60); + lock = happens * 3 / 2; + } + else lock --; +// happens = 1; + + tmp = happens?8.0f:0; + *dist2 = distt2 = (tmp + 15.0f*distt2)/16.0f; + + tmp = 30+D-90.0f*(1.0f+sin(cycle*19/20)); + if (happens) + tmp *= 0.6f; + + *dist = distt = (tmp + 3.0f*distt)/4.0f; + + if (!happens){ + tmp = M_PI*sin(cycle)/32+3*M_PI/2; + } + else { + rotation = iRAND(500)?rotation:iRAND(2); + if (rotation) + cycle *= 2.0f*M_PI; + else + cycle *= -1.0f*M_PI; + tmp = cycle - (M_PI*2.0) * floor(cycle/(M_PI*2.0)); + } + + if (abs(tmp-rot) > abs(tmp-(rot+2.0*M_PI))) { + rot = (tmp + 15.0f*(rot+2*M_PI)) / 16.0f; + if (rot>2.0*M_PI) + rot -= 2.0*M_PI; + *rotangle = rot; + } + else if (abs(tmp-rot) > abs(tmp-(rot-2.0*M_PI))) { + rot = (tmp + 15.0f*(rot-2.0*M_PI)) / 16.0f; + if (rot<0.0f) + rot += 2.0*M_PI; + *rotangle = rot; + } + else + *rotangle = rot = (tmp + 15.0f*rot) / 16.0f; +} + +void tentacle_update(int *buf, int *back, int W, int H, + short data[2][512], float rapport, + int drawit) { + int tmp; + int tmp2; + + static int colors[] = { + (0x18<<(ROUGE*8))|(0x4c<<(VERT*8))|(0x2f<<(BLEU*8)), + (0x48<<(ROUGE*8))|(0x2c<<(VERT*8))|(0x6f<<(BLEU*8)), + (0x58<<(ROUGE*8))|(0x3c<<(VERT*8))|(0x0f<<(BLEU*8))}; + + static int col = (0x28<<(ROUGE*8))|(0x2c<<(VERT*8))|(0x5f<<(BLEU*8)); + static int dstcol = 0; + static float lig = 1.15f; + static float ligs = 0.1f; + + int color; + int colorlow; + + float dist,dist2,rotangle; + + if ((!drawit) && (ligs>0.0f)) + ligs = -ligs; + + lig += ligs; + + if (lig > 1.01f) { + if ((lig>10.0f) | (lig<1.1f)) ligs = -ligs; + + if ((lig<6.3f)&&(iRAND(30)==0)) + dstcol=iRAND(3); + + col = evolutecolor(col,colors[dstcol],0xff,0x01); + col = evolutecolor(col,colors[dstcol],0xff00,0x0100); + col = evolutecolor(col,colors[dstcol],0xff0000,0x010000); + col = evolutecolor(col,colors[dstcol],0xff000000,0x01000000); + + color = col; + colorlow = col; + + lightencolor(&color,lig * 2.0f + 2.0f); + lightencolor(&colorlow,(lig/3.0f)+0.67f); + + rapport = 1.0f + 2.0f * (rapport - 1.0f); + rapport *= 1.2f; + if (rapport > 1.12f) + rapport = 1.12f; + + pretty_move (cycle,&dist,&dist2,&rotangle); + + for (tmp=0;tmp 1000) + cycle = 0; + } +} -- cgit v1.2.3