no ICQ, it doesn't like me and the feeling is mutual
for the coders (and me for backup)
WarpInEffect.cpp
add
float model_Interp_scale_x; //added these three for warpin stuff-Bobbau
float model_Interp_scale_y;
float model_Interp_scale_z;
int marp_Model; //global warp model number
replace
void warpin_render(matrix *orient, vector *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius )
{
int i;
int saved_gr_zbuffering = gr_zbuffer_get();
// gr_zbuffering = 0;
float Grid_depth = radius/2.5f;
vector center;
vm_vec_scale_add( ¢er, pos, &orient->vec.fvec, -(max_radius/2.5f)/3.0f );
// Warp_Map = texture_bitmap_num;//sets the warp map, and thus sets the interp flag for this being a warpin effect
vector vecs[5];
vertex verts[5];
if(wm > -1){
model_Interp_scale_x = radius /20;
model_Interp_scale_y = radius /20;
model_Interp_scale_z = radius /20;
set_warp_gloabals(model_Interp_scale_x, model_Interp_scale_y, model_Interp_scale_z, texture_bitmap_num);
float dist = vm_vec_dist_quick( pos, &Eye_position );
model_set_detail_level((int)(dist / (radius * 10.0f)));
gr_set_cull(0);
model_render( wm, orient, pos, MR_NO_LIGHTING | MR_NORMAL);
gr_set_cull(1);
// Warp_Map = -1;//un sets the warp map
model_Interp_scale_x = 1.0f;
model_Interp_scale_y = 1.0f;
model_Interp_scale_z = 1.0f;
set_warp_gloabals(model_Interp_scale_x, model_Interp_scale_y, model_Interp_scale_z, -1);
vecs[4] = center; //this is for the warp glow-Bobboau
verts[4].u = 0.5f; verts[4].v = 0.5f;
g3_rotate_vertex( &verts[4], &vecs[4] );
}else{
gr_set_bitmap( texture_bitmap_num, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
vm_vec_scale_add( &vecs[0], ¢er, &orient->vec.uvec, radius );
vm_vec_scale_add2( &vecs[0], &orient->vec.rvec, -radius );
vm_vec_scale_add2( &vecs[0], &orient->vec.fvec, Grid_depth );
vm_vec_scale_add( &vecs[1], ¢er, &orient->vec.uvec, radius );
vm_vec_scale_add2( &vecs[1], &orient->vec.rvec, radius );
vm_vec_scale_add2( &vecs[1], &orient->vec.fvec, Grid_depth );
vm_vec_scale_add( &vecs[2], ¢er, &orient->vec.uvec, -radius );
vm_vec_scale_add2( &vecs[2], &orient->vec.rvec, radius );
vm_vec_scale_add2( &vecs[2], &orient->vec.fvec, Grid_depth );
vm_vec_scale_add( &vecs[3], ¢er, &orient->vec.uvec, -radius );
vm_vec_scale_add2( &vecs[3], &orient->vec.rvec, -radius );
vm_vec_scale_add2( &vecs[3], &orient->vec.fvec, Grid_depth );
// vm_vec_scale_add( &vecs[4], ¢er, &orient->vec.fvec, -Grid_depth );
vecs[4] = center;
verts[0].u = 0.01f; verts[0].v = 0.01f;
verts[1].u = 0.99f; verts[1].v = 0.01f;
verts[2].u = 0.99f; verts[2].v = 0.99f;
verts[3].u = 0.01f; verts[3].v = 0.99f;
verts[4].u = 0.5f; verts[4].v = 0.5f;
for (i=0; i<5; i++ ) {
g3_rotate_vertex( &verts[i], &vecs[i] );
}
draw_face( &verts[0], &verts[4], &verts[1] );
draw_face( &verts[1], &verts[4], &verts[2] );
draw_face( &verts[4], &verts[3], &verts[2] );
draw_face( &verts[0], &verts[3], &verts[4] );
}
if ( Warp_glow_bitmap != -1 ) {
gr_set_bitmap( Warp_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
float r = radius;
int render_it;
#define OUT_PERCENT1 0.80f
#define OUT_PERCENT2 0.90f
#define IN_PERCENT1 0.10f
#define IN_PERCENT2 0.20f
if ( life_percent < IN_PERCENT1 ) {
// do nothing
render_it = 0;
} else if ( life_percent < IN_PERCENT2 ) {
r *= ( life_percent-IN_PERCENT1 ) / (IN_PERCENT2-IN_PERCENT1);
render_it = 1;
} else if ( life_percent < OUT_PERCENT1 ) {
// do nothing
render_it = 1;
} else if ( life_percent < OUT_PERCENT2 ) {
r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2-OUT_PERCENT1);
render_it = 1;
} else {
// do nothing
render_it = 0;
}
if (render_it) {
int saved_gr_zbuffering = gr_zbuffer_get();
gr_zbuffer_set(GR_ZBUFF_READ);
// Add in noise
//float Noise[NOISE_NUM_FRAMES] = {
int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
r *= (0.40f + Noise[noise_frame]*0.30f);
g3_draw_bitmap( &verts[4], 0,r, TMAP_FLAG_TEXTURED );
gr_zbuffer_set(saved_gr_zbuffering);
}
}
gr_zbuffer_set( saved_gr_zbuffering );
}
in FireBalls.cpp
replace
void fireball_load_data()
{
int i, idx;
fireball_info *fd;
for ( i = 0; i < MAX_FIREBALL_TYPES; i++ ) {
fd = &Fireball_info[i];
for(idx=0; idxlod_count; idx++){
fd->lod[idx].bitmap_id = bm_load_animation( fd->lod[idx].filename, &fd->lod[idx].num_frames, &fd->lod[idx].fps, 1 );
if ( fd->lod[idx].bitmap_id < 0 ) {
Error(LOCATION, "Could not load %s anim file\n", fd->lod[idx].filename);
}
}
}
if ( Warp_glow_bitmap == -1 ) {
Warp_glow_bitmap = bm_load( NOX("warpglow01") );
}
polymodel Warp_pm;
mprintf(("loading warp model\n"));
wm = -1;
wm = model_load("warp.pof", 0, NULL);
}
add
extern int wm;
to FireBalls.h,
origonaly I tried doing this with a buch of globals but it didn't workout right
in ModelInterp.cpp
this gets spliced into model_interp_defpoints between the part that scales the thrusters and the part that does everything else
} else if((Model_Interp_scale_x != 1) || (Model_Interp_scale_y != 1) || (Model_Interp_scale_z != 1)) {
mprintf(("warp model being scaled by %f %f %f\n",Model_Interp_scale_x ,Model_Interp_scale_y, Model_Interp_scale_z));
for (n=0; n {
vector tmp;
Interp_verts[n] = src;
tmp.xyz.x = src->xyz.x * Model_Interp_scale_x;
tmp.xyz.y = src->xyz.y * Model_Interp_scale_y;
tmp.xyz.z = src->xyz.z * Model_Interp_scale_z;
g3_rotate_vertex(dest,&tmp);
src++; // move to normal
for (i=0; i {
Interp_light_applied[next_norm] = 0;
Interp_norms[next_norm] = src;
next_norm++;
src++;
}
dest++;
}
}else{
replace model_interp_tmappoly (there'se stuff other than just the warp thing added to this)
void model_interp_tmappoly(ubyte * p,polymodel * pm)
{
vertex *Interp_list[TMAP_MAX_VERTS];
int i;
int nv;
model_tmap_vert *verts;
int is_invisible = 0;
if(Warp_Map < 0){
if ((!Interp_thrust_scale_subobj) && (pm->textures[w(p+40)]<0)) {
// Don't draw invisible polygons.
if ( !(Interp_flags & MR_SHOW_INVISIBLE_FACES)) {
return;
} else {
is_invisible = 1;
}
}
}
nv = w(p+36);
// Tmap_show_layers = 1;
#ifndef NDEBUG
modelstats_num_polys++;
#endif
if(Warp_Map < 0){
if (!g3_check_normal_facing(vp(p+20),vp(p+8)) && !(Interp_flags & MR_NO_CULL)) return;
}
if ( nv < 0 ) return;
verts = (model_tmap_vert *)(p+44);
for (i=0;i {
Interp_list[i] = &Interp_points[verts[i].vertnum];
Interp_list[i]->u = verts[i].u;
Interp_list[i]->v = verts[i].v;
if ( Interp_subspace ) {
Interp_list[i]->v += Interp_subspace_offset_u;
Interp_list[i]->u += Interp_subspace_offset_v;
Interp_list[i]->r = Interp_subspace_r;
Interp_list[i]->g = Interp_subspace_g;
Interp_list[i]->b = Interp_subspace_b;
} else {
// if ( !(pm->flags & PM_FLAG_ALLOW_TILING) ) {
// Assert(verts[i].u <= 1.0f );
// Assert(verts[i].v <= 1.0f );
// }
// Assert( verts[i].normnum == verts[i].vertnum );
if ( (Interp_flags & MR_NO_LIGHTING) || (pm->ambient[w(p+40)])) { //gets the ambient glow to work
if ( D3D_enabled ) {
Interp_list[i]->r = 191;
Interp_list[i]->g = 191;
Interp_list[i]->b = 191;
} else {
Interp_list[i]->b = 191;
}
} else {
int vertnum = verts[i].vertnum;
int norm = verts[i].normnum;
if ( Interp_flags & MR_NO_SMOOTHING ) {
if ( D3D_enabled ) {
light_apply_rgb( &Interp_list[i]->r, &Interp_list[i]->g, &Interp_list[i]->b, Interp_verts[vertnum], vp(p+8), Interp_light );
} else {
Interp_list[i]->b = light_apply( Interp_verts[vertnum], vp(p+8), Interp_light );
}
} else {
// if we're applying lighting as normal, and not using saved lighting
if ( !Interp_use_saved_lighting && !Interp_light_applied[norm] ) {
if ( D3D_enabled ) {
light_apply_rgb( &Interp_lighting->r[norm], &Interp_lighting->g[norm], &Interp_lighting->b[norm], Interp_verts[vertnum], Interp_norms[norm], Interp_light );
} else {
int li;
ubyte l;
l = light_apply( Interp_verts[vertnum], Interp_norms[norm], Interp_light );
if ( Detail.lighting > 1 ) {
// Add in precalculated muzzle flashes
float fl = i2fl(l)/255.0f;
ubyte *tmp = &Interp_lights[norm*pm->num_lights];
for ( li=0; linum_lights; li++ ) {
fl += i2fl(tmp[li])*pm->lights[li].value;
}
if ( fl < 0.0f ) {
fl = 0.0f;
} else if ( fl > 1.0f ) {
fl = 1.0f;
}
l = (ubyte)fl2i(fl*255.0f);
}
Interp_lighting->b[norm] = l;
}
Interp_light_applied[norm] = 1;
}
if ( D3D_enabled ) {
Interp_list[i]->r = Interp_lighting->r[norm];
Interp_list[i]->g = Interp_lighting->g[norm];
Interp_list[i]->b = Interp_lighting->b[norm];
} else {
Interp_list[i]->b = Interp_lighting->b[norm];
}
}
}
}
// Assert(verts[i].u >= 0.0f );
// Assert(verts[i].v >= 0.0f );
}
#ifndef NDEBUG
modelstats_num_polys_drawn++;
#endif
if (!(Interp_flags & MR_NO_POLYS) ) {
if ( is_invisible ) {
gr_set_color( 0, 255, 0 );
g3_draw_poly( nv, Interp_list, 0 );
} else if (Interp_thrust_scale_subobj) {
if ((Interp_thrust_bitmap>-1) && (Interp_thrust_scale > 0.0f) && !Pofview_running) {
gr_set_bitmap( Interp_thrust_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.2f );
g3_draw_poly( nv, Interp_list, TMAP_FLAG_TEXTURED );
} else if(!Pofview_running){
if ( !(Interp_flags & MR_SHOW_OUTLINE_PRESET) ) {
gr_set_color( 128, 128, 255 );
}
uint tflags = Interp_tmap_flags;
tflags &= (~(TMAP_FLAG_TEXTURED|TMAP_FLAG_TILED|TMAP_FLAG_CORRECT));
g3_draw_poly( nv, Interp_list, tflags );
}
} else if(Warp_Map > -1){ //warpin effect-Bobboau
gr_set_bitmap( Warp_Map, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
g3_draw_poly( nv, Interp_list, TMAP_FLAG_TEXTURED );
}else{
// all textured polys go through here
if ( Interp_tmap_flags & TMAP_FLAG_TEXTURED ) {
// subspace special case
if ( Interp_subspace && D3D_enabled ) {
gr_set_bitmap( pm->textures[w(p+40)], GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.2f );
}
// all other textures
else {
int texture;
// if we're rendering a nebula background pof, maybe select a custom texture
if((Interp_flags & MR_FORCE_TEXTURE) && (Interp_forced_bitmap >= 0)){
texture = Interp_forced_bitmap;
} else {
if (pm->is_ani[w(p+40)]){
texture = pm->textures[w(p+40)] + ((timestamp() / (int)(pm->fps[w(p+40)])) % pm->numframes[w(p+40)]);//here is were it picks the texture to render for ani-Bobboau
}else{
texture = pm->textures[w(p+40)];//here is were it picks the texture to render for normal-Bobboau
}
}
// muzzle flashes draw xparent
if(Interp_flags & MR_ALL_XPARENT){
gr_set_bitmap( texture, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, Interp_xparent_alpha );
} else {
if(pm->transparent[w(p+40)]){ //trying to get transperent textures-Bobboau
gr_set_bitmap( texture, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.8f );
}else{
gr_set_bitmap( texture );
}
}
}
} else {
if ( !(Interp_flags & MR_SHOW_OUTLINE_PRESET) ) {
gr_set_color( 128, 128, 128 );
}
}
if ( Interp_subspace ) {
g3_draw_poly( nv, Interp_list, TMAP_FLAG_TEXTURED|TMAP_FLAG_TILED|TMAP_FLAG_CORRECT );
} else {
if(Interp_flags & MR_ALL_XPARENT){
g3_draw_poly( nv, Interp_list, Interp_tmap_flags );
} else {
g3_draw_poly( nv, Interp_list, Interp_tmap_flags|TMAP_FLAG_NONDARKENING );
}
}
}
}
if (Interp_flags & (MR_SHOW_OUTLINE|MR_SHOW_OUTLINE_PRESET) ) {
if ( Interp_flags & MR_SHOW_OUTLINE ) {
gr_set_color_fast( &Interp_outline_color );
}
for (i=0; i {
int j = (i + 1) % nv;
g3_draw_line(Interp_list[i], Interp_list[j] );
}
}
}
some gloabals for the model system
float Model_Interp_scale_x = 1.0f; //added these three for warpin stuff-Bobbau
float Model_Interp_scale_y = 1.0f;
float Model_Interp_scale_z = 1.0f;
int Warp_Model = -1; //global warp model number
int Warp_Map = -1; //global map to be used while rendering the warp model
this sets the globals from the warpin effect
void set_warp_gloabals(float, float, float, int);
void set_warp_gloabals(float a, float b, float c, int d){
Model_Interp_scale_x =a;
Model_Interp_scale_y=b;
Model_Interp_scale_z=c;
Warp_Map=d;
mprintf(("warpmap being set to %d\n",Warp_Map));
}