Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Bobboau on July 25, 2002, 12:15:33 am
-
make this you're new beam rendering function
void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink)
{
int idx, s_idx;
vertex h1[4]; // halves of a beam section
vertex *verts[4] = { &h1[0], &h1[1], &h1[2], &h1[3] };
vector fvec, top1, bottom1, top2, bottom2;
float scale;
float u_scale; // beam tileing -Bobboau
float length; // beam tileing -Bobboau
// bogus weapon info index
if(bwi == NULL){
return;
}
// if the beam start and endpoints are the same
if(vm_vec_same(start, shot)){
return;
}
// get beam direction
vm_vec_sub(&fvec, shot, start);
vm_vec_normalize_quick(&fvec);
// turn off backface culling
gr_set_cull(0);
// draw all sections
for(s_idx=0; s_idxbeam_num_sections; s_idx++){
// calculate the beam points
scale = frand_range(1.0f - bwi->sections[s_idx].flicker, 1.0f + bwi->sections[s_idx].flicker);
beam_calc_facing_pts(&top1, &bottom1, &fvec, start, bwi->sections[s_idx].width * scale * shrink, bwi->sections[s_idx].z_add);
beam_calc_facing_pts(&top2, &bottom2, &fvec, shot, bwi->sections[s_idx].width * scale * scale * shrink, bwi->sections[s_idx].z_add);
R_VERTICES(); // rotate and project the vertices
P_VERTICES();
STUFF_VERTICES(); // stuff the beam with creamy goodness (texture coords)
length = vm_vec_dist(start, shot); // beam tileing -Bobboau
u_scale = length / bwi->sections[s_idx].width /2; // beam tileing, might make a tileing factor in beam index later -Bobboau
verts[1]->u = verts[1]->u * u_scale; // beam tileing -Bobboau
verts[2]->u = verts[2]->u * u_scale; // beam tileing -Bobboau
// set the right texture with additive alpha, and draw the poly
gr_set_bitmap(bwi->sections[s_idx].texture, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f);
g3_draw_poly( 4, verts, TMAP_FLAG_TEXTURED | TMAP_FLAG_TILED | TMAP_FLAG_CORRECT); // added TMAP_FLAG_TILED flag for beam texture tileing -Bobboau
}
// turn backface culling back on
gr_set_cull(1);
}
still needs a bit of tweaking, but it's basicly there
-
Any screenshots of this in action? :D
-
Great job! I didn't think there would be this much progress for a long time.
Can't wait to see shots, think it'll work with fighter beams?
-
it works on the fighter beam, actualy that's the only beam I've tested it on, but the rendering function is the same for all beams, I'll see about makeing some screens
-
also it looks like it will be relitivly easy to get that texture panning idea implemented
-
Wait, does this mean we can make like, beams which that look like arcing electricity easily?
-
Great if it does. :nod:
-
this should make my happy spiral beams alot cooler. any thoughts on implementing a particle effect along with beams so that you see particles flying down the length of the beam. this would also make a good special effect for missiles and prety much everything else in the game.
-
Sticking this so we get it added...
-
Commited :nod:
-
excellent :)
-
Make an .exe of this, along with the fighter beams... :)
-
Yes, probably around the 1st of August ;)
-
Ok, now I'm happier!! :D
BTW, Inquisitor could you explain me that CVS thingy and how do I access it??
-
Yeah:
http://www.3dap.com/hlp/hosted/fsscp/
and a preconfigured CVS batch is:
http://fs2source.warpcore.org/CVS.zip
-
Thanks :)
-
Just saw the new beams in action then - reminds me a lot of the beams in Homeworld. While the jagged saw effect is pretty cool, it is possible to make the beams look like true FS beams again isn't it?
-
I have set a tileing factor, I am going to set it up so that, positive numbers are relitive (to the beam liength) and negitive are absolute (total number of times tiled acros the beam), also remember I am trying to get this set up to translate the texture down the beam
-
How is this going?
-
also, what about screenshots? ;)
-
(http://members.cox.net/~wmcoolmon/images/beam.jpg)
-
Oooooooooh. Railguns!
-
Originally posted by Bobboau
I have set a tileing factor, I am going to set it up so that, positive numbers are relitive (to the beam liength) and negitive are absolute (total number of times tiled acros the beam), also remember I am trying to get this set up to translate the texture down the beam
So a beam tiling factor of +1 will draw the beams the way they were in the original, right? Perhaps that should be the default value, and if the parser doesn't find a beam tiling factor listed in the table entry, it should use that value.
-
stupid question number 132134: would it be possible to have a different map for the ends of the beams? Guess not, but anyway?
-
oh, kina forgot about this, I got a tileing factor set up and I was working of getting it to move, I needed to make a time based offset (as oposed to moveing the offset every frame on a beam by beam basis), or it won't work on fighter beams
U_offset = (float)( (float)(timestamp()%1000) * bwi->sections->translation)/1000.0f;
this is one of the places my ineptitude in C is biteing me
I tried several diferent things, this is what it looks like now
basicly I'm trying to get a floating point value between 0.0 and 1.0 based on the current time and the translaton rate for the beam
I don't supose there is something way to modulo that works on floating point values, I got some sort of error when I tryed something like
(timestamp() * bwi->sections->translation)%1.0f
it's been about a week sense I did this so I can't recall exactly what I did (other than screwing up something in the HUD :D)
-
the way I am setting up the tile factor 1 would be like it is now (my altered exe) bigger numbers would streach it out more, I am going to set it up so negitive numbers will be the absolute tile factor, so -1 would make it like the old rendering code -5 would tile it 5 times along the beam length, how ever far that would be
and what do you mean have a different map for the ends ??
-
wow that's great!
About the ends, say you had a lighting bolt texture, the last tile could be extra fragmented, looking like it's flailing more wildly at the end, i guess.
Who cares though, this is a great mod, it'll really change the way the game looks.
-
Originally posted by Bobboau
the way I am setting up the tile factor 1 would be like it is now (my altered exe) bigger numbers would streach it out more, I am going to set it up so negitive numbers will be the absolute tile factor, so -1 would make it like the old rendering code -5 would tile it 5 times along the beam length, how ever far that would be
Oh, I see. I took "absolute" to refer to the tile width being absolute, as in the beam would be drawn by repeating the tiles however many times were necessary to reach the target. You meant that the number of tiles was absolute. Gotcha.
Btw, you might want to make that explicit in your documentation, just to avoid all possibility for confusion. :)
-
yeah, what lam3o says, about. for exemple to have a beam with "round" ends for exemples, stuff like that.
-
[not claiming to have read thread, so if this has already been stated, slap me]
you need to make tiled beam textures a weapon flag - so the origional beams maintain their appearance, and only beams that we wwant tiled tile
and does the texture traverse the beam? ie if you made it have "pulse bulges" would they travel down the beam
-
working on it, if you read the thread, you'' see I am going to make this an optional tag in the beam section stuff,
-
Originally posted by Kazan
slap me
here you go:
"slaps kazan".
Anyway, I'm looking forward to that "animated" beam bob, could improve many beam ideas :)
-
Just a small note to Bobbau, look at the math.h functions, and there is a floating-point mod function, but it's slow, so try avoiding it.
-
i dont think compatibility with older beams is an issue, most of the original beam textures are very low resolution, and you cant tell one colom of pixels from another.
-
But there is a very obvious difference between the original beams and the new beams, as is shown in the screenshot. Slash beams probably won't look right, anyway...
-
I like the way old beams looks :) I just wish they could be "animated" (really noticing them "flowing", if you know what I mean...)
-
*Bobboau pulls head out of his ass*
I'm such an idiot, I was only adding the U offset to the far verts, no wonder it wasn't working
ok let's try this
float U_offset =0; // beam translation thing -Bobboau
void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink)
{
int idx, s_idx;
vertex h1[4]; // halves of a beam section
vertex *verts[4] = { &h1[0], &h1[1], &h1[2], &h1[3] };
vector fvec, top1, bottom1, top2, bottom2;
float scale;
float u_scale; // beam tileing -Bobboau
float length; // beam tileing -Bobboau
// bogus weapon info index
if(bwi == NULL){
return;
}
// if the beam start and endpoints are the same
if(vm_vec_same(start, shot)){
return;
}
// get beam direction
vm_vec_sub(&fvec, shot, start);
vm_vec_normalize_quick(&fvec);
// turn off backface culling
gr_set_cull(0);
// draw all sections
for(s_idx=0; s_idxbeam_num_sections; s_idx++){
// calculate the beam points
scale = frand_range(1.0f - bwi->sections[s_idx].flicker, 1.0f + bwi->sections[s_idx].flicker);
beam_calc_facing_pts(&top1, &bottom1, &fvec, start, bwi->sections[s_idx].width * scale * shrink, bwi->sections[s_idx].z_add);
beam_calc_facing_pts(&top2, &bottom2, &fvec, shot, bwi->sections[s_idx].width * scale * scale * shrink, bwi->sections[s_idx].z_add);
R_VERTICES(); // rotate and project the vertices
P_VERTICES();
STUFF_VERTICES(); // stuff the beam with creamy goodness (texture coords)
length = vm_vec_dist(start, shot); // beam tileing -Bobboau
u_scale = length / (bwi->sections[s_idx].width /2) / bwi->sections[s_idx].tile_factor; // beam tileing, might make a tileing factor in beam index later -Bobboau
U_offset = U_offset + flFrametime; //beam texture translation -Bobboau
if (U_offset > 1.0f){
U_offset -= 1.0f;
}
verts[1]->u = (verts[1]->u * u_scale) + (U_offset * bwi->sections[s_idx].translation); // beam tileing/translation -Bobboau
verts[2]->u = (verts[2]->u * u_scale) + (U_offset * bwi->sections[s_idx].translation); // beam tileing/translation -Bobboau
verts[3]->u = verts[3]->u + (U_offset * bwi->sections[s_idx].translation); //beam translation
verts[4]->u = verts[4]->u + (U_offset * bwi->sections[s_idx].translation); //beam translation
// set the right texture with additive alpha, and draw the poly
gr_set_bitmap(bwi->sections[s_idx].texture, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f);
g3_draw_poly( 4, verts, TMAP_FLAG_TEXTURED | TMAP_FLAG_TILED | TMAP_FLAG_CORRECT); // added TMAP_FLAG_TILED flag for beam texture tileing -Bobboau
}
// turn backface culling back on
gr_set_cull(1);
}
if( optional_string("+Tile Factor:")){ //beam texture tileing factor -Bobboau
stuff_float(&i.tile_factor);
}else{
i.tile_factor = 1.0f;
}
if( optional_string("+Translation:")){ //beam texture moveing stuff -Bobboau
stuff_float(&i.tile_factor);
}else{
i.translation = 0.0f;
}
in end of the beam sections loading code, in weapons .cpp
and of corse
add this
float tile_factor; // texture tile factor -Bobboau
float translation; // makes the beam texture move -Bobboau
to the beam_weapon_section_info struct
-
that doesn't seem to work, I realy should test stuff before I post it, and not code when I'm so tired I can barly see
-
can someone tell me why this causes a crash
U_offset = 0.0f;
verts[1]->u = ((verts[1]->u * u_scale) + U_offset); // beam tileing -Bobboau
verts[2]->u = ((verts[2]->u * u_scale) + U_offset); // beam tileing -Bobboau
verts[3]->u = (verts[3]->u + U_offset);
verts[3]->u = (verts[4]->u + U_offset);
-
Originally posted by Bobboau
can someone tell me why this causes a crash
Unless you changed it, verts is declared:
vertex *verts[4]
so the subscripts should be 0-3
You're accessing verts[4], and then trying to dereference == crasharoo
-
:eek2: I can't beleve I didn't see that
-
yeah it should be 0,1,2,3
-
ok I'm almost done with this, I just need to know why this(changes in bold) screws up the displaying of weapons in the HUD
from the bottom end of parse_weapon, in weapons.cpp
while( optional_string("$Section:") ){
beam_weapon_section_info i;
char tex_name[255] = "";
// section width
required_string("+Width:");
stuff_float(&i.width);
// texture
required_string("+Texture:");
stuff_string(tex_name, F_NAME, NULL);
i.texture = -1;
if(!Fred_running){
i.texture = bm_load(tex_name);
if(i.texture >= 0){
bm_lock(i.texture, 16, BMP_TEX_OTHER);
bm_unlock(i.texture);
}
}
// rgba inner
required_string("+RGBA Inner:");
stuff_byte(&i.rgba_inner[0]);
stuff_byte(&i.rgba_inner[1]);
stuff_byte(&i.rgba_inner[2]);
stuff_byte(&i.rgba_inner[3]);
// rgba outer
required_string("+RGBA Outer:");
stuff_byte(&i.rgba_outer[0]);
stuff_byte(&i.rgba_outer[1]);
stuff_byte(&i.rgba_outer[2]);
stuff_byte(&i.rgba_outer[3]);
// flicker
required_string("+Flicker:");
stuff_float(&i.flicker);
// zadd
required_string("+Zadd:");
stuff_float(&i.z_add);
[b]i.tile_factor = -1.0f;
if( optional_string("+Tile Factor:")){ //beam texture tileing factor -Bobboau
stuff_float(&(i.tile_factor));
}
i.translation = 0.0f;
if( optional_string("+Translation:")){ //beam texture moveing stuff -Bobboau
stuff_float(&(i.translation));
}[/b]
// maybe copy it
if(wip->b_info.beam_num_sections < MAX_BEAM_SECTIONS - 1){
wip->b_info.sections[wip->b_info.beam_num_sections++] = i;
}
}
yes I made changes to the beam section structure
-
what the hell, here's the new rendering function
float U_offset =0.0f; // beam texture offset -Bobboau
void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink)
{
int idx, s_idx;
vertex h1[4]; // halves of a beam section
vertex *verts[4] = { &h1[0], &h1[1], &h1[2], &h1[3] };
vector fvec, top1, bottom1, top2, bottom2;
float scale;
float u_scale; // beam tileing -Bobboau
float length; // beam tileing -Bobboau
// bogus weapon info index
if(bwi == NULL){
return;
}
// if the beam start and endpoints are the same
if(vm_vec_same(start, shot)){
return;
}
// get beam direction
vm_vec_sub(&fvec, shot, start);
vm_vec_normalize_quick(&fvec);
// turn off backface culling
gr_set_cull(0);
// draw all sections
for(s_idx=0; s_idxbeam_num_sections; s_idx++){
// calculate the beam points
scale = frand_range(1.0f - bwi->sections[s_idx].flicker, 1.0f + bwi->sections[s_idx].flicker);
beam_calc_facing_pts(&top1, &bottom1, &fvec, start, bwi->sections[s_idx].width * scale * shrink, bwi->sections[s_idx].z_add);
beam_calc_facing_pts(&top2, &bottom2, &fvec, shot, bwi->sections[s_idx].width * scale * scale * shrink, bwi->sections[s_idx].z_add);
R_VERTICES(); // rotate and project the vertices
P_VERTICES();
STUFF_VERTICES(); // stuff the beam with creamy goodness (texture coords)
//U_offset = ( ( ((float)timestamp() * bwi->sections[s_idx].translation)/1000.0f) - (float)(timestamp() * (int)bwi->sections[s_idx].translation /1000));
length = vm_vec_dist(start, shot); // beam tileing -Bobboau
if (bwi->sections[s_idx].tile_factor){
u_scale = length / (bwi->sections[s_idx].width /2) / bwi->sections[s_idx].tile_factor; // beam tileing, might make a tileing factor in beam index later -Bobboau
}else{
u_scale = bwi->sections[s_idx].tile_factor * -1;
}
verts[1]->u = (u_scale + (U_offset * bwi->sections[s_idx].translation)); // beam tileing -Bobboau
verts[2]->u = (u_scale + (U_offset * bwi->sections[s_idx].translation)); // beam tileing -Bobboau
verts[3]->u = (0 + (U_offset * bwi->sections[s_idx].translation));
verts[0]->u = (0 + (U_offset * bwi->sections[s_idx].translation));
// set the right texture with additive alpha, and draw the poly
gr_set_bitmap(bwi->sections[s_idx].texture, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f);
g3_draw_poly( 4, verts, TMAP_FLAG_TEXTURED | TMAP_FLAG_TILED | TMAP_FLAG_CORRECT); // added TMAP_FLAG_TILED flag for beam texture tileing -Bobboau
}
// turn backface culling back on
gr_set_cull(1);
}
and jam this line
U_offset = ( (float)(timestamp()/1000) - ( ((float)timestamp())/1000.0f)); //beam texture offset, so it looks like it is moveing, -Bobboau
into beam_render_all
change made in weapons.h
#define MAX_BEAM_SECTIONS 10
typedef struct beam_weapon_section_info {
float width; // width of the section
int texture; // texture bitmap
ubyte rgba_inner[4]; // for non-textured beams
ubyte rgba_outer[4]; // for non-textured beams
float flicker; // how much it flickers (0.0 to 1.0)
float z_add; // is this necessary?
float tile_factor; // texture tile factor -Bobboau
float translation; // makes the beam texture move -Bobboau
} beam_weapon_section_info;
-
will someone tell me why my parseing code isn't working, please
-
make sure that your loading the tileing properly...
-
Originally posted by Bobboau
will someone tell me why my parseing code isn't working, please
I haven't played w/ the parsing code enough to provide a useful answer, sorry :(