I have made parseing code for this stuff
// beam sections
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]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;
}[/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;
}
}
parse_weapon
weapons.cpp
line ~ 1230
for some odd reason though it seems to damage the code that displays the weapon names in the hud
also I have been working on the tileing code
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
float U_offset; // beam texture offset -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
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 = ((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);
}
that code will work, but I've been unable to get the translation to work,
will someone more knowlegable tell me why this code 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);