Author Topic: beam texture tileing  (Read 7918 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
:eek2: I can't beleve I didn't see that
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
yeah it should be 0,1,2,3
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
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
Code: [Select]

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
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what the hell, here's the new rendering function
Code: [Select]

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

Code: [Select]
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
Code: [Select]

#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;
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
will someone tell me why my parseing code isn't working, please
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Anaz

  • 210
make sure that your loading the tileing properly...
Arrr. I'm a pirate.

AotD, DatDB, TVWP, LM. Ph34r.

You WILL go to warpstorm...

 

Offline penguin

  • Eudyptes codus
  • 28
  • Still alive.
Quote
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 :(
your source code slave