Flare Effect With Smoke Trail
by Francisco Montanes · 05/16/2013 (9:59 am) · 15 comments
This is a flare effect for aircrafts.
Quoting Mack:
"Projectile that has a light attached to it (with lens flare properties)"
Quoting Michael Hall:
"A low velocity ballistic (with low gravityMod) projectile with a light and particle trail..."
This resource comes from a thread in forum I started because I needed advice about how to implement this effect.
Finally I decided to make a resource to share with all of you.
The fireworks:
flares.cs file
Deploying Flares...
I had to make a change in source code, because Projectile class doesn't have drag effect when is ballistic, witch may be some times usefull.
In Projectile::simulate( F32 dt )
I've added a new field 'dragCoeffiecient' in ProjectileData.
Any comments will be very welcome. Really.
Thank you all that helped me in forum!!
Francisco
Quoting Mack:
"Projectile that has a light attached to it (with lens flare properties)"
Quoting Michael Hall:
"A low velocity ballistic (with low gravityMod) projectile with a light and particle trail..."
This resource comes from a thread in forum I started because I needed advice about how to implement this effect.
Finally I decided to make a resource to share with all of you.
The fireworks:
flares.cs file
function execFlares(){
exec("./flares.cs");
}
datablock ParticleData(FlareSmokeParticle)
{
textureName = "art/shapes/particles/smoke";
dragCoeffiecient = 100.5;
gravityCoefficient = -0.01;
inheritedVelFactor = 0.1;
lifetimeMS = 16000;
lifetimeVarianceMS = 150;
useInvAlpha = true;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "1 1 1 0.8";
colors[1] = "1 1 1 0.2";
colors[2] = "1 1 1 0.0";
sizes[0] = 4;
sizes[1] = 16;
sizes[2] = 32;
times[0] = 0.0;
times[1] = 0.75;
times[2] = 1.0;
};
datablock ParticleEmitterData(FlareSmokeEmitter)
{
ejectionPeriodMS = 20;
periodVarianceMS = 0;
ejectionVelocity = 1;
velocityVariance = 0.3;
thetaMin = 0.0;
thetaMax = 150;
particles = "FlareSmokeParticle";
softnessDistance = "0";
blendStyle = "NORMAL";
softParticles = "0";
};
datablock ProjectileData(FlareProjectile)
{
projectileShapeName = "art/shapes/weapons/weapon_AAMissile/AIM9_projectile.dts";
directDamage = 0;
radiusDamage = 0;
damageRadius = 0;
explosion = GrenadeLauncherExplosion;
particleEmitter = FlareSmokeEmitter;
splash = BulletSplash;
sound = MissileFlightSound;
isGuided = false;
explosionTolerance = 8;
precision = 80;
trackDelay = 40;
trackingAngle = 70;
seekRadius = 900;
velInheritFactor = 1;
armingDelay = 55000;
lifetime = 15000;
fadeDelay = 15000;
isBallistic = true;
gravityMod = 0.20;
dragCoeffiecient = 0.2;
explodeOnExplodeTime = true;
muzzleVelocity = 50;
proximityRadius = 3;
hasLight = false;
lightRadius = 3.0;
lightColor = "1 1 0";
};
function FlareProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
}
datablock LightFlareData( AircraftLightFlare )
{
overallScale = 1.0;
flareEnabled = true;
renderReflectPass = true;
flareTexture = "core/art/special/lensFlareSheet0";
elementRect[0] = "0 512 512 512";
elementDist[0] = 0.0;
elementScale[0] = 10.5;
elementTint[0] = "1.0 1.0 1.0";
elementRotate[0] = true;
elementUseLightColor[0] = false;
elementRect[1] = "512 0 512 512";
elementDist[1] = 0.0;
elementScale[1] = 20.0;
elementTint[1] = "0.5 0.5 0.5";
elementRotate[1] = false;
elementUseLightColor[1] = false;
};
//-----------------------------------------------------------------------------
function dropFlare(%obj)
{
%slot = 2;
%muzzlePoint = %obj.getMuzzlePoint(%slot);
//%objectVelocity = VectorScale(%obj.getVelocity(), 1.2);
%objectVelocity = %obj.getVelocity();
%objectVelocity = VectorAdd(%objectVelocity, getRandom(-10,10) SPC getRandom(-10,10) SPC 0);
%p = new Projectile() {
dataBlock = FlareProjectile;
initialVelocity = %objectVelocity;
initialPosition = %muzzlePoint;
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
target = -1;
};
MissionCleanup.add(%p);
%light = new PointLight() {
radius = "500";
isEnabled = "1";
color = "1 1 1 1";
brightness = "0.2";
castShadows = "0";
priority = "1";
animate = "0";
animationPeriod = "1";
animationPhase = "1";
flareType = "AircraftLightFlare";
flareScale = "2";
attenuationRatio = "0 1 1";
shadowType = "DualParaboloidSinglePass";
texSize = "512";
overDarkFactor = "2000 1000 500 100";
shadowDistance = "400";
shadowSoftness = "0.15";
numSplits = "1";
logWeight = "0.91";
fadeStartDistance = "0";
lastSplitTerrainOnly = "0";
representedInLightmap = "0";
shadowDarkenColor = "0 0 0 -1";
includeLightmappedGeometryInShadow = "0";
position = %obj.getMuzzlePoint(%slot);
rotation = "1 0 0 0";
canSave = "1";
canSaveDynamicFields = "1";
};
MissionCleanup.add(%light);
%p.mountObject(%light, 0, "0 0 0");
%p.schedule(8000, "delete");
%light.schedule(8000, "delete");
return %p;
}Deploying Flares...
function aiAircraftVehicle::dropFlare(%this)
{
%num = getRandom(1,3);
for(%i = 0; %i<%num; %i++)
%obj = dropFlare(%this, 1);
%this.schedule(getRandom(2000,3000), "dropFlare");
}I had to make a change in source code, because Projectile class doesn't have drag effect when is ballistic, witch may be some times usefull.
In Projectile::simulate( F32 dt )
if ( mDataBlock->isBallistic ){
mCurrVelocity.z -= 9.81 * mDataBlock->gravityMod * dt;
mCurrVelocity -= mCurrVelocity * mDataBlock->dragCoeffiecient * dt;
}I've added a new field 'dragCoeffiecient' in ProjectileData.
addField("dragCoeffiecient", TypeF32, Offset(dragCoeffiecient, ProjectileData ),
"@brief dragCoeffiecient on the projectile.nn"
"The larger this value is, the more that drag will affect the projectile. ");Any comments will be very welcome. Really.
Thank you all that helped me in forum!!
Francisco
About the author
Hello, I'm electronics engineer working in simulation for Adaptive Systems S.A. (Spain) http://www.adaptive.es/en/
Recent Blogs
#2
05/16/2013 (11:18 am)
I agree pretty sweet
#3
05/16/2013 (11:21 am)
looks pretty realistic, nice :-)
#4
05/16/2013 (1:36 pm)
This is sweet! Thanks for sharing, Francisco.
#5
05/16/2013 (2:22 pm)
Looks fantastic. Now I want aeroplanes dropping flares in my game...
#6
05/16/2013 (4:37 pm)
Very cool effect! I will try and think of how I can use this :-)
#7
05/16/2013 (5:46 pm)
Looks great Francisco, good job :)
#9
05/17/2013 (3:05 am)
Nice effect ! Thanks for sharing.
#10
Very clever use of projectiles, light, lightflares and particles!
05/17/2013 (3:38 am)
Looks fragging awesome! Great job!Very clever use of projectiles, light, lightflares and particles!
#11
05/17/2013 (4:16 am)
That loos really nice. Did you find it hard trying to get this setup? Every time i look at partials i get flustered...
#12
05/17/2013 (4:48 am)
Definitely Yes... Everytime I'm involved in a "artistic" work, I despair a little. In fact, this is one of the hundred versions that I really don't hate too much. :)
#13
One ommission:
Projectile.h after gravity mod declaration:
/// dragCoeffiecient on the projectile
F32 dragCoeffiecient;
05/21/2013 (10:54 pm)
Muchimas Gracias!One ommission:
Projectile.h after gravity mod declaration:
/// dragCoeffiecient on the projectile
F32 dragCoeffiecient;
#14
Er... my bad.... Other omissions:
in ProjectileData::ProjectileData() add
in void ProjectileData::packData(BitStream* stream) add
in void ProjectileData::unpackData(BitStream* stream) add
05/22/2013 (1:26 am)
De nada tio!Er... my bad.... Other omissions:
in ProjectileData::ProjectileData() add
++ dragCoeffiecient = 0;
in void ProjectileData::packData(BitStream* stream) add
stream->write(gravityMod);
++ stream->write(dragCoeffiecient);
stream->write(bounceElasticity);in void ProjectileData::unpackData(BitStream* stream) add
stream->read(&gravityMod);
++ stream->read(&dragCoeffiecient);
stream->read(&bounceElasticity);
#15
06/08/2013 (10:32 pm)
wow,that is coooooooooooooooooooooooooooooooooool~~ 
Torque Owner Adam Beer
Ignition Games Inc.