2 * $Logfile: /Freespace2/code/Fireball/WarpInEffect.cpp $
7 * Code for rendering the warp in effects for ships
10 * Revision 1.1 2002/05/03 03:28:08 root
14 * 3 7/22/99 1:22p Dave
15 * Enable proper zbuffering for warpin glow effect.
17 * 2 10/07/98 10:52a Dave
20 * 1 10/07/98 10:48a Dave
22 * 23 4/08/98 8:20p John
23 * Made "Apex" of warp effect not move.
25 * 22 3/30/98 4:02p John
26 * Made machines with < 32 MB of RAM use every other frame of certain
27 * bitmaps. Put in code to keep track of how much RAM we've malloc'd.
29 * 21 3/29/98 12:39p John
30 * Made warp in glow page in
32 * 20 3/26/98 5:21p John
33 * Added new code to preload all bitmaps at the start of a level.
34 * Commented it out, though.
36 * 19 3/18/98 12:36p John
37 * Made hardware have nicer looking warp effect
39 * 18 3/16/98 4:51p John
40 * Added low-level code to clip all polygons against an arbritary plane.
41 * Took out all old model_interp_zclip and used this new method instead.
43 * 17 3/10/98 4:18p John
44 * Cleaned up graphics lib. Took out most unused gr functions. Made D3D
45 * & Glide have popups and print screen. Took out all >8bpp software
46 * support. Made Fred zbuffer. Made zbuffer allocate dynamically to
47 * support Fred. Made zbuffering key off of functions rather than one
50 * 16 3/04/98 7:07p John
51 * Added debug code to try to normalize a zerolength vector.
53 * 15 2/26/98 3:28p John
54 * fixed optimize compiler warning
56 * 14 2/24/98 6:36p John
57 * Made warp effect draw as a 4 poly cone.
59 * 13 2/22/98 12:19p John
60 * Externalized some strings
62 * 12 1/15/98 9:07p John
63 * Added noise to warp effect glow.
65 * 11 1/15/98 4:58p John
66 * Made warp effect use a looping ani. Made the scaling up & down be in
69 * 10 12/30/97 6:44p John
70 * Made g3_Draw_bitmap functions account for aspect of bitmap.
72 * 9 12/08/97 11:15a John
73 * added parameter to warpout for life.
75 * 8 12/05/97 3:46p John
76 * made ship thruster glow scale instead of being an animation.
78 * 7 12/02/97 3:59p John
79 * Added first rev of thruster glow, along with variable levels of
80 * translucency, which retquired some restructing of palman.
82 * 6 10/24/97 12:18p John
83 * sped up warp effect by decreasing number of polys with distance.
85 * 5 9/15/97 5:45p John
86 * took out chunk stuff.
87 * made pofview display thrusters as blue polies.
89 * 4 9/12/97 4:02p John
90 * put in ship warp out effect.
91 * put in dynamic lighting for warp in/out
93 * 3 9/09/97 4:49p John
94 * Almost done ship warp in code
96 * 2 9/08/97 8:39a John
97 * added in code structure for grid
99 * 1 9/05/97 10:07a John
113 #include "floating.h"
115 #include "lighting.h"
118 #include "systemvars.h"
119 #include "animplay.h"
120 #include "fireballs.h"
121 #include "linklist.h"
124 DCF(norm,"normalize a zero length vector")
127 vector tmp = vmd_zero_vector;
128 vm_vec_normalize(&tmp);
132 void draw_face( vertex *v1, vertex *v2, vertex *v3 )
137 vm_vec_perp(&norm,(vector *)&v1->x,(vector *)&v2->x,(vector *)&v3->x);
138 if ( vm_vec_dot(&norm,(vector *)&v1->x ) >= 0.0 ) {
148 g3_draw_poly( 3, vertlist, TMAP_FLAG_TEXTURED );
152 void warpin_render(matrix *orient, vector *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius )
156 int saved_gr_zbuffering = gr_zbuffer_get();
158 // gr_zbuffering = 0;
160 gr_set_bitmap( texture_bitmap_num, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
162 float Grid_depth = radius/2.5f;
166 vm_vec_scale_add( ¢er, pos, &orient->fvec, -(max_radius/2.5f)/3.0f );
171 vm_vec_scale_add( &vecs[0], ¢er, &orient->uvec, radius );
172 vm_vec_scale_add2( &vecs[0], &orient->rvec, -radius );
173 vm_vec_scale_add2( &vecs[0], &orient->fvec, Grid_depth );
175 vm_vec_scale_add( &vecs[1], ¢er, &orient->uvec, radius );
176 vm_vec_scale_add2( &vecs[1], &orient->rvec, radius );
177 vm_vec_scale_add2( &vecs[1], &orient->fvec, Grid_depth );
179 vm_vec_scale_add( &vecs[2], ¢er, &orient->uvec, -radius );
180 vm_vec_scale_add2( &vecs[2], &orient->rvec, radius );
181 vm_vec_scale_add2( &vecs[2], &orient->fvec, Grid_depth );
183 vm_vec_scale_add( &vecs[3], ¢er, &orient->uvec, -radius );
184 vm_vec_scale_add2( &vecs[3], &orient->rvec, -radius );
185 vm_vec_scale_add2( &vecs[3], &orient->fvec, Grid_depth );
187 // vm_vec_scale_add( &vecs[4], ¢er, &orient->fvec, -Grid_depth );
190 verts[0].u = 0.01f; verts[0].v = 0.01f;
191 verts[1].u = 0.99f; verts[1].v = 0.01f;
192 verts[2].u = 0.99f; verts[2].v = 0.99f;
193 verts[3].u = 0.01f; verts[3].v = 0.99f;
194 verts[4].u = 0.5f; verts[4].v = 0.5f;
196 for (i=0; i<5; i++ ) {
197 g3_rotate_vertex( &verts[i], &vecs[i] );
200 draw_face( &verts[0], &verts[4], &verts[1] );
201 draw_face( &verts[1], &verts[4], &verts[2] );
202 draw_face( &verts[4], &verts[3], &verts[2] );
203 draw_face( &verts[0], &verts[3], &verts[4] );
205 if ( Warp_glow_bitmap != -1 ) {
206 gr_set_bitmap( Warp_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
212 #define OUT_PERCENT1 0.80f
213 #define OUT_PERCENT2 0.90f
215 #define IN_PERCENT1 0.10f
216 #define IN_PERCENT2 0.20f
218 if ( life_percent < IN_PERCENT1 ) {
221 } else if ( life_percent < IN_PERCENT2 ) {
222 r *= ( life_percent-IN_PERCENT1 ) / (IN_PERCENT2-IN_PERCENT1);
224 } else if ( life_percent < OUT_PERCENT1 ) {
227 } else if ( life_percent < OUT_PERCENT2 ) {
228 r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2-OUT_PERCENT1);
236 int saved_gr_zbuffering = gr_zbuffer_get();
237 gr_zbuffer_set(GR_ZBUFF_READ);
240 //float Noise[NOISE_NUM_FRAMES] = {
241 int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
243 r *= (0.40f + Noise[noise_frame]*0.30f);
245 g3_draw_bitmap( &verts[4], 0,r, TMAP_FLAG_TEXTURED );
246 gr_zbuffer_set(saved_gr_zbuffering);
250 gr_zbuffer_set( saved_gr_zbuffering );