Changing particles' parameters
by SPECS · in Torque Game Engine · 05/29/2008 (8:30 am) · 6 replies
Hi All!
I would like to make something like an animated particle effect, i.e:
I would use an existent ParticleData datablock and change for example the color, position, and other parameters over time - i.e in some "frame" function (each frame / clocktick)
The same intervention would be very useful for me also concerning precipitation - I would like to make my rain heavier over time..
How can I do that - using script? adding code to the engine?
In the same sense - can I create paths, along which particles are moving (instead of a pathed player bot)?
I would be EXTREMELY grateful about any response
Best
Nina
I would like to make something like an animated particle effect, i.e:
I would use an existent ParticleData datablock and change for example the color, position, and other parameters over time - i.e in some "frame" function (each frame / clocktick)
The same intervention would be very useful for me also concerning precipitation - I would like to make my rain heavier over time..
How can I do that - using script? adding code to the engine?
In the same sense - can I create paths, along which particles are moving (instead of a pathed player bot)?
I would be EXTREMELY grateful about any response
Best
Nina
#2
Thanks for replying! I suppose the particle system has these operations but I don't know how to use it (from script or engine code, whatever) since I am not a TGE expert.. I would like to make a particle effect (i.e fire or lava) increase and decrease (something like pulsating) over time - something like a particle effect animation. What are the function to do that? And where should I put them?
Thx again!
05/30/2008 (7:26 am)
Hi Nathan, Thanks for replying! I suppose the particle system has these operations but I don't know how to use it (from script or engine code, whatever) since I am not a TGE expert.. I would like to make a particle effect (i.e fire or lava) increase and decrease (something like pulsating) over time - something like a particle effect animation. What are the function to do that? And where should I put them?
Thx again!
#3
Thanks for replying! I suppose the particle system has these operations but I don't know how to use it (from script or engine code, whatever) since I am not a TGE expert.. I would like to make a particle effect (i.e fire or lava) increase and decrease (something like pulsating) over time - something like a particle effect animation. What are the function to do that? And where should I put them?
Thx again!
05/30/2008 (8:47 am)
Hi Nathan, Thanks for replying! I suppose the particle system has these operations but I don't know how to use it (from script or engine code, whatever) since I am not a TGE expert.. I would like to make a particle effect (i.e fire or lava) increase and decrease (something like pulsating) over time - something like a particle effect animation. What are the function to do that? And where should I put them?
Thx again!
#4
05/30/2008 (1:40 pm)
Here's an example, I'll point out some of the values that have major effect on the particles.datablock ParticleData(VC_Diamond1_P)
{
dragCoeffiecient = 0.5; //<- Controls how much drag there is on a particle
gravityCoefficient = 0.2; //<- Controls how much gravity effects the particle
inheritedVelFactor = 0.00;
lifetimeMS = 2000; //<- Controls how long the particle is rendered before deletion
lifetimeVarianceMS = 400; //<- Lifetime = Lifetime +- this
useInvAlpha = false; //<- Basicly changes whether the particles glow or not.
spinRandomMin = 360.0; //<- Minimum spin
spinRandomMax = 720.0; //<- Maximum spin
colors[0] = "1.0 0.60 1.0 1.0"; //<- The particle is Colors[n] at times[n]
colors[1] = "1.0 0.60 1.0 1.0";
colors[2] = "1.0 0.60 1.0 0.0";
sizes[0] = 0.10; //<- The particle is Sizes[n] at times[n]
sizes[1] = 0.10;
sizes[2] = 0.10;
times[0] = 0.0; //<- At what point colors[n] and sizes[n] take place
times[1] = 0.6;
times[2] = 1.0;
textureName = %mySpellDataPath @ "/vc/particles/diamond"; // <- Path to texture
};
datablock ParticleData(VC_Diamond2_P)
{
dragCoeffiecient = 0.5;
gravityCoefficient = 0.2;
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 400;
useInvAlpha = false;
spinRandomMin = 360.0;
spinRandomMax = 720.0;
colors[0] = "0.2 0.03 0.93 1.0";
colors[1] = "0.2 0.03 0.93 1.0";
colors[2] = "0.2 0.03 0.93 0.0";
sizes[0] = 0.10;
sizes[1] = 0.10;
sizes[2] = 0.10;
times[0] = 0.0;
times[1] = 0.6;
times[2] = 1.0;
textureName = %mySpellDataPath @ "/vc/particles/diamond"; // diamondSparkle
};
datablock afxParticleEmitterDiscData(VC_Sparkle_E)
{
ejectionOffset = 0.5; //<- How far away from the center of the emitter the particles come out
ejectionPeriodMS = 2; // <- How many milliseconds between each particle
periodVarianceMS = 1; // <- ejectionPeriod = ejectionPeriod +- this
ejectionVelocity = 0.6; // <- Speed the particles are ejected at
velocityVariance = 0.3; // <- Variance of speed
particles = "VC_Diamond1_P VC_Diamond2_P"; // List of all the particles in the emitter
};
#5
Is this way supported in TGEA without AFX pack ?
06/05/2008 (3:32 am)
Quote:particles = "VC_Diamond1_P VC_Diamond2_P";
Is this way supported in TGEA without AFX pack ?
#6
06/05/2008 (4:15 am)
I think so, but I'm not 100% certain. I never worked with particles much until I bought AFX, so most of what I know about them is based on what I learned using AFX.
Torque Owner Nathan Kent
For the rain, you could just schedule somewhere in script to create a new rain object, deleting the old one. Something similar to:
$rain = new Precipitation(rain) { canSaveDynamicFields = "1"; position = "-389.274 514.971 54.6187"; rotation = "1 0 0 0"; scale = "1 1 1"; nameTag = "rain"; dataBlock = "LightRain"; minSpeed = "1.5"; maxSpeed = "2"; minMass = "0.75"; maxMass = "0.85"; maxTurbulence = "0.1"; turbulenceSpeed = "0.2"; rotateWithCamVel = "1"; useTurbulence = "0"; numDrops = "5000"; boxWidth = "200"; boxHeight = "100"; doCollision = "1"; }; schedule(5 * 60 * 100 /*5 Minutes*/, "nextRain"); function nextRain() { $rain.delete(); $rain = new Precipitation(rain) { canSaveDynamicFields = "1"; position = "-389.274 514.971 54.6187"; rotation = "1 0 0 0"; scale = "1 1 1"; nameTag = "rain"; dataBlock = "HeavyRain"; minSpeed = "1.5"; maxSpeed = "2"; minMass = "0.75"; maxMass = "0.85"; maxTurbulence = "0.1"; turbulenceSpeed = "0.2"; rotateWithCamVel = "1"; useTurbulence = "0"; numDrops = "50000"; boxWidth = "200"; boxHeight = "100"; doCollision = "1"; }; }