Converting Particles from Legacy T2D
by Peter Robinson · 09/09/2015 (8:38 am) · 7 comments
It's been years since T2D MIT came out but I've lived in the past, trying to work on my project on the old engine. Finally, about a month ago I took the leap and started converting my code to the new engine. It's been rough. The y-axis has flipped and mounting is gone, but I've made the best of it because I love composite sprites and the ability to sort a layer using a z index. The code base also seems easier to work with. Gradually I hope to impart everything I've learned for the two or three other people out there who haven't taken the plunge and upgraded yet. Today I'm going to solve the particle problem.
Particles are saved in a binary format in legacy T2D so you can't just open the file and change things. So I wrote a script that would load a particle effect and then save it in the correct taml format. Almost everything has stayed the same between the two versions for particles but there are some changes that you should know about.
There might be other problems that I haven't come across. Feel free to add a comment if you find something.
Here's the script I wrote. It depends on the xml class from the common folder. Just give that first function a list of particle effects, set the path to open them, and call the ExportAll function from a legacy copy of T2D. The resulting taml will be in your AppData folder. I hope it helps!
www.circuithive.com/downloads/ParticleConverter.cs
Particles are saved in a binary format in legacy T2D so you can't just open the file and change things. So I wrote a script that would load a particle effect and then save it in the correct taml format. Almost everything has stayed the same between the two versions for particles but there are some changes that you should know about.
- You'll have to change the image or animation to reference a valid asset.
- Different settings can be globally scaled for all emitters at the effect level. I don't believe this was possible in legacy so there's no conversion for it.
- You can now have an offset for an emitter from the effect. I think this is new. The offset will be "0 0" as a placeholder.
- You can also now have an EmitterSize for an emitter. Setting the EmitterType to BOX (previously AREA) uses this size instead of the size of the player as before. I defaulted the size to "10 10". You'll need to set it accordingly.
- EmitterTypes LINEX and LINEY have been combined into LINE which uses the width (effectively LINEX). So if you used LINEY you'll need to rotate your effect for it to work.
There might be other problems that I haven't come across. Feel free to add a comment if you find something.
Here's the script I wrote. It depends on the xml class from the common folder. Just give that first function a list of particle effects, set the path to open them, and call the ExportAll function from a legacy copy of T2D. The resulting taml will be in your AppData folder. I hope it helps!
www.circuithive.com/downloads/ParticleConverter.cs
About the author
A programmer who has been using the Torque2D game engine since the early adopter days. My game is Pirate Code and it can be found at www.circuithive.com. It will be arriving on Steam in 2016.
#2
09/22/2015 (2:46 pm)
Will do Simon. I don't think I can do particles in text. Experimentation is key to making a good particle effect. I'll add my function too. With all those "s in there the function isn't as useful as I'd hoped. Although I guess a little find and replace could fix it up again.
#3
I am simply providing the PFX editor as an alternative; Feel no obligation to use it or add to it. :)
09/22/2015 (6:06 pm)
You can also submit the script file via dropbox or personal hosting.I am simply providing the PFX editor as an alternative; Feel no obligation to use it or add to it. :)
#4
I'll still probably use your editor. I need something for particle effects. If editors have been written - even if poorly tested or documented - it should be mentioned in the official documentation or nobody will ever use them. And if nobody uses them, there'll be nobody to test and improve them.
09/23/2015 (6:05 am)
Creating a download for the script file might be better. Now that I'm thinking about it, your particle editor is in T2D MIT and my script would need to run with a legacy copy of T2D.I'll still probably use your editor. I need something for particle effects. If editors have been written - even if poorly tested or documented - it should be mentioned in the official documentation or nobody will ever use them. And if nobody uses them, there'll be nobody to test and improve them.
#5
09/23/2015 (6:27 am)
Done. There's now a link to the file. I hope someone finds it useful.
#6
I think you make a good point about a "community editors" section in the wiki. There was/is such a section in the Google+ community but nobody posts over there.
09/23/2015 (6:33 am)
Sorry for not being clearer, in my mind T2D MIT is known as T2D and the "legacy" version is known as TGB (Torque Game Builder).I think you make a good point about a "community editors" section in the wiki. There was/is such a section in the Google+ community but nobody posts over there.
#7
Despite what the documentation says here, the pivot point should be set to "0 0" if you want to rotate round the center of the particle. We should probably correct the documentation. The old engine used "0.5 0.5" as the center. I'll subtract 0.5 from the pivot point in the converter to adjuster for this.
Next, the rendering order of emitters has changed. In the old engine, the first emitter appeared in the front, now it appears in the back. To handle this my converter will write the emitters in reverse order.
And finally the fixed force angle needs to be updated to account for rotated quadrants and a flipped y-axis. My converter handles this too.
Even after all this I can't guarantee an exact conversion, but in my case, it's getting close.
09/30/2015 (9:06 am)
Some more random information on particles:Despite what the documentation says here, the pivot point should be set to "0 0" if you want to rotate round the center of the particle. We should probably correct the documentation. The old engine used "0.5 0.5" as the center. I'll subtract 0.5 from the pivot point in the converter to adjuster for this.
Next, the rendering order of emitters has changed. In the old engine, the first emitter appeared in the front, now it appears in the back. To handle this my converter will write the emitters in reverse order.
And finally the fixed force angle needs to be updated to account for rotated quadrants and a flipped y-axis. My converter handles this too.
Even after all this I can't guarantee an exact conversion, but in my case, it's getting close.

Associate Simon Love
If you're wondering why " are all over your code, it is due to a bug which replaces all quotes with that code whenever you edit a blog post after publishing it. Pain in the a** for sure!
If you are interested in a Particle Effects Editor for T2D, built in T2D, check out my
Particles Editor
By no means perfect but you get the source and can tweak it to your heart's desire, even add your import function to it. It's yours as much as it is mine. Its framework is built upon Michael Perry's Editor base.