*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