Grappling with This System :D
by Rob Sandbach · in Torque Game Builder · 01/06/2006 (1:33 pm) · 6 replies
Hello all!
Im looking to create a prototype firework effect for my game. Ive read through the official alpha documentation and the tutorial, and understand the principles, but im still a little stumped. Ive built the explosion effect from the tutorial, which all works nicely. Ive removed the smoke emitter so i just have my particles racing from the centre, simulating the particles. These then slow after explosion and move really slowly as fireworks tend to do. Im planning on adding a "setconstantforce" to act as gravity after they slow so they droop a little bit.
My problem is, I'd like to add trails behind each particle as they shoot outwards, to simulate this sort of effect:
http://i1.trekearth.com/photos/11791/firework.jpg
Ive beaten around the editor and looked at the demo effects, but im beat!
Apologies if it's a simple answer i've overlocked!!
Look forward to some help :D
Im looking to create a prototype firework effect for my game. Ive read through the official alpha documentation and the tutorial, and understand the principles, but im still a little stumped. Ive built the explosion effect from the tutorial, which all works nicely. Ive removed the smoke emitter so i just have my particles racing from the centre, simulating the particles. These then slow after explosion and move really slowly as fireworks tend to do. Im planning on adding a "setconstantforce" to act as gravity after they slow so they droop a little bit.
My problem is, I'd like to add trails behind each particle as they shoot outwards, to simulate this sort of effect:
http://i1.trekearth.com/photos/11791/firework.jpg
Ive beaten around the editor and looked at the demo effects, but im beat!
Apologies if it's a simple answer i've overlocked!!
Look forward to some help :D
#2
I don't really understand alpha blending, or what it does atm so Im defining colours by adjusting the RGB values of the particles and having seperate effects, with different colours. Is there a more efficient method of achieving this?
Appreciate the help you've offered here, didn't think about doing it this way. As long as the overhead ain't too high, I should be able to kick out a variety of different fireworks purely adjusting life and gravitational pull of this function.
Thanks again!!
Rob
01/07/2006 (11:59 am)
Thanks very much for this help Melv, I think i'll give this a shot. I don't really understand alpha blending, or what it does atm so Im defining colours by adjusting the RGB values of the particles and having seperate effects, with different colours. Is there a more efficient method of achieving this?
Appreciate the help you've offered here, didn't think about doing it this way. As long as the overhead ain't too high, I should be able to kick out a variety of different fireworks purely adjusting life and gravitational pull of this function.
Thanks again!!
Rob
#4
I've added the code and Torque will now crash randomly. Without the above code it works fine for as long as I want, and I've really stress tested it at time in terms of particles and emmitters, having 600-1000 fireworks firing 20 a second, each with a particle emitter mounted. In this respect I can't see it being it's overloaded with particle editors. One thought that did come across me was that every emitter in the scene is using the MagicTrail imagemap as it's basis....
Seems strange that I can have as many mounted emitters as I want, but using moving effects as above causes a crash. What else is strange is the random nature of these crashes. It's not when there's x trails on screen. Sometimes it's not even when ive called that function but a couple of seconds later.
Any thoughts anyone has?
01/20/2006 (3:55 pm)
Ok Melv, if you could help me out I'd appreciate it...I've added the code and Torque will now crash randomly. Without the above code it works fine for as long as I want, and I've really stress tested it at time in terms of particles and emmitters, having 600-1000 fireworks firing 20 a second, each with a particle emitter mounted. In this respect I can't see it being it's overloaded with particle editors. One thought that did come across me was that every emitter in the scene is using the MagicTrail imagemap as it's basis....
Seems strange that I can have as many mounted emitters as I want, but using moving effects as above causes a crash. What else is strange is the random nature of these crashes. It's not when there's x trails on screen. Sometimes it's not even when ive called that function but a couple of seconds later.
Any thoughts anyone has?
#5
you must to upgrade if you are using alpha2...
01/20/2006 (4:47 pm)
Hmm crash sounds like the memory bugs that melv squished in the alpha3you must to upgrade if you are using alpha2...
#6
01/20/2006 (5:52 pm)
Aaah! Will look into this! Thanks very much for the heads up!
Employee Melv May
The effect you're looking for can't be done directly from the editor and here's the reason why. As you can see, each "streak" of the firework is actually leaving behind particles meaning that each "streak" is a moving emitter. This can be done but the editor is only a placeholder and you cannot easily orchestrate this kind of effect using it.
Two options would be:
1) Define your effect to be the "streak" itself and in script create a function like "createFirework()" which creates a bunch of these effects all shooting outwards; this'll mean you can add a gravity force to each one as you mentioned.
2) Create a t2d C++ object which essentially does the above.
A while back I was going to add a parent object to the t2dParticleEffect which emitted "effects". In the "Particle Illusions" product, these are called "Super Emitters". Unfortunately, there were many other things to do and I didn't get to do this but this doesn't mean you can't create this effect, you most certainly can but unfortunately, for the moment, just not using the existing editor.
Option #1 above would be real easy to do. In-fact, particles are so much fun to play with, here's an example albeit using a stock effect that isn't suited that well but it means you can see the effect immediately.
Add this to the T2D mod, preferably somewhere in the "client.cs" file:
function sceneWindow2D::onMouseDown( %this, %modifier, %worldPosition, %mouseClicks ) { createFirework( %worldPosition, 10 ); } function createFirework( %worldPosition, %streaks ) { for ( %n = 0; %n < %streaks; %n++ ) { %firework = new t2dParticleEffect() { scenegraph = t2dScene; }; %firework.loadEffect("~/client/effects/magic_trail.eff"); %firework.setPosition( %worldPosition ); %firework.setEffectLifeMode( KILL, 2.0 ); %firework.playEffect(); %firework.setLinearVelocityPolar( getRandom(360), getRandom(10,15) ); %firework.setConstantForcePolar( 180, 10 ); } }... and just click on the screen where you want the "firework". Things to configure here would be the effect itself which you could automatically control, within the editor, its life-mode to save you doing it in script. You can also change the velocity and direction using the "setLinearVelocityPolar()" command. You can also change the gravity using "setConstantForcePolar()". There's also the option of how many streaks to use. It's always good practice as well to turn-on the debug-info banner and monitor the particle usage to ensure it doesn't get too high.It could also be handy to expose these in the function call as parameters perhaps. Note that you can also add code here to give you a random or specified colour using the new per-emitter blending options available in the alpha-releases.
Don't forget to come back here and post your results just for fun. Good luck!
Hope this helps,
- Melv.