View previous topic :: View next topic |
Author |
Message |
leileilol

Joined: 15 Oct 2004 Posts: 1321
|
Posted: Thu Mar 19, 2009 9:17 am Post subject: 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. |
|
Back to top |
|
 |
Tomaz
Joined: 05 Nov 2004 Posts: 49
|
Posted: Thu Mar 19, 2009 3:39 pm Post subject: |
|
|
I dont see why adopting the system i used to WinQuake wouldnt work? WinQuake doesnt use contents? Its not like thats a renderer specific thing.
If I remember I'll look it up when I get home from work. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Thu Mar 19, 2009 4:44 pm Post subject: |
|
|
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Last edited by mh on Thu Mar 19, 2009 4:46 pm; edited 1 time in total |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Thu Mar 19, 2009 4:45 pm Post subject: |
|
|
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? :) _________________ What's a signature? |
|
Back to top |
|
 |
LordHavoc
Joined: 05 Nov 2004 Posts: 243 Location: western Oregon, USA
|
Posted: Thu Mar 19, 2009 7:17 pm Post subject: |
|
|
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... |
|
Back to top |
|
 |
MeTcHsteekle
Joined: 15 May 2008 Posts: 397 Location: its a secret
|
Posted: Tue Mar 24, 2009 9:31 pm Post subject: |
|
|
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: | 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 |
|
Back to top |
|
 |
LordHavoc
Joined: 05 Nov 2004 Posts: 243 Location: western Oregon, USA
|
Posted: Wed Mar 25, 2009 5:14 am Post subject: |
|
|
I think versions from around 2006/2007 may work better.
Note that there's a need for a #define or something at the top to switch it over - look at the #ifdef lines all over the file. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|