Cheep Particle Tricks
by Caylo Gypsyblood · in Torque Game Engine · 01/31/2007 (5:03 pm) · 41 replies
A few days ago, when attempting to optimize Torques Particles a bit, I seem to inadvertently put in some simple physics, and collision detection along with a script call back.
And now, I am getting a better ingame FPS even with the new added overhead.
But i dont know if i did everything right, it may not work networked, being im working on a single player game, i have not tested it beyond that.
Cheap Particle Tricks Download
All other info is in the file.
EDIT: Download removed ,post here asking for file to be sent by email...
EDIT: returned download link.....
And now, I am getting a better ingame FPS even with the new added overhead.
But i dont know if i did everything right, it may not work networked, being im working on a single player game, i have not tested it beyond that.
Cheap Particle Tricks Download
All other info is in the file.
EDIT: Download removed ,post here asking for file to be sent by email...
EDIT: returned download link.....
#2
caylo if you like i can host the file for you; or just submit it as a resource.
02/09/2007 (10:16 am)
Link down for me also.caylo if you like i can host the file for you; or just submit it as a resource.
#3
Let me know what you think of the Particle Tricks. And i am expecting to make a resource, wishing first to have the thing tested a bit more. It works great for my single player project. My fear is i could have done better with the pack/unpack stuff, i dont truly understand it...
02/09/2007 (12:57 pm)
Seems I deleted it when cleaning my file depo. Back now...Let me know what you think of the Particle Tricks. And i am expecting to make a resource, wishing first to have the thing tested a bit more. It works great for my single player project. My fear is i could have done better with the pack/unpack stuff, i dont truly understand it...
#4
going thru the code now.
Couple possible optimizations:
you know that mPow is pretty slow yeah ?
why not just use good old * instead ?
random numbers are also very slow.
you may want to move this line out of updateSingleParticle():
very nice tho !
02/09/2007 (1:17 pm)
Hey caylo - awesome, thanks.going thru the code now.
Couple possible optimizations:
you know that mPow is pretty slow yeah ?
why not just use good old * instead ?
S32 distFromCam = mPow(particle->pos.x - cameraPos.x,2) + mPow(particle->pos.y - cameraPos.y,2) + mPow(particle->pos.z - cameraPos.z,2);
random numbers are also very slow.
you may want to move this line out of updateSingleParticle():
S32 DOparticle= (S32)(sgRandom.randI(1, 100));and just create the random number once when the particle is created.
very nice tho !
#5
That one DOparticle; I actually did use a predefined system (check the particle Distance Reduction section of code found in void ParticleEmitter::addParticle you see i already DO give them each a #) for that at first, but it seemed to be spitting them out in a orderly fashion and looked to systematic.
Still, much thanks Orion, I sort of expected a long list of problems to be found...
PS: I put
02/09/2007 (2:03 pm)
That +mPow chunk of code came that way. (I often cut and past my functions from other places i already see them working. Im not a brilliant programmer, but i understand brilliant code...)That one DOparticle; I actually did use a predefined system (check the particle Distance Reduction section of code found in void ParticleEmitter::addParticle you see i already DO give them each a #) for that at first, but it seemed to be spitting them out in a orderly fashion and looked to systematic.
Still, much thanks Orion, I sort of expected a long list of problems to be found...
PS: I put
S32 distFromCam = mPow(particle->pos.x - cameraPos.x,2) * (particle->pos.y - cameraPos.y,2) * (particle->pos.z - cameraPos.z,2);but from some angles the particles do not get distance reduction. I actually dont even know what mPow is.
#6
mPow is the power function. mPow(a, b) = a^b, so mPow(a, 2) = a^2 = a*a.
also, you *do* need to square each element individually;
actually i don't even see how that last line would compile. anyhow, here's the code i would use:
and change the subsequent references to "distFromCam" to "distFromCamSquared".
02/09/2007 (2:35 pm)
Heh.mPow is the power function. mPow(a, b) = a^b, so mPow(a, 2) = a^2 = a*a.
also, you *do* need to square each element individually;
actually i don't even see how that last line would compile. anyhow, here's the code i would use:
VectorF vecCamParticle = particle->pos - cameraPos; F32 distFromCamSquared = vecCamParticle.lenSquared();
and change the subsequent references to "distFromCam" to "distFromCamSquared".
#7
02/09/2007 (6:29 pm)
Cool thanks. I would have looked into it deeper, but had a hangover. Getting the distance from the cam is all over the place in the code.
#8
If so please send it to me at RJNelson68@cox.net
05/21/2008 (3:11 pm)
Hey Caylo do you still have this code available?If so please send it to me at RJNelson68@cox.net
#9
Great Idea, keep us updated!
05/22/2008 (3:57 pm)
I was wanting to do something like this with particles, I mainly wanted to do collision for like sparks from a power cable of some sort. Great Idea, keep us updated!
#10
Also, what exactly was changed, I understand the collisions, but what do you mean by simple physics?
05/22/2008 (7:42 pm)
Do you know if this is compatable with AFX? I'd try, but it's late, and I'm not able to get to the computer with Torque on it. =PAlso, what exactly was changed, I understand the collisions, but what do you mean by simple physics?
#11
please send to racs333@hotmail.com
Thanks in advance.
05/22/2008 (10:25 pm)
Hello Caylo, Id love to see this code / particle tricksplease send to racs333@hotmail.com
Thanks in advance.
#12
Cheap Particle Tricks Download
05/23/2008 (12:33 am)
Here is the download. If i recall correctly its hell to get working with 1.5x code. Cheap Particle Tricks Download
#13
05/23/2008 (8:57 am)
Thanks Caylo, and I plan to make it work with TGEA.
#14
05/23/2008 (3:19 pm)
Well I got the collision system for this to work great in TGEA but the particle reduction code is so drastically different that I didn't get it done.
#15
05/23/2008 (8:49 pm)
I expect it is on count of TGEA particles use batch rendering...?
#16
05/23/2008 (9:10 pm)
Yup, not really worried about it though. The biggest part I wanted was the collision which works perfectly. Thanks.
#17

Other then that it works
05/24/2008 (9:00 am)
I have it working in AFX, the only thing is the textures arent showing properly.. they are simply rendered squares. Any idea what i need todo tosmooth them out. The actual motions and effects work though ie, bouncing and splashing.. the steam looks like its a bunch of boxes spewing forth. i added a normal steam emmiter i have. just tocompare the 2
Other then that it works
#18
05/24/2008 (12:02 pm)
The example emitters do not use any datablock defined texture. Texture should work once defined in datablock.
#19
05/24/2008 (12:53 pm)
Link doesn't work anymore
#20
05/24/2008 (1:23 pm)
It should, but if problem persist send me an email for file by attachment...
Torque 3D Owner Thomas Shaw