Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Nuke on May 07, 2008, 07:06:58 pm
-
i was thinking about redoing my lua based railgun particle trails (http://www.youtube.com/watch?v=YTlDH0QfYjE) in c, to improve its performance and make it easier to mod in. i always wanted more variety in my particle spewer so i thought of adding a type field to the entry and possibly a couple more parameters. since most of the parameters for my railgun effect are the same as the existing pspew entry ( see this post (http://www.hard-light.net/forums/index.php/topic,53679.msg1086075.html#msg1086075) ).
what i want to do is add a type field to the pspew parameters, its default will be the standard pspew effect as its implemented, and it can have other options like helical, star, ring, ect. this would add alot more variety to particles. i know how to do the helical effect so the rest would be fairly easy to do the others i mentioned.
most of these effects share similar parameters. so i think this is the best way to go about different particle spew types. id be willing to code this myself if you guys could point me in the right direction.
-
That'd be something nice to add. We've all been effectively shooting the same weapons for ten years or so...just with different and better colors. I'm always a supporter of new options for visual variety.
-
didnt i say that like several years ago?
-
If you did, it's still every bit as true now as it was back then.
-
none the less i need some input from coders, a crash course in how tables are parsed would be a good start.
-
optional_string returns if that string exists in the table. required_string kills the exe if the string isn't found (don't use it except for section names). stuff_* pulls the specified type from the tables and puts it in the specified buffer. Adding a field looks like:
if(optional_string("$Subsystem Factor:")) {
stuff_float(&wip->subsystem_factor);
}
Comments and whitespace are handled internally.
-
Also remember to add the new entry (or rather the variable) to the ship_info structure and also make sure you give it some value when tables are initialized.
-
optional_string returns if that string exists in the table. required_string kills the exe if the string isn't found (don't use it except for section names). stuff_* pulls the specified type from the tables and puts it in the specified buffer. Adding a field looks like:
if(optional_string("$Subsystem Factor:")) {
stuff_float(&wip->subsystem_factor);
}
Comments and whitespace are handled internally.
ok i saw something like that for pspew parameters in weapons.cpp. i figured id use optional_string. so is this
stuff_float(&wip->subsystem_factor);
the function that stores the variable? and i take it &wip->subsystem_factor is a reference to a structure element? im abit rusty in old skool c, and i never really got this far in that language. most ive done is quake c.
Also remember to add the new entry (or rather the variable) to the ship_info structure and also make sure you give it some value when tables are initialized.
ok, wouldnt have thought to look at ship_info for a weapon parameter, or would there also be a weapon_info struct?
-
lols... I wrote that when i was too tired and without reading the previous posts accurately enough... Yeah.. the weapon_info not ship_info
Basically you just need to add the new entry to struct weapon_info in weapon.h like for example using int to get the info which 'special particle type' is in use
int particle_spew_type;
Then add to the void init_weapon_entry in weapon.cpp the initial data like
wip->particle_spew_type = -1;
And then add the actual parsing stuff thing with the optional_string under the $Pspew: entry
if(optional_string("+Type:"))
{
stuff_int(&wip->particle_spew_type);
}
And then adding the rest of stuff (the floats etc needed for the additional types) as needed
-
looks pretty straight forward then. il update and try to code it up later tonight.
anyone know what the default pspew values are? im thinking about making everything optional (using the default value). oh never mind i found em :D
-
i think i got it to parse the new type field. the hard part is learning all of freespace's wierd ass math funcs. il finish the particle code tomorrow maybe.
-
:bump:
i sorta got my c implementation of the effect working. its an order of magnitude faster than the lua version. i can do a gapless trail without slowing down the engine! see the results:
(http://i213.photobucket.com/albums/cc103/Emperor_of_Nihil/screen0036.jpg)
(http://i213.photobucket.com/albums/cc103/Emperor_of_Nihil/screen0026.jpg)
-
looks like the d3 omega cannon
-
This looks great! Please go on :)
-
How bout a tail with gaps?
-
can be done by reducing the number of particles. right now none of the information in the table makes any since, like +count: seems to be backwards, as in lower numbers mean more particles. for sanity im gonna need to rethink some of the math so that the pspew properties make more sense to modders. but it shouldnt be that hard.
thin again this is supposed to be pspew types, thats one type, i need ideas for more spew patterns. il probably do some variations on the helix type, one with a counter rotating core perhaps. or a solid core, or a double helix. i might see about multiple spewers per weapon. add an offset value to the spawn origin. so you can do things like missiles with multiple particle trails.
-
How about spew'd groups or patterns?
Um.. star shaped... circles.. hexagonal...triangular...
-
could probibly do all those. just a matter of whether they would look good or not. also can do one that throws particles in all directions. sorta like what you have with some weapons in freelancer. to give them that sparkly energetic look.
-
I had a weird issue with a missile particle trail, it was creating fireworks-esque particle balls
the size of moons, and they'd follow the player's ship everywhere.
For the longest time thought it was my afterburners...
But just an idea...
Perhaps a sword of particles?
Let me know when you've got all the kinks out of the current version, I'd like to stick it in my mod now
that I've got most of the railgun worked out finally.
-
Perhaps a sword of particles?
Lightsabre.
-
Perhaps a sword of particles?
Lightsabre.
*Imagines lightsabre duel between Shivan and Terran Marine*
-
I had a weird issue with a missile particle trail, it was creating fireworks-esque particle balls
the size of moons, and they'd follow the player's ship everywhere.
For the longest time thought it was my afterburners...
But just an idea...
Perhaps a sword of particles?
Let me know when you've got all the kinks out of the current version, I'd like to stick it in my mod now
that I've got most of the railgun worked out finally.
sounds like you got scale and radius mixed up. really it always confused the **** out of me. radius is the size of the particle while scale is some factor used to determine how big the effect will spread to.
who all wants an offset vector so you can specify where the spew comes from.
was just gonna do it as a z offset but if i ever do multiple spewers (not that i know how atm), an x and y offset would be cool.
*thinks*
i guess for now il just do a z offset.
*thinks some more*
then again i could put a few offsets in there and just alternate between them each particle.
should i do that dynamically? does the engine do that for me?
how does it work for beam sections.
*looks at code*
static array
*thinks some more*
i can probibly do that
*brain explodes*
but not today
lol
-
Well thankfully I'm not the one who made the rocket's table data, and it was 3 years old.
I'm all for more controls... long as someone comments them out or tells the general population
what the heck they do in plain English.
You can make the world's greatest program, but it's useless if no one can utilize it. :nod:
-
well ive sorta changed my philosophy on how to do things. ive decided to make spew types as simple as possible, letting users define multiple particle spews per weapon. you may then build a stack of particle effects. for example your tach railgun needs two spirals, one big one small. so what you will do is set up a large spiral pspew and a smal spiral pspew. the effects overlap to make a more tach like spew.
so far ive really added only a few new tags to pspew. most of them can apply across the range of spew types. count will always be the number of particles spewed per frame, time will always be the delay between spawns, vel will always be the velocity inheritence factor, radius will always be the particle size, life will alwas be the duration, scale will always be how big the effect is (really in all types its a scaler for particle velocity). ive realy only added a few things that arent already defined. normal and offset should be pretty self explanitory, direction and location of the spew. rotation rate is only used for helix type and defines the speed of rotation (i think its in rotations per second so it makes more since than in the lua script). sparkler has a z scale which allows you to make an ovoid shape so you can surround a laser blob. other than that thers just the type string.
while most of the variables mean the same thing, how they effect the type depends on the type. like scale needs to be alot bigger using helix mode than in default. a vel of 1 looks good on a sparkler while a vel of 0.01 looks better on a helix. as a modder my new system makes alot of sense.
-
go get the build, do it now!
-
That sounds great, allowing for the definition of multiple spews could allow for a missile trail with one texture and having a particle "flame" effect closer to the missile.
-
do i have to spell it out for you
http://www.hard-light.net/forums/index.php/topic,60417.0.html
go play with the build :D
-
i updated the build check it out