Author Topic: warp in model now loading from pof  (Read 6056 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
as you can see in the image below I have gotten the warphole model to render as it should in game, this will be most usefull for TBP, but it does offer an improvement for normal FS as well, I still have to implement LOD and as you can see in the image I forgot to turn off backface culling (fixed it right after takeing the pic), but this is one of the things that we have wanted for a while, and the code I used can be used for other such cool efects like 3D explosions and such

I will commit this as soon as I get it all ironed out
(I may save my changes and start from a clean update becase I have developed this problem were the game has a 40% chance of hard freazeing on stratup, it didn't start doing this untill after I commited my last changes so I'm worried that this may be something that was introduced around that time, by me or someone else)
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

  

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
warp in model now loading from pof
Btw, how did it used to work?
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline aldo_14

  • Gunnery Control
  • 213
warp in model now loading from pof
Quote
Originally posted by Sesquipedalian
Btw, how did it used to work?


ani mapped onto a flat polygon, I think.

This allows, I reckon, for better subspace 'tunnels' to be modelled (as the warpout pof)

 

Offline Fury

  • The Curmudgeon
  • 213
warp in model now loading from pof
Quote
Originally posted by aldo_14


ani mapped onto a flat polygon, I think.

This allows, I reckon, for better subspace 'tunnels' to be modelled (as the warpout pof)


You think we could have 3D jump point?

Most definitely a good think for TBP, B5 cone-like jump point.
There at least two different effects though... one seen in A Call to Arms-movie and another in the series and ItB. And a new one seen in The Legend of the Rangers.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
the way it's setup, you can have any model that falls within the normal pof limetations, and any warpin/out (these can still be diferent) ani mapped to it, I actualy made a warp model for TBP for testing though it could use some work,
is there a quick vidio of a ship exiting hyperspace that I could examine to try and reproduce for the effect
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline tomcat

  • Dark Lord of Truespace
  • 28
warp in model now loading from pof
Bob that is the most USEFULL thing u did for TBP with source code;7  -- try it with a cone one but with a animated texture that make like it is changing alpha channel from 0% to final blue efect:)
Truespace is the path of the Dark Side
-----------------------------------------------
Dark Truespace Master Tomcat

 

Offline Fury

  • The Curmudgeon
  • 213
warp in model now loading from pof
Five short avi captures are soon up. Wait a few mins.

OK, here are ITB captures.

And Bobboau, don't you have ICQ? Communication would be tad easier. :)
« Last Edit: October 22, 2002, 09:45:07 am by 173 »

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
no ICQ, it doesn't like me and the feeling is mutual

for the coders (and me for backup)

WarpInEffect.cpp
add
Code: [Select]

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
Code: [Select]

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
Code: [Select]

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
Code: [Select]
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
Code: [Select]

} 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)
Code: [Select]

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
Code: [Select]

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
Code: [Select]

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));
}
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Joey_21

  • 28
    • http://denebsystem.cjb.net/
warp in model now loading from pof
Very neat. :nod:

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
looking at those clips I may have to add a step in frot of the current warpin effect were it has a cone of beam like objects and the warp glow that fade just as the warp model opens,
might it be a good idea to scale the ship models as they are going through the effect (I think I can do that now)
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline LAM3O

  • 25
warp in model now loading from pof
"might it be a good idea to scale the ship models as they are going through the effect (I think I can do that now)
"

Amazing!!!

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
key word being 'think', I haven't actualy tried yet
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Fury

  • The Curmudgeon
  • 213
warp in model now loading from pof
Quote
Originally posted by Bobboau
might it be a good idea to scale the ship models as they are going through the effect (I think I can do that now)


Wow... until now I thought that is not possible...
Way to go Bobboau! I hope you will succeed! :D

 

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
warp in model now loading from pof
maybe you could even make it so, that you can´t see ships from behind the warphole.

right, now.

you just see a ship appearing, and in case of scale, you would see a ship "grow".

and in the case it has to travel a bit while it grows like in TBP

Disable collisions or else u know what will happen to ships behind the warphole.
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
warp in model now loading from pof
ships in stage 1 warpin already have there colision disabled
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline RandomTiger

  • Senior Member
  • 211
warp in model now loading from pof
Quote
Originally posted by DTP
maybe you could even make it so, that you can´t see ships from behind the warphole.


You could use the dot product of the direction of the cone and the vector from the cone start to the viewing ship to determine if it should be seen by checking the resulting angle against the average angle of the cone.


 

Offline Fury

  • The Curmudgeon
  • 213
warp in model now loading from pof
By the way, would it be possible somehow define jump anim size regardless of ship's size?

I mean, mostly only military ships have jump capability in B5. It would add a lot of atmosphere to our mod if we could simulate this in the way that one jump point is used by numerous ships.

 

Offline RandomTiger

  • Senior Member
  • 211
warp in model now loading from pof
Quote
Originally posted by Mr. Fury
By the way, would it be possible somehow define jump anim size regardless of ship's size?

I mean, mostly only military ships have jump capability in B5. It would add a lot of atmosphere to our mod if we could simulate this in the way that one jump point is used by numerous ships.


That would be very cool for TBP and other mods.

 

Offline Anaz

  • 210
warp in model now loading from pof
I think I know how to do that just using this...
you make a big invisible cube, and have it warp in, and in the space where it warps in, you just have all of the ships that you want to appear come out with no warp effect.
Arrr. I'm a pirate.

AotD, DatDB, TVWP, LM. Ph34r.

You WILL go to warpstorm...

 

Offline Solatar

  • 211
warp in model now loading from pof
Yeah, but make sure the cube has a "no_collide_invisible" tag. Or it might look funny.