making particles collide and bounce in stock quake
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
making particles collide and bounce in stock quake
HI!!!!
i'm messing about the "QUACK ENEGN PROGRAMING" and I wanted to make particles not go THROUGH WALLS specifically on rocket particles.
and I also want to make rocket sparks bounce too!!
HOW DO THIS! I tried to steal the TOMAZ QUAKE CODE but its like a completely different particle system dependent on contents and so that doesn't really plug into winquake as well as i'd like
I DO NOT WANT TO REPLACE THE WHOLE PARTICLE SYSTEM!!!
also after this i plan to have a silly hack to 'decal' the particle to live 5x longer and flatten itself to the surface it touched. I dreamed of doing this in 2000 but never ever attempted this because I never got the former working. I would then go ape with blood particles that splatter all over the place and don't break sweats on entity counts because there are none. i'd have no idea to rasterize 'decal particles' in software, maybe by a oriented colored sprite block or so.
i'm messing about the "QUACK ENEGN PROGRAMING" and I wanted to make particles not go THROUGH WALLS specifically on rocket particles.
and I also want to make rocket sparks bounce too!!
HOW DO THIS! I tried to steal the TOMAZ QUAKE CODE but its like a completely different particle system dependent on contents and so that doesn't really plug into winquake as well as i'd like
I DO NOT WANT TO REPLACE THE WHOLE PARTICLE SYSTEM!!!
also after this i plan to have a silly hack to 'decal' the particle to live 5x longer and flatten itself to the surface it touched. I dreamed of doing this in 2000 but never ever attempted this because I never got the former working. I would then go ape with blood particles that splatter all over the place and don't break sweats on entity counts because there are none. i'd have no idea to rasterize 'decal particles' in software, maybe by a oriented colored sprite block or so.
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
Easiest way is probably to do a Mod_PointInLeaf (p->org, cl.worldmodel) for each particle, check the contents of the returned leaf, and if it's CONTENTS_SOLID assume that it's gone into a wall and set p->die = -1 and skip drawing it.
A crude way to make them bounce would then be to set p->vel[0] = -p->vel[0], and etc for [1] and [2] if it hit's solid.
Should be fine for any Quake, Win or GL, as the data required is available.
This won't work with brush model entities however, so particles will go through doors and plats. Also, a particle can still go through a wall if it moves fast enough (it would have to be really fast, and with a low framerate, though).
Better ways would be more computationally intensive.
A crude way to make them bounce would then be to set p->vel[0] = -p->vel[0], and etc for [1] and [2] if it hit's solid.
Should be fine for any Quake, Win or GL, as the data required is available.
This won't work with brush model entities however, so particles will go through doors and plats. Also, a particle can still go through a wall if it moves fast enough (it would have to be really fast, and with a low framerate, though).
Better ways would be more computationally intensive.
Last edited by mh on Thu Mar 19, 2009 4:46 pm, edited 1 time in total.
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
qboolean SV_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
so:
{
trace_t tr;
vec3_t endpos;
memset(&tr, 0, sizeof(tr));
tr.fraction = 1;
VectorMA(p->origin, frametime, p->vel, endpos);
VectorCopy(endpos, tr.endpos);
SV_RecursiveHullCheck(&cl.worldmodel->hulls[0], 0, 0, 1, p->origin, endpos, &tr);
VectorCopy(tr.endpos, p->origin);
if (tr.fraction != 1)
{
float f = DotProduct(vel*tr.plane_normal)*-2;//bounce like a super-bouncy ball.
VectorMA(p->vel, f, tr.plane_normal, p->vel);
}
}
Insert the above code instead of the following line:
VectorMA(p->origin, frametime, p->vel, p->origin);
Then it'll clip particles to the world.
notes:
sv_recursivehullcheck is a generic function provided inside the server code. the 0,0,1 parameters are needed due to its recursive nature, but should be set as above for starting at the top of the bsp tree.
the passed in trace_t structure needs to be pre-initialised. Really its only the values you want set if it should fail to hit anything. This being fraction, solidity, and endpos.
If the trace starts solid, endpos will not be changed. This means the particle will pass through solids still, but only if the trace started in a solid. This gives some protection against moving BSP objects.
hull 0 is the point-sized/infinity-small hull. The next smallest is too big.
It'll not clip to doors/moving plats/func_wall.
For that you'd need to iterate over the visentities list for bsp models, and pick whichever trace gave the smallest fractions.
CL_LinkEntities will give you hits here, but I'm not gonna discuss it in detail cos I don't remember the contents of that array or even the actual name of it.
The above code will probably not even compile. Certainly it'll have undeclared functions.
Regarding oriented decals... Which texture are you going to use? :)
so:
{
trace_t tr;
vec3_t endpos;
memset(&tr, 0, sizeof(tr));
tr.fraction = 1;
VectorMA(p->origin, frametime, p->vel, endpos);
VectorCopy(endpos, tr.endpos);
SV_RecursiveHullCheck(&cl.worldmodel->hulls[0], 0, 0, 1, p->origin, endpos, &tr);
VectorCopy(tr.endpos, p->origin);
if (tr.fraction != 1)
{
float f = DotProduct(vel*tr.plane_normal)*-2;//bounce like a super-bouncy ball.
VectorMA(p->vel, f, tr.plane_normal, p->vel);
}
}
Insert the above code instead of the following line:
VectorMA(p->origin, frametime, p->vel, p->origin);
Then it'll clip particles to the world.
notes:
sv_recursivehullcheck is a generic function provided inside the server code. the 0,0,1 parameters are needed due to its recursive nature, but should be set as above for starting at the top of the bsp tree.
the passed in trace_t structure needs to be pre-initialised. Really its only the values you want set if it should fail to hit anything. This being fraction, solidity, and endpos.
If the trace starts solid, endpos will not be changed. This means the particle will pass through solids still, but only if the trace started in a solid. This gives some protection against moving BSP objects.
hull 0 is the point-sized/infinity-small hull. The next smallest is too big.
It'll not clip to doors/moving plats/func_wall.
For that you'd need to iterate over the visentities list for bsp models, and pick whichever trace gave the smallest fractions.
CL_LinkEntities will give you hits here, but I'm not gonna discuss it in detail cos I don't remember the contents of that array or even the actual name of it.
The above code will probably not even compile. Certainly it'll have undeclared functions.
Regarding oriented decals... Which texture are you going to use? :)
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
LordHavoc wrote:I used to keep the cl_particles.c in DP compileable in glquake engines, but I stopped maintaining the compatibility, it could be added back if you want to drop in the DP particle system...
hmm i keep getting 102 errors when i try this, using cl_particles.c from :
[ ] darkplacesengine2002..> 25-Feb-2002 01:18 830k
i try commenting out some refefinitions but its little stuff to like:
- Code: Select all
C:\Users\alex\Desktop\quake\src\WinQuake\cl_particles.c(117) : error C2143: syntax error : missing '{' before '*'
C:\Users\alex\Desktop\quake\src\WinQuake\cl_particles.c(156) : warning C4047: '=' : 'int *' differs in levels of indirection from 'int '
C:\Users\alex\Desktop\quake\src\WinQuake\cl_particles.c(162) : error C2039: 'particles' : is not a member of 'refdef_t'
bah
- MeTcHsteekle
- Posts: 399
- Joined: Thu May 15, 2008 10:46 pm
- Location: its a secret
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest