Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Bobboau on September 21, 2002, 02:44:34 am
-
ok I've gotten after burner trails to work, they still need some tweakage, and some of the values I am going to recode so they can be specifyed through the ships table, but the main bulk of the code I have done now shouldn't change too much
allright in ShipContrails.cpp I added a bunch of new functions wich do basicly the same thing as the ones in there now but rather than doing the nebula trails it does the ABtrails
new forward declairations (these go at the top of the file right under the ones there now)
// determine if the ship has AB trails
int ct_has_ABtrails(ship *shipp);
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp);
// create new ABtrails
void ct_create_ABtrails(ship *shipp);
made changes to ct_ship_create so it will initalise both neb trails and ABtrails
// call when a ship is created to initialize its contrail stuff
void ct_ship_create(ship *shipp)
{
int idx;
Assert(shipp != NULL);
// null out the ct indices for this guy
for(idx=0; idx shipp->trail_num[idx] = (short)-1;
}
for(idx=0; idx shipp->ABtrail_num[idx] = (short)-1;
}
}
a similar thing here
// call when a ship is deleted to free up its contrail stuff
void ct_ship_delete(ship *shipp)
{
int idx;
Assert(shipp != NULL);
// free up any contrails this guy may have had
for(idx=0; idx if(shipp->trail_num[idx] >= 0){
trail_object_died(shipp->trail_num[idx]);
shipp->trail_num[idx] = (short)-1;
}
if(shipp->ABtrail_num[idx] >= 0){
trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
}
add this to the first line in ct_ship_process
ct_ship_process_ABtrails(shipp);//seems like as good a place as any -Bobboau
here's the real meat of the code, the ABtrail proces, creation, and updateing code, this is all below everything else
// call each frame for processing a ship's ABtrails
void ct_ship_process_ABtrails(ship *shipp)
{
int idx;
object *objp;
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
objp = &Objects[shipp->objnum];
// if this is not a ship, we don't care
if((objp->type != OBJ_SHIP) || (Ship_info[Ships[objp->instance].ship_info_index].ct_count <= 0)){
return;
}
Assert(objp->instance >= 0);
shipp = &Ships[objp->instance];
if(!(objp->phys_info.flags & PF_AFTERBURNER_ON)){ //if the after burners aren't on -Bobboau
for(idx=0; idx trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
// if the object already has ABtrails
if(ct_has_ABtrails(shipp)){
ct_update_ABtrails(shipp);
}
// otherwise add new ones
else {
ct_create_ABtrails(shipp);
}
/* if(shipp->ab_info->stamp > timestamp( (int)(shipp->ab_info->max_life * 1000) ) ){
for(idx=0; idx if(shipp->ABtrail_num[idx] >= 0){
trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
}
*/
}
// create new ABtrails
void ct_create_ABtrails(ship *shipp)
{
vector v1;
int idx;
matrix m;
ship_info *sip;
object *objp;
// get object and ship info
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
Assert(shipp->ship_info_index >= 0);
objp = &Objects[shipp->objnum];
sip = &Ship_info[shipp->ship_info_index];
// get the inverse rotation matrix
vm_copy_transpose_matrix(&m, &objp->orient);
if(objp->phys_info.flags & PF_AFTERBURNER_ON){//AB trails-Bobboau
for(idx=0; idxab_count; idx++){
shipp->ABtrail_num[idx] = (short)trail_create(shipp->ab_info[idx]);
// get the point for the contrail
vm_vec_rotate(&v1, &shipp->ab_info[idx].pt, &m);
vm_vec_add2(&v1, &objp->pos);
// if the spew stamp has elapsed
if(trail_stamp_elapsed(shipp->ABtrail_num[idx])){
trail_add_segment(shipp->ABtrail_num[idx], &v1);
trail_set_stamp(shipp->ABtrail_num[idx]);
} else {
trail_set_segment(shipp->ABtrail_num[idx], &v1);
}
}
/* if( objp == Player_obj){
HUD_printf("trailnum %d", shipp->ABtrail_num[0]);
}
*/
}
}
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp)
{
vector v1;
matrix m;
int idx;
ship_info *sip;
object *objp;
// get object and ship info
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
Assert(shipp->ship_info_index >= 0);
objp = &Objects[shipp->objnum];
sip = &Ship_info[shipp->ship_info_index];
// get the inverse rotation matrix
vm_copy_transpose_matrix(&m, &objp->orient);
for(idx=0; idx if(objp->phys_info.flags & PF_AFTERBURNER_ON){//ABtrails
if(shipp->ABtrail_num[idx] >= 0){
// get the point for the contrail
vm_vec_rotate(&v1, &shipp->ab_info[idx].pt, &m);
vm_vec_add2(&v1, &objp->pos);
// if the spew stamp has elapsed
if(trail_stamp_elapsed(shipp->ABtrail_num[idx])){
trail_add_segment(shipp->ABtrail_num[idx], &v1);
trail_set_stamp(shipp->ABtrail_num[idx]);
} else {
trail_set_segment(shipp->ABtrail_num[idx], &v1);
}
}
}
}
}
// if a ship has active ABtrails
int ct_has_ABtrails(ship *shipp)
{
int idx;
for(idx=0; idx if(shipp->ABtrail_num[idx] >= 0){
return 1;
}
}
// no contrails
return 0;
}
add this to the end of ShipContrails.h
// call each frame for processing a ship's contrails
void ct_ship_process_ABtrails(ship *shipp);
// determine if the ship has AB trails
int ct_has_ABtrails(ship *shipp);
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp);
// create new ABtrails
void ct_create_ABtrails(ship *shipp);
there now you have all the code for handeling the trails, but we still need to make chages to the ship structure in ship.h
these need to be added
short ABtrail_num[MAX_SHIP_CONTRAILS]; //after burner trails -Bobboau
trail_info ab_info[MAX_SHIP_CONTRAILS];
int ab_count;
now this following code is subject to change, it assigns the inital values for the ABtrails, things like position are going to remain hard coded, things like the bitmap and posably max life are defonantly going into the table, things like width alpha, I might make a factoring value
this goes into ship_create down near the bottom just before the ct_ship_create(shipp);
trail_info *ci;
//first try at ABtrails -Bobboau
shipp->ab_count = 0;
//if(sip->flags & SIF_AFTERBURNER){
for(int h = 0; h < pm->n_thrusters; h++){
for(int j = 0; j < pm->thrusters->num_slots; j++){
// this means you've reached the max # of AB trails for a ship
Assert(sip->ct_count <= MAX_SHIP_CONTRAILS);
ci = &shipp->ab_info[shipp->ab_count++];
// ci = &sip->ct_info[sip->ct_count++];
ci->pt = pm->thrusters[h].pnt[j];//offset
ci->w_start = pm->thrusters[h].radius[j];//width
ci->w_end = 0.05f;//end width
ci->a_start = 1.0f;//start alpha
ci->a_end = 0.0f;//end alpha
ci->max_life = 5.0f;//max life
ci->stamp = 60; //spew time???
ci->bitmap = bm_load("ABtrail");
//loading this bitmap as default for now,
//I might add this to the afterburner section of the ships.tbl later
}
}
//}//end AB trails -Bobboau
remember my executable is right here (http://freespace.volitionwatch.com/blackwater/FS3.zip), also in there are the other things I have done to date, the code is currently being beta tested, make sure you have no mods instaled and make a new pilot,
you stand about a %50 chance of this not crashing good luck ;)
-
50% lol :)
EDIT ok its like 0% for me
Assert: ship_count <= MAX_SHIP_TYPES
File: D:\Games\projects\freespace2_public\code\Playerman\ManagePilot.cpp
Line: 478
Call stack:
------------------------------------------------------------------
FS3.exe 005644b0()
FS3.exe 0056686d()
FS3.exe 004385de()
FS3.exe 00504c21()
FS3.exe 004377b1()
FS3.exe 0050508e()
FS3.exe 0043a2ec()
FS3.exe 0043a36e()
FS3.exe 00651a96()
kernel32.dll 77e7eb69()
------------------------------------------------------------------
-
see if makeing a new pilot fixes this
-
Oh yeah afterburner trails... nice for a start! I'd likem to be a little longer maybe 1/4 more?
:cool:
-
I'm working on makeing them a lot more customisable, in my next build you will be able to define the values for the bitmap, relitive width, starting alpha, and life, on a ship by ship basis, I'm makeing the preleminary build now, after a bit of testing I'll make a clean build and I'll update the EXE post the code changes.
-
ok in the new tables it's gona look like this
$Trails:
+Bitmap: name of bitmap
+Width: relitive width of trail
+Alpha: starting alpha
+Life: life time in seconds
inside the after burner section
so for example
$Afterburner: YES
+Aburn Max Vel: 0.0, 0.0, 150.0
+Aburn For accel: 0.7
+Aburn Fuel: 300.0
+Aburn Burn Rate: 50.0
+Aburn Rec Rate: 25.0
$Trails:
+Bitmap: ABtrail
+Width: 1.0
+Alpha: 1.0
+Life: 15
is what the Ulysses' afterburner section is going to be
if you include the $Trails: string you are going to have to specify all four of the values, if the $Trails: string is missing that ship will not have any trails
-
any screenshots for us with no compiling program/no time?
-
well there is the executable (http://freespace.volitionwatch.com/blackwater/FS3.zip)
-
Pictures? I'm a picture kind of guy :)
-
Originally posted by Bobboau
see if makeing a new pilot fixes this
thats the problem it wont go to main screen or make new pilot.....
-
try renameing the data file so it rebuilds everything,
ok new code
this replaces the afterburner parsing in the parse_ship() finction in ship.cpp
// Get Afterburner information
// Be aware that if $Afterburner is not 1, the other Afterburner fields are not read in
required_string("$Afterburner:");
int has_afterburner;
stuff_boolean(&has_afterburner);
if ( has_afterburner == 1 ) {
sip->flags |= SIF_AFTERBURNER;
required_string("+Aburn Max Vel:");
stuff_vector(&sip->afterburner_max_vel);
required_string("+Aburn For accel:");
stuff_float(&sip->afterburner_forward_accel);
required_string("+Aburn Fuel:");
stuff_float(&sip->afterburner_fuel_capacity);
required_string("+Aburn Burn Rate:");
stuff_float(&sip->afterburner_burn_rate);
required_string("+Aburn Rec Rate:");
stuff_float(&sip->afterburner_recover_rate);
if(optional_string("$Trails:")){//optional values aplyed to ABtrails -Bobboau
char bitmap_name[MAX_FILENAME_LEN] = "";
required_string("+Bitmap:");
stuff_string(bitmap_name, F_NAME, NULL);
sip->ABbitmap = bm_load(bitmap_name);
required_string("+Width:");
stuff_float(&sip->ABwidth_factor);
required_string("+Alpha:");
stuff_float(&sip->ABAlpha_factor);
required_string("+Life:");
stuff_float(&sip->ABlife);
}else{
sip->ABbitmap = -1; //defalts for no ABtrails
sip->ABwidth_factor = 1.0f;
sip->ABAlpha_factor = 1.0f;
sip->ABlife = 5.0f;
}
} else {
sip->afterburner_max_vel.x = 0.0f;
sip->afterburner_max_vel.y = 0.0f;
sip->afterburner_max_vel.z = 0.0f;
sip->ABbitmap = -1; //defalts for no ABtrails
sip->ABwidth_factor = 1.0f;
sip->ABAlpha_factor = 1.0f;
sip->ABlife = 5.0f;
}
this replaces the code I said was going to be redone in ship_create()
trail_info *ci;
//first try at ABtrails -Bobboau
shipp->ab_count = 0;
//if(sip->flags & SIF_AFTERBURNER){
for(int h = 0; h < pm->n_thrusters; h++){
for(int j = 0; j < pm->thrusters->num_slots; j++){
// this means you've reached the max # of AB trails for a ship
Assert(sip->ct_count <= MAX_SHIP_CONTRAILS);
ci = &shipp->ab_info[shipp->ab_count++];
// ci = &sip->ct_info[sip->ct_count++];
ci->pt = pm->thrusters[h].pnt[j];//offset
ci->w_start = pm->thrusters[h].radius[j] * sip->ABwidth_factor;//width * table loaded width factor
ci->w_end = 0.05f;//end width
ci->a_start = 1.0f * sip->ABAlpha_factor;//start alpha * table loaded alpha factor
ci->a_end = 0.0f;//end alpha
ci->max_life = sip->ABlife;// table loaded max life
ci->stamp = 60; //spew time???
ci->bitmap = sip->ABbitmap; //table loaded bitmap used on this ships burner trails
}
}
//}//end AB trails -Bobboau
this is added the the ship_info structure
//optional ABtrail values
int ABbitmap; //the bitmap used
float ABwidth_factor; //a number that the width (set by the thruster glow width) will be multiplyed by
float ABAlpha_factor; //allows you to set how starting trasparency value
float ABlife; //how long the trails live for
the EXE (http://freespace.volitionwatch.com/blackwater/FS3.zip) has been updated
and here are some screens
(http://freespace.volitionwatch.com/blackwater/trails01.jpg)
(http://freespace.volitionwatch.com/blackwater/trails02.jpg)
(http://freespace.volitionwatch.com/blackwater/trails03.jpg)
(http://freespace.volitionwatch.com/blackwater/trails04.jpg)
(http://freespace.volitionwatch.com/blackwater/trails05.jpg)
(http://freespace.volitionwatch.com/blackwater/trails06.jpg)
(http://freespace.volitionwatch.com/blackwater/trails07.jpg)
(http://freespace.volitionwatch.com/blackwater/trails08.jpg)
(http://freespace.volitionwatch.com/blackwater/trails09.jpg)
(http://freespace.volitionwatch.com/blackwater/trails10.jpg)
-
Hey bobboau, could i get that targeting icon from you? ;)
-
Same here, that is a nice targeting icon. You ever thought about doing a HUD redesign?
-
oh, forgot about that, it doesn't work right, it's too big, I need to adjust the coordanants, but if you all want it I'll upload it when I get back home
-
Nice looking screens!
But...
-Can you make afterburner trails more transparent? They are a bit too visible in my opinion.
-Can anything be done to beam breaking? I mean the strange effect when you see small beams at distance, AAA and fighter beams for example. (http://freespace.volitionwatch.com/blackwater/trails03.jpg)
On another note... perhaps a better effect for trails would be more like smoke effect? Just a line coming out of thrusters seems strange...
-
Smoke effect...probably more of a visual thing with the trail PCX rather than the code itself. Looks like a neat thing....does it just go out the back all the time or is it activated by afterburners?
-
Right, but code defines how much room there is for visuality.
I don't know if it currently supports transparency and more fancy effects?
Activated by afterburners only.
-
Originally posted by Mr. Fury
Right, but code defines how much room there is for visuality.
I don't know if it currently supports transparency and more fancy effects?
Activated by afterburners only.
just look at the pics, they're transparent.
-
Wow, they're pretty cool...
I think that they would be better if they looks like the ones in the DVD version, similar to homeworld's ones.
Are trails generated by the engine alone or do they require POF modifications for every ship?
-
Originally posted by venom2506
just look at the pics, they're transparent.
OK, whatever. :p
-
Originally posted by Zarax
Wow, they're pretty cool...
I think that they would be better if they looks like the ones in the DVD version, similar to homeworld's ones.
Are trails generated by the engine alone or do they require POF modifications for every ship?
they're generated friom the glow, so I suppose they need no additional pof data?
-
Could someone take some pictures of the trails in the DVD version. Better yet, find the PCX files that generate them and help us out. We can replicate the effect no doubt.
-
Originally posted by IceFire
Could someone take some pictures of the trails in the DVD version. Better yet, find the PCX files that generate them and help us out. We can replicate the effect no doubt.
no thanx, the DVD ones are ugly from what I've seen.
-
Well at least show me a picture so I know what they look like...then we have grounds to improve. From the looks of it, I'd like to control the begining/ending width, begin/end alpha, and bitmap...just like on bombs.
-
you can specify on a ship by ship basis how tarnsparent they are to be at creation, they will grow more transparent untill they are totaly invisable as the trail section grows old
there is also table based controle on the relitive width (a number that the width it is multiplyed by) of the trail, by defalt they are set to be 1/2 the diameter of the glow they come from (so if you want realy thin ones you set +Width: to be .2 wich would make them .2 the radius of the thruster they come from)
I didn't set table controle over ending width (just set it to 0), but if you all realy want it I can add it fairly easily
bitmap is controlable on a ship by ship basis
-
that's so cool. so there is a new tbl entry, if I understand right?
-
Originally posted by Bobboau in the sixth post
ok in the new tables it's gona look like this
$Trails:
+Bitmap: name of bitmap
+Width: relitive width of trail
+Alpha: starting alpha
+Life: life time in seconds
inside the after burner section
so for example
$Afterburner: YES
+Aburn Max Vel: 0.0, 0.0, 150.0
+Aburn For accel: 0.7
+Aburn Fuel: 300.0
+Aburn Burn Rate: 50.0
+Aburn Rec Rate: 25.0
$Trails:
+Bitmap: ABtrail
+Width: 1.0
+Alpha: 1.0
+Life: 15
is what the Ulysses' afterburner section is going to be
if you include the $Trails: string you are going to have to specify all four of the values, if the $Trails: string is missing that ship will not have any trails [/B]
yes :nod:
-
you should do a shrink percent field so it tapers off the longer it stays active... same thing maybe with transparency
-
it shold be doing that (like it does with missle trails and nebula trails) though I can see it isn't, I think it has to do with how long there set to be
-
I've upped the maxamum trail segments, and it seems to improve the problem, I'm doing a few tweaks to this and other things (like trying to get the fighter beams to record player kills)
-
Originally posted by Bobboau
yes :nod:
lol sorry, didn't look at that, I thought that was code for the source :p
-
Originally posted by Bobboau
I've upped the maxamum trail segments, and it seems to improve the problem, I'm doing a few tweaks to this and other things (like trying to get the fighter beams to record player kills)
check if the narrowing doesn't happen only on the last segment
-
Originally posted by IceFire
Could someone take some pictures of the trails in the DVD version. Better yet, find the PCX files that generate them and help us out. We can replicate the effect no doubt.
See here: http://www.geocities.com/ipw47/afterburner.html
-
Cool! We can do better...but that looks cool! They adjusted the thickness at beginning and end like bomb trails.
-
it seems that upping the trail segments fixed it, I'd upload the changed version but I've already started on my next thing, refineing the fighter beams, things like the warm up\down ect... and I'm not at home right now