Forum

"fancy" particles

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

"fancy" particles

Postby MeTcHsteekle » Mon Feb 16, 2009 12:31 am

how do u make the original particles and somewhat enhance them like this : http://qer.planetquake.gamespy.com/scre ... icles4.jpg

just not as wacked out |:/
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Postby revelator » Mon Feb 16, 2009 3:41 am

if i remember correctly it could be done by modifying the hardcoded dot sizes

Code: Select all
//this part ->
byte   dottexture[8][8] =
{
   {0,1,1,0,0,0,0,0},
   {1,1,1,1,0,0,0,0},
   {1,1,1,1,0,0,0,0},
   {0,1,1,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0},
};
//end
void R_InitParticleTexture (void)
{
   int      x,y;
   byte   data[8][8][4];

   //
   // particle texture
   //
   particletexture = texture_extension_number++;
    GL_Bind(particletexture);
//and here
   for (x=0 ; x<8 ; x++)
   {
      for (y=0 ; y<8 ; y++)
      {
         data[y][x][0] = 255;
         data[y][x][1] = 255;
         data[y][x][2] = 255;
         data[y][x][3] = dottexture[x][y]*255;
      }
   }
//end
   glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

   particletexture_blood = EasyTgaLoad("textures/particles/blood.tga");
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
   particletexture_dirblood = EasyTgaLoad("textures/particles/blood2.tga");
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
}
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Postby metlslime » Mon Feb 16, 2009 8:33 am

looks like the particle texture is unchanged in that screenshot -- it's just that they all have like .5 alpha or something.

so just replace the glColor3f (x, y, z) with a glColor4f (x, y, z, 0.5)
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby Electro » Mon Feb 16, 2009 11:14 am

Those are considered fancy, really??
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby MeTcHsteekle » Mon Feb 16, 2009 1:56 pm

Electro wrote:Those are considered fancy, really??


...eh fancy enough :?

anyways thanks, ill see what i can break :O
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Postby MDave » Mon Feb 16, 2009 3:22 pm

It would be nice to make them fade over the course of its lifetime, like in quake 2. :wink:
User avatar
MDave
 
Posts: 76
Joined: Mon Dec 17, 2007 7:08 pm

Postby mh » Mon Feb 16, 2009 5:17 pm

That's straightforward enough, just deduct some multiple of frametime from alpha during each update (each particle should of course have it's own alpha stored in the particle_t struct to enable this).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby MeTcHsteekle » Mon Feb 16, 2009 5:45 pm

metlslime wrote:so just replace the glColor3f (x, y, z) with a glColor4f (x, y, z, 0.5)


i cant find this part :?
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Postby metlslime » Mon Feb 16, 2009 11:15 pm

oh, i guess the line is actually:

Code: Select all
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);


It takes a pointer to an array of bytes, so it might be easier to replace it with:

Code: Select all
glColor4ub((byte *)&d_8to24table[(int)p->color],
           (byte *)&d_8to24table[(int)p->color] + 1,
           (byte *)&d_8to24table[(int)p->color] + 2,
           128);


replace the 128 with whatever alpha value you want, from 0-255
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby MeTcHsteekle » Mon Feb 16, 2009 11:41 pm

metlslime wrote:oh, i guess the line is actually:

Code: Select all
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);


It takes a pointer to an array of bytes, so it might be easier to replace it with:

Code: Select all
glColor4ub((byte *)&d_8to24table[(int)p->color],
           (byte *)&d_8to24table[(int)p->color] + 1,
           (byte *)&d_8to24table[(int)p->color] + 2,
           128);


replace the 128 with whatever alpha value you want, from 0-255


cool it worked :D

but the particles have lost their colouring, and i got 9 warnings
    --------------------Configuration: winquake - Win32 GL Release--------------------
    Compiling...
    r_part.c
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(676) : warning C4047: 'function' : 'unsigned char ' differs in levels of indirection from 'unsigned char *'
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(676) : warning C4024: 'glColor4ub' : different types for formal and actual parameter 1
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(677) : warning C4047: 'function' : 'unsigned char ' differs in levels of indirection from 'unsigned char *'
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(677) : warning C4024: 'glColor4ub' : different types for formal and actual parameter 2
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(678) : warning C4047: 'function' : 'unsigned char ' differs in levels of indirection from 'unsigned char *'
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(678) : warning C4024: 'glColor4ub' : different types for formal and actual parameter 3
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(679) : warning C4761: integral size mismatch in argument; conversion supplied
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(679) : warning C4761: integral size mismatch in argument; conversion supplied
    C:\Users\alex\Desktop\quake\src\proquake\r_part.c(679) : warning C4761: integral size mismatch in argument; conversion supplied
    Linking...

    glprotest.exe - 0 error(s), 9 warning(s)


im sorry if im being a bother because im still new to this, i mean, i just figured out how to make the particles square in reckless'es matrix he posted
ill still look into what i can atm :o

edit: ouch, i tried adding a "v" to "glColor4ub" and i crashed the engine
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Postby mh » Tue Feb 17, 2009 1:13 am

Try this:

Top of R_DrawParticles, declare:
Code: Select all
byte *pcolor;


Instead of the glColor3ub, use:
Code: Select all
pcolor = (byte *) &d_8to24table[(int) p->color];
glColor4ub (pcolor[0], pcolor[1], pcolor[2], 128);


Breaks things up a little, and will be slower (but not that anyone would notice :D ), but it's easier to read/debug/etc for when you're starting out.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby metlslime » Tue Feb 17, 2009 2:02 am

oops... i didn't derefence that pointer... should be:

Code: Select all
glColor4ub(*(byte *)&d_8to24table[(int)p->color],
           *(byte *)&d_8to24table[(int)p->color] + 1,
           *(byte *)&d_8to24table[(int)p->color] + 2,
           128);


but yeah, mh's code is less messy, maybe just use that instead.
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby MeTcHsteekle » Tue Feb 17, 2009 2:07 am

thanks, didn't realize there is so many different ways to do different tasks...now i understand why engines take so long to update :O

hmm could i make a cvar for the transparency like :
Code: Select all
pcolor = (byte *) &d_8to24table[(int) p->color];
glColor4ub (pcolor[0], pcolor[1], pcolor[2], parttrans.value);


and then :
Code: Select all
cvar_t   parttrans = {"parttrans", "150", true};  //partical transparancy value...save to conf.


does that look right, and would i put it at the top of r_part.c?
should i make it gl_parttrans or r_parttrans...hmm GL or render

eh?

EDIT:
C:\Users\alex\Desktop\quake\src\proquake\r_part.c(680) : warning C4761: integral size mismatch in argument; conversion supplied

DAMN YOU WARNING!!!!!!!!!!!!!!!!!!!![aka does not compute]

EDITEDIT: BUT IT WORKS!!!!!!! WAHAHAHAHAHAHAHAHAHAHAHAHAH ...... I DESERVE A SASH http://www.newgrounds.com/portal/viewer ... kxNg%3D%3D
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Postby mh » Tue Feb 17, 2009 9:58 am

Cvar values are stored as floats, so try (int) parttrans.value as your alpha input.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby MeTcHsteekle » Tue Feb 17, 2009 1:42 pm

well, i tried that and still got the same warning [??]
perhaps i shouldn't fix something that's not broken [yet,it might break]. my next question would be how to make them effected by the lights in the map but, it sounds like it might be a lot of work for such a little effect.
so anyways, where should i look to make the particles lives longer, so they linger for a few more seconds? im guessing its still in r_part.c

........well i figured out how to make there lives shorter, now to reverse [heh]

.................got it, in r_part.c under R_DrawParticles
Code: Select all
   frametime = cl.time - cl.oldtime;
   time3 = frametime * 10;//15
   time2 = frametime * 2.2; // 15//10;   //i think i messed up the div. equally
   time1 = frametime * 1.1;//5
   grav = frametime * sv_gravity.value * 0.005; //ligers where it lives
   dvel = 4*frametime;
bah
MeTcHsteekle
 
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest