Game Development Community

Particles - Big and Small

by Kevin Summers · in Torque Game Engine · 04/10/2007 (1:44 pm) · 9 replies

I'm having a small problem with particles. Specifically with trying to change the size
of a particle emission.

I'm trying to create a particle emitter to create a flame for the tip of a candle. I can't
figure out how to change the size of an existing emitter such as the built in "Torch Fire"
in starter.fps to make it MUCH smaller than it is.

Is there a combination of settings in the datablock definitions that will do this?

#1
04/10/2007 (1:47 pm)
Seek something such as " sizes[0] = 1;" found inside the datablock ParticleData definition.
#2
04/10/2007 (3:02 pm)
I've made several attempts at changing those, and other settings in the datablocks.

Unfortunately it hasn't made any "size" difference in the flame as it sits inside a small
lantern sitting on a table in the game.
#3
04/10/2007 (3:31 pm)
Could you include your Particle data blocks?
#4
04/10/2007 (3:41 pm)
Here is one of the latest attempts. I still get a nice large fire that trails off to one side about 3-4
game scale feet. I'm looking to get a basically straight up 2 inch (game scale) flame.

datablock ParticleData(TorchFire1)
{
   textureName          = "~/data/shapes/particles/fire";
   dragCoefficient     = 0.0;
   gravityCoefficient   = -0.5;   // rises slowly
   inheritedVelFactor   = 0.00;
   lifetimeMS           = 1;
   lifetimeVarianceMS   = 0;
   useInvAlpha = false;
   spinRandomMin = -30.0;
   spinRandomMax = 30.0;

   colors[0]     = "0.6 0.6 0.0 0.1";
   colors[1]     = "0.8 0.6 0.0 0.1";
   colors[2]     = "0.0 0.0 0.0 0.1";
   colors[3]     = "0.0 0.0 0.0 0.1";

   sizes[0]      = 0.2;
   sizes[1]      = 0.5;
   sizes[2]      = 0.1;
   sizes[3]      = 0.0;

   times[0]      = 0.1;
   times[1]      = 0.2;
   times[2]      = 0.3;
   times[3]      = 0.6;
};
#5
04/11/2007 (5:43 am)
Here are a few things to try with the particles:

1) Increase the size of a particle to a much larger number just to see the effect. I cannot remember exactly but the difference between 0.2 and 0.5 may not be very noticeable.

ex)
sizes[0] = 5.0;

2) Turn down the amount of particles being emitted. If you are emitting many particles it may be creating a blob of particles where it is impossible to see the size of each individual particle.

3) Delete the DSO file for whatever script your particle data resides in. There has been a few times where a script did not recompile for me until I forced it too in this way.

4) I do not have any code available to me but just double check that the array name is not size instead of sizes. Simply look at some other data blocks to see what array they use.
* This is probably not the problem.

5) Depending on the life of the particle you may not have time to notice the sizes change. For example your particle size goes from 0.2 to 0.5 to 0.1 in only 30% of the time that the particle exists. If this particle only exists for a second you may not be able to observe the changing characteristics.

Let me know if any of these suggestions help.
#6
04/11/2007 (6:19 am)
To make them really small use '0.001' or '0.01', etc..
#7
04/11/2007 (11:11 am)
I shifted my focus to a different particle emitter in the stock starter.fps file.
I was changing values in the emitter for TorchFire in the ChimneyFire.cs file
and it was having little or no effect. Even with large changes in lifetimeMS,
sizes[] and times[].

I changed to the emitter for ChimneyFire in the same file, and was able to
set the values and see changes. The particle effects are definately strange
and wonderful animals. You have to be meticulous and careful to make sure
that when you place the particle emitter in the game you chose the right
particle that goes with the right emitter node, or you don't see the changes
that you want. While I don't know if that's what I did earlier with the TorchFire,
it seems logical that I might have accidently done that.

In switching to the ChimneyFire and going down to very small values for sizes,
such as 0.001, and smaller lifetimeMS values, I was able to get the candle flame
effect I was after.

I'll update this post with the code soon. So others can learn from my mistake(s). :-)

Here is what I ended up with after messing around with it for a while. This is what I
would consider a rough draft for a small candle flame, but it gets it close to what I
was after.

datablock ParticleData(CandleFire1)
{
   textureName          = "~/data/shapes/particles/smoke";
   dragCoefficient     = 0.0;
   gravityCoefficient   = -0.1;   // rises slowly
   inheritedVelFactor   = 0.00;
   lifetimeMS           = 200;
   lifetimeVarianceMS   = 10;
   useInvAlpha = false;
   spinRandomMin = -30.0;
   spinRandomMax = 30.0;

   colors[0]     = "0.8 0.6 0.0 0.1";
   colors[1]     = "0.8 0.6 0.0 0.1";
   colors[2]     = "0.0 0.0 0.0 0.0";

   sizes[0]      = 0.03;
   sizes[1]      = 0.05;
   sizes[2]      = 0.01;

   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleData(CandleFire2)
{
   textureName          = "~/data/shapes/particles/smoke";
   dragCoefficient     = 0.0;
   gravityCoefficient   = -0.2;   // rises slowly
   inheritedVelFactor   = 0.00;
   lifetimeMS           = 200;
   lifetimeVarianceMS   = 5;
   useInvAlpha = false;
   spinRandomMin = -30.0;
   spinRandomMax = 30.0;

   colors[0]     = "0.6 0.6 0.0 0.1";
   colors[1]     = "0.6 0.6 0.0 0.1";
   colors[2]     = "0.0 0.0 0.0 0.0";

   sizes[0]      = 0.03;
   sizes[1]      = 0.05;
   sizes[2]      = 0.01;

   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(CandleFireEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 5;

   ejectionVelocity = 0.1;
   velocityVariance = 0.0;

   thetaMin         = 0.0;
   thetaMax         = 90.0;  

   particles = "CandleFire1" TAB "CandleFire2";
};

datablock ParticleEmitterNodeData(CandleFireEmitterNode)
{
   timeMultiple = 1;
};
#8
04/11/2007 (11:47 am)
One thing, many of the 'stock' Torque data blocks are defined multiple times, multiple place, with the same NAME (they are only there for example after all..), essentially overriding the earlier loaded definition. At least this is found true for 1.42. If you wish to be SURE 100% the datablock you are editing is working correctly, one should cut/past from an example and then give it a NEW name.
#9
04/11/2007 (12:04 pm)
That was going to be my next consideration. There are several samples within the starter.fps that I wont end up using, so I'm going to clear most of them out and start fresh with a Particles.cs file and go from there.