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;