2
* Copyright (C) 2002 Terence M. Welsh
3
* Ported to Linux by Tugrul Galatali <tugrul@galatali.com>
5
* Skyrocket is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Skyrocket is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include "skyrocket_shockwave.h"
23
#include "skyrocket_world.h"
25
extern unsigned int cloudtex;
27
float shockwavegeom[7][WAVESTEPS + 1][3];
34
shockwavegeom[0][0][0] = 1.0f;
35
shockwavegeom[0][0][1] = 0.0f;
36
shockwavegeom[0][0][2] = 0.0f;
37
shockwavegeom[1][0][0] = 0.985f;
38
shockwavegeom[1][0][1] = 0.035f;
39
shockwavegeom[1][0][2] = 0.0f;
40
shockwavegeom[2][0][0] = 0.95f;
41
shockwavegeom[2][0][1] = 0.05f;
42
shockwavegeom[2][0][2] = 0.0f;
43
shockwavegeom[3][0][0] = 0.85f;
44
shockwavegeom[3][0][1] = 0.05f;
45
shockwavegeom[3][0][2] = 0.0f;
46
shockwavegeom[4][0][0] = 0.75f;
47
shockwavegeom[4][0][1] = 0.035f;
48
shockwavegeom[4][0][2] = 0.0f;
49
shockwavegeom[5][0][0] = 0.65f;
50
shockwavegeom[5][0][1] = 0.01f;
51
shockwavegeom[5][0][2] = 0.0f;
52
shockwavegeom[6][0][0] = 0.5f;
53
shockwavegeom[6][0][1] = 0.0f;
54
shockwavegeom[6][0][2] = 0.0f;
56
for (i = 1; i <= WAVESTEPS; i++) {
57
ch = cos (6.28318530718f * (float (i) / float (WAVESTEPS)));
58
sh = sin (6.28318530718f * (float (i) / float (WAVESTEPS)));
59
for (j = 0; j <= 6; j++) {
60
shockwavegeom[j][i][0] = ch * shockwavegeom[j][0][0];
61
shockwavegeom[j][i][1] = shockwavegeom[j][0][1];
62
shockwavegeom[j][i][2] = sh * shockwavegeom[j][0][0];
67
// temp influences color intensity (0.0 - 1.0)
68
// texmove is amount to advance the texture coordinates
69
void drawShockwave (float temperature, float texmove)
73
static float u, v1, v2;
76
// setup diminishing alpha values in color array
77
if (temperature > 0.5f) {
87
temp = temperature * 2.0f;
89
colors[1][3] = temp * 0.9f;
90
colors[2][3] = temp * 0.8f;
91
colors[3][3] = temp * 0.7f;
92
colors[4][3] = temp * 0.5f;
93
colors[5][3] = temp * 0.3f;
96
// setup rgb values in color array
97
for (i = 0; i <= 5; i++) {
99
//colors[i][1] = temp + (((1.0f - temp) * 0.5f) - (1.0f - temp) * float(i) * 0.1f);
101
colors[i][2] = temperature;
104
glDisable (GL_CULL_FACE);
105
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
107
glEnable (GL_TEXTURE_2D);
108
glBindTexture (GL_TEXTURE_2D, cloudtex);
110
// draw bottom of shockwave
111
for (i = 0; i < 6; i++) {
112
v1 = float (i + 1) * 0.07f - texmove;
113
v2 = float (i) * 0.07f - texmove;
115
glBegin (GL_TRIANGLE_STRIP);
116
for (j = 0; j <= WAVESTEPS; j++) {
117
u = (float (j) / float (WAVESTEPS))*10.0f;
118
glColor4fv (colors[i + 1]);
119
glTexCoord2f (u, v1);
120
glVertex3f (shockwavegeom[i + 1][j][0], -shockwavegeom[i + 1][j][1], shockwavegeom[i + 1][j][2]);
121
glColor4fv (colors[i]);
122
glTexCoord2f (u, v2);
123
glVertex3f (shockwavegeom[i][j][0], -shockwavegeom[i][j][1], shockwavegeom[i][j][2]);
128
// keep colors a little warmer on top (more green)
129
if (temperature < 0.5f)
130
for (i = 1; i <= 5; i++)
131
colors[i][1] = temperature + 0.5f;
133
// draw top of shockwave
134
for (i = 0; i < 6; i++) {
135
v1 = float (i) * 0.07f - texmove;
136
v2 = float (i + 1) * 0.07f - texmove;
138
glBegin (GL_TRIANGLE_STRIP);
139
for (j = 0; j <= WAVESTEPS; j++) {
140
u = (float (j) / float (WAVESTEPS))*10.0f;
141
glColor4fv (colors[i]);
142
glTexCoord2f (u, v1);
143
glVertex3f (shockwavegeom[i][j][0], shockwavegeom[i][j][1], shockwavegeom[i][j][2]);
144
glColor4fv (colors[i + 1]);
145
glTexCoord2f (u, v2);
146
glVertex3f (shockwavegeom[i + 1][j][0], shockwavegeom[i + 1][j][1], shockwavegeom[i + 1][j][2]);
151
glEnable (GL_CULL_FACE);