Author Topic: beam texture tileing  (Read 7878 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
beam texture tileing
make this you're new beam rendering function

Code: [Select]

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; // beam tileing, might make a tileing factor in beam index later -Bobboau
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);
}



still needs a bit of tweaking, but it's basicly there
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 WMCoolmon

  • Purveyor of space crack
  • 213
Any screenshots of this in action? :D
-C

 

Offline LAM3O

  • 25
Great job!   I didn't think there would be this much progress for a long time.

Can't wait to see shots, think it'll work with fighter beams?

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
it works on the fighter beam, actualy that's the only beam I've tested it on, but the rendering function is the same for all beams, I'll see about makeing some screens
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
also it looks like it will be relitivly easy to get that texture panning idea implemented
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

 
Wait, does this mean we can make like, beams which that look like arcing electricity easily?

 

Offline Hudzy

  • Apollo Pilot
  • 28
Great if it does. :nod:

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
this should make my happy spiral beams alot cooler. any thoughts on implementing a particle effect along with beams so that you see particles flying down the length of the beam. this would also make a good special effect for missiles and prety much everything else in the game.
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 Inquisitor

Sticking this so we get it added...
No signature.

  

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Commited :nod:
-C

 

Offline Inquisitor

excellent :)
No signature.

 

Offline Raven2001

  • Machina Terra Reborn
  • 211
  • Im not the droid your looking for, move along
Make an .exe of this, along with the fighter beams... :)
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 Inquisitor

Yes, probably around the 1st of August ;)
No signature.

 

Offline Raven2001

  • Machina Terra Reborn
  • 211
  • Im not the droid your looking for, move along
Ok, now I'm happier!! :D

BTW, Inquisitor could you explain me that CVS thingy and how do I access it??
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 Inquisitor

No signature.

 

Offline Raven2001

  • Machina Terra Reborn
  • 211
  • Im not the droid your looking for, move along
Thanks :)
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.

 
Just saw the new beams in action then - reminds me a lot of the beams in Homeworld. While the jagged saw effect is pretty cool, it is possible to make the beams look like true FS beams again isn't it?

 

Offline Bobboau

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

How is this going?
No signature.

 

Offline Nico

  • Venom
    Parlez-vous Model Magician?
  • 212
also, what about screenshots? ;)
SCREW CANON!