[Feature Request]Ooh
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
[Feature Request]Ooh
Someone tell me how to make particles use additive blending
- Attachments
-
- DOOM0004.png (104.86 KiB) Viewed 499 times
Last edited by Chilvence on Tue Jan 04, 2005 12:21 pm, edited 1 time in total.
- Cutmanmike
- Posts: 11336
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Well, I could make it do so, but I thought it looked better if it flashed instantly and then disappeared. Give me 10 minutes and I'll attach the effect to the chaingun....Chris wrote:Ditto. Does it actually flash and fade away without falling/rising?
Also, theres the unfortunate fact that it eats many many particles, probably more than the railgun, which you can only get a few simultaneous shots off without them starting to dissappear
- Cutmanmike
- Posts: 11336
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
- Cutmanmike
- Posts: 11336
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
If you could spawn them in ACS, then yeah I suppose. You'd need to do some math though to work out your effect, this one uses lots of vectors. LOTS of vectors, In fact, I just noticed I mixed up two in the above exe.
Code: Select all
void P_ConnectLightning (vec3_t start, vec3_t end)
{
float length;
int steps, i;
vec3_t step, dir, pos;
VectorSubtract (end, start, dir);
length = VectorLength (dir);
steps = (int)(length);
if (length){length = 1 / length;}else{return;}
VectorScale2 (dir, length);
VectorScale (dir, 1, step);
VectorCopy (start, pos);
int div = 128-M_Random()*2000;
for (i = steps; i; i--)
{
particle_t *p = LightningParticle (2);
if (!p)
return;
p->size = 6;
p->x = FLOAT2FIXED(pos[0]);
p->y = FLOAT2FIXED(pos[1]);
p->z = FLOAT2FIXED(pos[2]);
p->color = 168;
/*
we'll leave out the halo effect for now...
particle_t *h = LightningParticle (10);
if (!h)
return;
h->size = 13;
h->x = FLOAT2FIXED(pos[0]);
h->y = FLOAT2FIXED(pos[1]);
h->z = FLOAT2FIXED(pos[2]);
h->color = 162;
h->trans = 128;*/
VectorAdd (pos, step, pos);
}
}
void P_DrawLightning (vec3_t start, vec3_t end)
{
float length;
int steps, i;
vec3_t step, dir, pos;
VectorSubtract (end, start, dir);
length = VectorLength (dir);
steps = (int)(length);
if (length){length = 1 / length;}else{return;}
vec3_t linepos; //where the real hitscan trace would be
vec3_t linestep; //step to follow the imaginary hitscan line
vec3_t kludge; //used for measuring the distance between the current arc and the line
vec3_t connect; //point from which to connect one arc to the next
VectorScale2 (dir, length);
VectorScale (dir, 1, step);
VectorCopy (start, pos);
VectorCopy (start, linepos);
VectorCopy (start, connect);
VectorCopy (step, linestep);
VectorScale2 (step, 0.2f); //shorten the ligtning arcs a little bit...
//arc amount, x, y, and z
//I am assuming M_Random gives a number between 0 and 255, I hope this is correct)
int ax = 128-M_Random();
int ay = 128-M_Random();
int az = 128-M_Random();
for (i = steps; i; i--)
{
VectorSubtract (pos, linepos, kludge);
if( VectorLength (kludge) > 30) //if the lightning deviates too far
{
//draw a line between the last closest position of the lightning to the hitscan line
//and the new arc start position(which is the hitscan line itself)
P_ConnectLightning(connect, linepos);
//...
VectorCopy(linepos, pos); // then reset the lightning trail to the hitscan line
VectorCopy(linestep, step);
}
else if(VectorLength (kludge) < 12 ) //when the arc deviates more than 12 units, save this position
{
VectorCopy(pos, connect);
}
particle_t *p = LightningParticle (2);
if (!p)
return;
p->size = 6;
p->x = FLOAT2FIXED(pos[0]);
p->y = FLOAT2FIXED(pos[1]);
p->z = FLOAT2FIXED(pos[2]);
p->color = 168;
/*
we'll leave out the halo effect for now...
particle_t *h = LightningParticle (10);
if (!h)
return;
h->size = 13;
h->x = FLOAT2FIXED(pos[0]);
h->y = FLOAT2FIXED(pos[1]);
h->z = FLOAT2FIXED(pos[2]);
h->color = 162;
h->trans = 128;*/
//direction change: in effect this just generates a random vector and adds it to the arc line
//this can potentially compress or extend the arc, but ultimately it doesnt matter since the
//connector joins the arcs together, and we get free forks as a side effect without even
//needing to calculate them
if (M_Random() < 200)//add some randomness to the direction change
{
ax = (M_Random()-128)*50;
ay = (M_Random()-128)*50;
az = (M_Random()-128)*50;
}
float tempx = FIXED2FLOAT(ax);
float tempy = FIXED2FLOAT(ay);
float tempz = FIXED2FLOAT(az);
step[0] += tempx;
step[1] += tempy;
step[2] += tempz;
VectorAdd (pos, step, pos);
VectorAdd (linepos, linestep, linepos);
}
}
- Cutmanmike
- Posts: 11336
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Well, it is really, its just the nature of the language that makes it look complicated. It takes the point of origin, adds a tiny random vector change, spawns a single particle, then repeats until it reaches the end. If the random vector arcs too far away from the actual hitscan line, then it snaps back and starts randomising again. Now the railgun effect, THATS complicated. What I've done is pathetic compared to that...
- Cutmanmike
- Posts: 11336
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact: