Improved particle system for Torque 3D
by Lukas Joergensen · 05/20/2012 (7:08 pm) · 36 comments
Download it here
I wrote a pdf which is included in the download. The pdf should document the code decently so i will use this page mostly for credits and showcase!Showoff thread!
Torque CE wiki page
(Some differences may apply)What is this resource?
This resource extends the particleEmitter class and adds a new graphEmitter class.The change to the regular particleEmitter class lies in the ability to change values on a per emitter basis rather than a per datablock basis. Read more about this here
The change that this resource will focus on tho is the graphEmitter class. The graphEmitter class is basing the position of the particles on 3 functions, one for each coordinate.
So if the function for x is x=1 it would be placed 1 meter from the graphEmitter along the x-axis.
Combined with the powerful muParser, it is very easy to create nice looking effects like the ones above.
To do list:
- Better documentation and commenting of the code
- Bugfixes & cleanup of the code
- Possibly benchmark
Please do confirm that the documentation is OK and nothing needs clarified. And do tell me if i need to upload some files!
And you are always welcome to ask all the questions you want!
A video showing almost all features of 2.0.0
An environmental example
Composite functions
If you want to do composite functions you can do it via the muParser syntax!
Here is an example of the spiralNode with a variable function!
datablock GraphEmitterNodeData(g_compSpiralNode : g_DefaultNode)
{
xFunc = "t<500 ? cos(t/50)*t*0.02 : t<1000 ? cos(t/50)*t*0.1 : t<1500 ? cos(t/50)*t*0.02 : cos(t/50)*t*0.1";
yFunc = "t<500 ? sin(t/50)*t*0.02 : t<1000 ? sin(t/50)*t*0.1 : t<1500 ? sin(t/50)*t*0.02 : sin(t/50)*t*0.1";
zFunc = "t/20";
};Oh almost forgot!
I got all changes to the particleEmitter files written here:
http://nakednerd.clan-net.dk/tutorials/read?tut=t3d1
Changelog
Hotfix 04/06-2012Hotfix 01/06-2012
Update v1.0.2
Update v1.0.1
Credits
Thanks to Ingo Berg for releasing this powerful tool (muParser)! [MIT license]Thanks to Charlie Patterson, hes Twillex engine is what inspired me to all of this, and i ensure you that if you combine the Twillex engine with this resource you will have some vastly powerful tools at your hands!
Thanks to everyone who downloads this resource! If you create something magnificent please show it off in the comments below!
About the author
IPS Bundle available at: https://www.winterleafentertainment.com/Products/IPS.aspx
#2
I can already see this enhancement taking up a lot of time by playing with it :)
05/20/2012 (10:25 pm)
Nifty!I can already see this enhancement taking up a lot of time by playing with it :)
#3
05/20/2012 (10:31 pm)
Thanks Lukas. I'll play with this soon (when I finally get to breathe) and see what I can do with it.
#4
Edit: btw no problem guys! I hope you create some awesome stuff with it!
05/21/2012 (1:46 am)
My face when the resource ends up under blogs..... GG fix please! :DEdit: btw no problem guys! I hope you create some awesome stuff with it!
#5
05/21/2012 (5:58 am)
Oooh! Pretty!
#6
Featuring:
05/21/2012 (3:00 pm)
Just making the very last fixes, then going to work on some documentation and then i will have update 1.0.1 ready for release!Featuring:
- Dynamic variables
- Reverse boolean
- A working timeScale (kindda embarrassed over that bug really)
- Some bug fixes and optimization
- Edit: a fix to a possible issue where emitters wouldn't delete on the client side.
#7
05/21/2012 (4:32 pm)
Can I make decent afterburners with this Lukas? My afterburners are pathetic pilot lights. My craft will travel at 50m/s at this rate!
#8
Do you want them to peak like this:
Or more cylinder formed like this:

And do you want them to shoot backwards while stationary as well?
Oh yeah also do you want them volumetric or hollow?
05/21/2012 (4:42 pm)
Hmm afterburners,Do you want them to peak like this:

Or more cylinder formed like this:

And do you want them to shoot backwards while stationary as well?
Oh yeah also do you want them volumetric or hollow?
#9
This is what I have at the moment. Sorry about the angle. It's not the best shot for an example.
05/22/2012 (2:40 am)
Haha... Nice going Lukas! Actually what I have now looks more like the first pic, while what I want is something like the second pic. As to hollow or volumetric, I don't mind. The best looking for the lowest cost to performance would make me happy. I think I just need to spend more time with particles in general.This is what I have at the moment. Sorry about the angle. It's not the best shot for an example.
#10
05/22/2012 (4:44 am)
Well tbh, just found that the graphEmitter doesn't take rotation into account so right now backburners is not really something you can do... Fix incoming with update 1.0.1
#11
05/22/2012 (12:59 pm)
freaking lovely stuff.
#12
05/24/2012 (5:10 am)
really awesome cool stuff :)
#13
So, I just made some fixes and features for the resource. I uploaded a video showing the new features too, or most of them atleast.
I wanted to play a little around with videoeditting and thats why there is some effects in it too, also to shorten the length of the video.
See the release video here:
(Sorry for it not being in HD, it's a bit longer and didn't want to spend too long time uploading so compressed it to 20 mb >.<)
HOTFIX
If you have updated to v1.0.1 please wait for the hotfix to get uploaded and download again, or append this to the graphEmitter.cpp:
Will still be in next update tho.
05/24/2012 (8:06 am)
***Update***So, I just made some fixes and features for the resource. I uploaded a video showing the new features too, or most of them atleast.
I wanted to play a little around with videoeditting and thats why there is some effects in it too, also to shorten the length of the video.
See the release video here:
(Sorry for it not being in HD, it's a bit longer and didn't want to spend too long time uploading so compressed it to 20 mb >.<)
Update is: Live
HOTFIX
If you have updated to v1.0.1 please wait for the hotfix to get uploaded and download again, or append this to the graphEmitter.cpp:
if(nodeDat->particleProg == 0)
{
nodeDat->particleProg = F32_MIN;
}Right after:if(nodeDat->particleProg > nodeDat->funcMax)
{
if(nodeDat->Loop)
nodeDat->particleProg = nodeDat->funcMin;
nodeDat->onBoundaryLimit(true);
}
if(nodeDat->particleProg < nodeDat->funcMin)
{
if(nodeDat->Loop)
nodeDat->particleProg = nodeDat->funcMax;
nodeDat->onBoundaryLimit(false);
}NVM, seems like this is built into muParserWill still be in next update tho.
#14
Well i'm not an artist for sure, but here is an example of how you could utilize this resource to make a backburner (not sure if this one suits your needs but it is a proof of concept at least)
Tell me if you are interested in this code.
I used the Twillex resource to add some dynamic features to the emitter.
The part of the video where it pulls together is to simulate how you can use dynamic fields to let the speed of the vehicle influence the emitter. Here i used it to simulate that at greater speeds you would thin out the emitter so to solve some graphical issues.
Edit: the point in having it longer when the object was slow or didn't move is because they would be long during acceleration decceleration and when not moving it would be turned off.
05/24/2012 (10:57 am)
@Dan now that I got the rotation working and dynamic variables I will try and look into the backburner! Mostly for interest and to see if I slam my head into any limitations this system may have. I am mainly looking for any limitations with emitters in motion, I will post what I find out.Well i'm not an artist for sure, but here is an example of how you could utilize this resource to make a backburner (not sure if this one suits your needs but it is a proof of concept at least)
Tell me if you are interested in this code.
I used the Twillex resource to add some dynamic features to the emitter.
The part of the video where it pulls together is to simulate how you can use dynamic fields to let the speed of the vehicle influence the emitter. Here i used it to simulate that at greater speeds you would thin out the emitter so to solve some graphical issues.
Edit: the point in having it longer when the object was slow or didn't move is because they would be long during acceleration decceleration and when not moving it would be turned off.
#15
Tell me if you have any problems or if you would like to see some new features added!
05/24/2012 (6:32 pm)
Just released an update 1.0.2 with better documentation and a new syntax for dynamic variables + some documentation on composite function, leaving this resource for now.Tell me if you have any problems or if you would like to see some new features added!
#16
05/25/2012 (2:35 am)
Oooh shiny, got some new particle features in mind! Just got sticky particles working!
#17
05/25/2012 (4:32 am)
Wow... Updates. Nice work Lukas!
#18
@Dan this update I am working on right now might be interesting for your backburners, as I found that, as soon as the object moves too fast, the particles wont be emitted fast enough and it wont look very good without creating a big tail behind it.
In the next update i will create sticky particles which might solve that problem!
A more recent version of the attracted particles:
05/26/2012 (9:24 am)
I keep playing with this resource and I have some nice goodies in the works!@Dan this update I am working on right now might be interesting for your backburners, as I found that, as soon as the object moves too fast, the particles wont be emitted fast enough and it wont look very good without creating a big tail behind it.
In the next update i will create sticky particles which might solve that problem!
A more recent version of the attracted particles:
#19
(Switch to 3 minutes in to just see the new features in 2.0.0)
05/27/2012 (3:39 pm)
Patch video of patch 2.0.0(Switch to 3 minutes in to just see the new features in 2.0.0)
#20
It is not very well documented code-wise, I will see if i get around to fix that
05/27/2012 (4:11 pm)
Patch 2.0.0 is live
With some particle physics, attractive particles, particle collisions and more.It is not very well documented code-wise, I will see if i get around to fix that

Ahsan Muzaheed
Default Studio Name
may be i will not be able to test it in this week.
so this post is just to say you thanks.
your resource has given me inspiration to work with t3d's particles for first time.(some part of your last video gives me an idea to do some lighting work on sky)
i am a slow learner.and very much curious.i will be back with a lot off question.
thanks for this wonderful resource.`