- m.transparent = true;
- m.blendfunc1 = GL_SRC_ALPHA;
- m.blendfunc2 = GL_ONE; //_MINUS_SRC_ALPHA;
- m.numtriangles = EXPLOSIONTRIS;
- m.index = &explosiontris[0][0];
- m.numverts = EXPLOSIONVERTS;
- m.vertex = &e->vert[0][0];
- m.vertexstep = sizeof(float[3]);
- alpha = e->alpha;
- //if (alpha > 1)
- // alpha = 1;
- m.cr = 1;
- m.cg = 1;
- m.cb = 1;
- m.ca = 1; //alpha;
- m.color = &c[0][0];
- m.colorstep = sizeof(float[4]);
- VectorSubtract(r_origin, e->origin, centerdir);
- VectorNormalizeFast(centerdir);
- /*
- centerdist = DotProduct(e->origin, centerdir);
- size = 0;
- for (i = 0;i < EXPLOSIONVERTS;i++)
- {
- dist = DotProduct(e->vert[i], centerdir) - centerdist;
- if (size < dist)
- size = dist;
- }
- scale = 4.0f / size;
- */
- if (fogenabled)
- {
- for (i = 0;i < EXPLOSIONVERTS;i++)
- {
- //dist = (DotProduct(e->vert[i], centerdir) - centerdist) * scale - 2.0f;
- VectorSubtract(e->vert[i], e->origin, diff);
- VectorNormalizeFast(diff);
- dist = DotProduct(diff, centerdir) * 6.0f - 4.0f;
- if (dist > 0)
- {
- // use inverse fog alpha as color
- VectorSubtract(e->vert[i], r_origin, diff);
- ifog = 1 - exp(fogdensity/DotProduct(diff,diff));
- if (ifog < 0)
- ifog = 0;
- c[i][0] = c[i][1] = c[i][2] = dist * alpha * ifog;
- }
- else
- c[i][0] = c[i][1] = c[i][2] = 0;
- c[i][3] = 1;
- }
- }
- else
- {
- for (i = 0;i < EXPLOSIONVERTS;i++)
- {
- //dist = (DotProduct(e->vert[i], centerdir) - centerdist) * scale - 2.0f;
- VectorSubtract(e->vert[i], e->origin, diff);
- VectorNormalizeFast(diff);
- dist = DotProduct(diff, centerdir) * 6.0f - 4.0f;
- if (dist > 0)
- c[i][0] = c[i][1] = c[i][2] = dist * alpha;
- else
- c[i][0] = c[i][1] = c[i][2] = 0;
- c[i][3] = 1;
- }
- }
- /*
- if (fogenabled)
- {
- m.color = &c[0][0];
- m.colorstep = sizeof(float[4]);
- for (i = 0;i < EXPLOSIONVERTS;i++)
- {
- // use inverse fog alpha as color
- VectorSubtract(e->vert[i], r_origin, diff);
- ifog = 1 - exp(fogdensity/DotProduct(diff,diff));
- if (ifog < 0)
- ifog = 0;
- c[i][0] = ifog;
- c[i][1] = ifog;
- c[i][2] = ifog;
- c[i][3] = alpha;
- }
- }
- */