Particle system overall size
by bentgarney · in Torque Game Builder · 03/21/2005 (2:38 am) · 8 replies
#2
Changing particle effects in code is a very advanced topic and isn't needed in most cases. I just wanted to highlight that as you should be able to achieve the effect your desire using the particle-editor alone. Of course, there are always going to be effects that you want to change dynamically (such as our grav-beam in the grav-demo).
"sizex_scale" is part of the effect, not the emitter. I note that in your example, you're drilling down to a specific emitter.
Before you can change the data-keys in any graph-field, you need to select it. Once selected, any key operations will be to that graph-field and it will stay selected until either you change it or another effect is loaded.
Anyhow, here's how you change the field for an effect and an emitter. Note that I'm just replacing the initial key in these examples (at least a single-key is enforced by T2D)...
Note that all indexes for both objects and keys are always zero-based. You can grab the emitters by index or by finding them (as shown above). It's always worth checking the objects returned to ensure they are valid as well as checking the emitter count etc. This is just safe practice and helps with your sanity.
If you want to check that these values have been changed then simply use "saveEffect()" and load it up in the particle-editor to see that the value has indeed changed.
Good Luck,
- Melv.
03/21/2005 (7:26 am)
Rob,Changing particle effects in code is a very advanced topic and isn't needed in most cases. I just wanted to highlight that as you should be able to achieve the effect your desire using the particle-editor alone. Of course, there are always going to be effects that you want to change dynamically (such as our grav-beam in the grav-demo).
"sizex_scale" is part of the effect, not the emitter. I note that in your example, you're drilling down to a specific emitter.
Before you can change the data-keys in any graph-field, you need to select it. Once selected, any key operations will be to that graph-field and it will stay selected until either you change it or another effect is loaded.
Anyhow, here's how you change the field for an effect and an emitter. Note that I'm just replacing the initial key in these examples (at least a single-key is enforced by T2D)...
// Select our effect field.
$myeffect.selectGraph("sizex_scale");
// Set the first key (index#0) to 10.
$myeffect.setDataKeyValue( 0, 10 );%emitter = $myeffect.findEmitterObject("MYCOOLEMITTER");
// Select out emitter field.
%emitter.selectGraph("quantity_base");
// Set the first key (index#0) to 100.
%emitter.setDataKeyValue( 0, 100 );Note that all indexes for both objects and keys are always zero-based. You can grab the emitters by index or by finding them (as shown above). It's always worth checking the objects returned to ensure they are valid as well as checking the emitter count etc. This is just safe practice and helps with your sanity.
If you want to check that these values have been changed then simply use "saveEffect()" and load it up in the particle-editor to see that the value has indeed changed.
Good Luck,
- Melv.
#3
03/21/2005 (10:23 am)
I love the particle editor... could spend way too much time playing with it
#4
also remember you have access to all of the particle editor GUI's... can make sliders for the options yourself if you want (I created a very large tutorial on creating the Physics Demo, which 80% of it is about the GUI and a good 60% of the GUI is sliders, so would be a good place to start)...
03/21/2005 (10:39 am)
I'll admit its a bit clunky, having to change the graph field dropdown, though its so much better than changing it all by script :)also remember you have access to all of the particle editor GUI's... can make sliders for the options yourself if you want (I created a very large tutorial on creating the Physics Demo, which 80% of it is about the GUI and a good 60% of the GUI is sliders, so would be a good place to start)...
#5
- Melv.
03/21/2005 (12:29 pm)
I don't like the particle editor either but it did only take a few days to do and it isn't the final product one. It does allow you to make cool effects though but it is clunky.- Melv.
#6
I wanted to change the smallthruster in the tutorial to the jet effect but I am having trouble resizing it.
I created a smalljet in the particle engine using the scale tools and saved it as smalljet.eff but when I attach it it is huge.
function attachThruster(%mountObj, %mountPosition, %angle)
{
// Create Player Thruster.
%thruster = new fxParticleEffect2D() { scenegraph = t2dSceneGraph; };
// %thruster.loadEffect("~/client/effects/smallThruster.eff");
%thruster.loadEffect("~/client/effects/smalljet.eff");
%thruster.mount( %mountObj, %mountPosition, 0, false );
%thruster.setRotation( %angle );
%thruster.playEffect();
}
How could I modify my code above to adjust the size of the smalljet?
Thanks
Jeff
03/21/2005 (12:51 pm)
Hi there,I wanted to change the smallthruster in the tutorial to the jet effect but I am having trouble resizing it.
I created a smalljet in the particle engine using the scale tools and saved it as smalljet.eff but when I attach it it is huge.
function attachThruster(%mountObj, %mountPosition, %angle)
{
// Create Player Thruster.
%thruster = new fxParticleEffect2D() { scenegraph = t2dSceneGraph; };
// %thruster.loadEffect("~/client/effects/smallThruster.eff");
%thruster.loadEffect("~/client/effects/smalljet.eff");
%thruster.mount( %mountObj, %mountPosition, 0, false );
%thruster.setRotation( %angle );
%thruster.playEffect();
}
How could I modify my code above to adjust the size of the smalljet?
Thanks
Jeff
#7
05/25/2007 (6:08 am)
I'm also interested in this. Was there ever any developments in adjusting the particle properties dynamically? It would be great to make a particle change size or colour when a particular event is happening.
#8
Some examples.
This one is pretty simple, change the speed of the effect;
Changing the color is a bit trickier since that stuff is in the emitters rather than in the system:
Note that currently there's no nice way to set the name of an emitter through the GUI, you can do this through script or the console though.
Or you could just use getEmitterObject directly instead of findEmitterObject but I find it nice to give the emitters names so I know what's what.
05/25/2007 (7:18 am)
I do some dynamic particle changes to sync the particles to music. Some examples.
This one is pretty simple, change the speed of the effect;
NameOfYourParticleSystem.selectGraph(speed_scale); NameOfYourParticleSystem.setValueScale (%speed);
Changing the color is a bit trickier since that stuff is in the emitters rather than in the system:
%emitter = NameOfYourParticleSystem.findEmitterObject( "NameOfYourEmitter" ); %emitter.selectGraph(red_life); %emitter.setValueScale (%scaleValue);This will scale your red color by %scaleValue.
Note that currently there's no nice way to set the name of an emitter through the GUI, you can do this through script or the console though.
%emitter = NameOfYourParticleSystem.getEmitterObject( 2 ); // get the emitter with ID 2
%emitter.setEmitterName ("blah");Or you could just use getEmitterObject directly instead of findEmitterObject but I find it nice to give the emitters names so I know what's what.
Associate Melv May
"setSize()" just controls the area which is used when spawning particles, it doesn't have anything to do with particle sizes.
Presumably you're asking how to scale all the emitters at once? If so, this is exactly what the particle-effect settings are (not the particle-emitter).
Changing "sizex_scale" or "sizey_scale" scales these sizes for all the emitters. As do all the "_scale" settings in the effect.
Note that all these settings can be changed in script as well.
We'll be getting some nice documentation out eventually as well as a nice particle editor. ;)
- Melv.