Author Topic: beam texture tileing  (Read 6421 times)

0 Members and 1 Guest are viewing this topic.

Offline WMCoolmon

  • Purveyor of space crack
  • 213
-C

 

Offline an0n

  • Banned again
  • 211
  • Emo Hunter
    • http://nodewar.penguinbomb.com/forum
Oooooooooh. Railguns!
"I.....don't.....CARE!!!!!" ---- an0n
"an0n's right. He's crazy, an asshole, not to be trusted, rarely to be taken seriously, and never to be allowed near your mother. But, he's got a knack for being right. In the worst possible way he can find." ---- Yuppygoat
~-=~!@!~=-~ : Nodewar.com

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Quote
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.
« Last Edit: August 03, 2002, 05:08:48 pm by 448 »
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline Nico

  • Venom
    Parlez-vous Model Magician?
  • 212
stupid question number 132134: would it be possible to have a different map for the ends of the beams? Guess not, but anyway?
SCREW CANON!

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
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)
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
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 ??
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 LAM3O

  • 25
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.

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Quote
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. :)
« Last Edit: August 04, 2002, 05:42:01 am by 448 »
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline Nico

  • Venom
    Parlez-vous Model Magician?
  • 212
yeah, what lam3o says, about. for exemple to have a  beam with "round" ends for exemples, stuff like that.
SCREW CANON!

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
[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
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
working on it, if you read the thread, you'' see I am going to make this an optional tag in the beam section stuff,
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 Nico

  • Venom
    Parlez-vous Model Magician?
  • 212
Quote
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 :)
SCREW CANON!

 

Offline Fry_Day

  • 28
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.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
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.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
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...
-C

 

Offline Raven2001

  • Machina Terra Reborn
  • 211
  • Im not the droid your looking for, move along
I like the way old beams looks :) I just wish they could be "animated" (really noticing them "flowing", if you know what I mean...)
Yeah, I know you were waiting for a very nice sig, in which I was quoting some very famous scientist or philosopher... guess what?!? I wont indulge you...

Why, you ask? What, do I look like a Shivan to you?!?


Raven is a god.

 

Offline Bobboau

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

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);
}


Code: [Select]

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

float tile_factor; // texture tile factor -Bobboau
float translation; // makes the beam texture move -Bobboau

to the beam_weapon_section_info struct
« Last Edit: August 07, 2002, 03:05:00 am by 57 »
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
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
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
can someone tell me why this causes a crash
Code: [Select]

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);
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 penguin

  • Eudyptes codus
  • 28
  • Still alive.
Quote
Originally posted by Bobboau
can someone tell me why this causes a crash
 

Unless you changed it, verts is declared:
Code: [Select]

vertex *verts[4]

so the subscripts should be 0-3

You're accessing verts[4], and then trying to dereference == crasharoo
your source code slave