Explosions - how to make them like i want them to be?

Explosions - how to make them like i want them to be?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Explosions - how to make them like i want them to be?

Post by Optimus Prime »

Hi

i read the explosion guide, but i still cant work with them like i want it.
I know its a new feature, so the guide isnt really complete, but i wonder why the examples in the guide work.

example:
[ARM_HLT_Expl]
{
[smoke]
{
[properties]
{
ageSpeed=0.04; // age increase per frame, when age >= 1 the particle is destroyed
size = 40;
sizeGrowth = -2;
pos = -30 r60, r30, -30 r60;
speed=0.75 r-1.5, 1.7 r1.6, 0.75 r-1.5;
}
water=1;
ground=1;
count=10;
}
}
and in the projectile.txt there is:
Class: CSmokeProjectile. Scriptname: smoke
color: float
size: float
startSize: float
sizeExpansion: float
ageSpeed: float
speed: float3
pos: float3
why can you use variables which arent used by this class? I tried my own explosions but i cant see them ig.
When i want to make an orange plasma xplosion, what must i use?
Is there anyone who can explain the new system a but more in detail?

I wanted to use this class for a plasmashot:
Class: CGfxProjectile. Scriptname: gfx
creationTime: int
lifeTime: int
color: uchar[4]
speed: float3
pos: float3
and wrote it in the explosions.tdf like this:
[PLASMAORANGE]
{
[gfx]
{
[properties]
{
creationTime: 2;
lifeTime: 20;
color: 1, 0.7, 0, 1; (the last is alpha right?)
speed: 0.75, 0.75, 0.75;
pos: 0, 0, 0;
}
[groundflash]
{
flashSize = 100;
flashAlpha = 1;
circleGrowth = 15;
circleAlpha = 1;
ttl = 12;
color = 1,0.7,0;
}
underwater=1;
air=1;
water=1;
ground=1;
count=10;
}
i also tried some other explosions, but i never can see them ig.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

The explosion system is very alpha indeed. Maybe a bit too much to use right now. The classes are directly linked to C++ projectile classes, and those C++ classes use different ways to store color/handle particle age/...
I'll add more documentation and classes sometime.

Btw, your [groundflash] section should not be in the [gfx] section.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Um, this looks like code that should work, per docs... but while the groundflash shows, the projectile doesn't. Any ideas, folks?

Code: Select all

[TEST_EXPLOSION]
{
	usedefaultexplosions=0;
[dirt]
{
	[properties]
	{
	alpha = 0.5;
	alphaFalloff = 0.0;
	size = 15;
	sizeExpansion = 1;
	slowdown = 0.1;
	color = 0.4,0.4,0.4;
	speed = 0 r5,5 r10,0 r5;
	pos = 0 r1,0 r5,0 r1;
	}
underwater=1;
air=1;
water=1;
ground=1;
count=20;
}
[groundflash]
	{
	flashSize = 100;
	flashAlpha = 1;
	circleGrowth = 15;
	circleAlpha = 1;
	ttl = 12;
	color = 1,0.7,0;
	}
underwater=1;
air=1;
water=1;
ground=1;
count=10;
}
User avatar
Optimus Prime
Posts: 755
Joined: 03 Oct 2005, 14:31

Post by Optimus Prime »

try defauktexplosions =1 should work.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Tested, and it works. Thanks for that Optimus, I guess "usedefaultexplosions=0" doesn't work yet, which is a pity, since I'd like to use custom graphics.

Problems are already surfacing, but I will be patient, and not list them yet.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

The following code does not run as described:

Code: Select all

[TEST_EXPLOSION]
{
usedefaultexplosions=1;
[gfx]
{
	[properties]
	{
	creationTime = 5;
	lifeTime = 40;
	color = 0, 0.8, 1, 0.8;
	speed = 0, 0, 0;
	pos = 0, 0, 0;
	}
ground=1;
count=15;
}
[dirt]
{
	[properties]
	{
	alpha = 0.5;
	alphaFalloff = 0.0;
	size = 15.0;
	sizeExpansion = 1.0;
	slowdown = 0.1;
	color = 0.4, 0.6, 0.4;
	speed = 0, 5, 0;
	pos = 0, 0, 0;
	}
ground=1;
count=15;
}
[groundflash]
	{
	flashSize = 100;
	flashAlpha = 1;
	circleGrowth = 15;
	circleAlpha = 1;
	ttl = 12;
	color = 0, 1, 0.7;
	}
underwater=1;
air=1;
water=1;
ground=1;
count=1;
}
Instead, it shows the default smokepuff. I know that I'm invoking the explosion correctly - the groundflash shows up. But the custom explosion is being overridden by the default one, and if I write it with the line usedefaultexplosions=1; set to boolean 0, then I just see a groundflash. Pretty frustrating, thus far- the groundflashes are pretty, but I'm trying to build all new particle FX, with zero results thus far. Something pretty basic must be wrong.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

What I really need to see, please, is a single example explosion generator that works, other than JC's iterator example, which does work as coded. I'm not terribly attracted to heatclouds, because I can't change their colors, so I immediately gravitated to the smoke, where I am allowed to play with such things... only to find that, thus far, they don't operate.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Went back to a simpler structure. Still doesn't work, period. No parse errors, no crashes, it just doesn't do anything.

Code: Select all

[TEST_EXPLOSION]
{
	usedefaultexplosions=0;
[dirt]
{
	[properties]
	{
	alpha = 0.5;
	alphaFalloff = 0.0;
	size = 15.0;
	sizeExpansion = 1.0;
	slowdown = 0.1;
	color = 0.4, 0.6, 0.4;
	speed = 0, 5, 0;
	pos = 0, 0, 0;
	}
}
underwater=1;
air=1;
water=1;
ground=1;
count=1;
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Noticed a problem with brackets. Fixed it, but it still doesn't work.

Code: Select all

[TEST_EXPLOSION]
{
[dirt]
	{
		[properties]
		{
		alpha = 0.5;
		alphaFalloff = 0.0;
		size = 15.0;
		sizeExpansion = 1.0;
		slowdown = 0.1;
		color = 0.4, 0.6, 0.4;
		speed = 0, 5, 0;
		pos = 0, 0, 0;
		}
	underwater=1;
	air=1;
	water=1;
	ground=1;
	count=1;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Put in the example smokepuff code, removed comment line. Works perfectly. The structure is IDENTICAL to my corrected-brackets version, above, but this one works. Are all of the projectiles in Projectiles.txt working, or did I make a mistake somewhere?

Code: Select all

[TEST_EXPLOSION]
{
	[smoke]
	{
		[properties]
		{
			ageSpeed=0.04;
			size = 40;
			sizeGrowth = -2;
			pos = -30 r60, r30, -30 r60;
			speed=0.75 r-1.5, 1.7 r1.6, 0.75 r-1.5;
		}
		water=1;
		ground=1;
		count=10;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Success, at last. This generates a nice big drifting cloud. With a quick groundflash and some sparky fire at the heart during the first 0.25 seconds or so, this could make a great artillery effect.

Code: Select all

[TEST_EXPLOSION]
{
	[smoke]
	{
		[properties]
		{
			color = 1;
			startSize = 5;
			sizeExpansion = 1;
			ageSpeed=0.01;
			size = 20;
			sizeGrowth = -2;
			pos = -30 r60, r30, -30 r60;
			speed=0.75 r-1.5, 1.7 r1.6, 0.75 r-1.5;
		}
		water=1;
		ground=1;
		count=10;
	}
}

The only problem is that this is the only Projectile class I've tested thus far that actually does what the specifications say it will. Now to test the others.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Tracer works, but it immediately showed me a severe problem with the way that the current code works.

Here's a working tracer:

Code: Select all

[TEST_EXPLOSION]
{
	[tracer]
	{
		[properties]
		{
			length = 45;
			pos = -30 r60, 30 r10, -30 r60;
			speed= 1 r6, 1 r6, 1 r6;
		}
		water=1;
		ground=1;
		count=15;
	}
}
What one will see is that all of the tracers are going generally towards the positive X and Y axis.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

So, to solve this problem, I tried a combined-FX... and found out that if you combine more than one of the same projectile class, the first one is the only one that appears to work :P

This makes it pretty much impossible to do nice spherical explosions, hemispheres, and other basic shapes- if I cannot call the same thing twice or more, and I cannot have multiple logical expressions or conditions for the motion-control, then that's a problem. Moreover, it's kind've hard to make a first-class FX if I can't combine a few tracers that lazily drift through the air with some really high-speed ones suggesting the force of the impact/explosion/whatever.

Code: Select all

[TEST_EXPLOSION]
{
	[smoke]
	{
		[properties]
		{
			color = 1;
			startSize = 5;
			sizeExpansion = 1;
			ageSpeed=0.01;
			size = 20;
			sizeGrowth = -2;
			pos = -30 r60, r30, -30 r60;
			speed=0.75 r-2, 1.4 r1, 0.75 r-2;
		}
		water=1;
		ground=1;
		count=4;
	}
	[tracer]
	{
		[properties]
		{
			length = 45;
			pos = -30 r60, 30 r10, -30 r60;
			speed= 1 r6, 1 r6, 1 r6;
		}
		water=1;
		ground=1;
		count=15;
	}
	[tracer]
	{
		[properties]
		{
			length = 45;
			pos = -30 r60, 30 r10, -30 r60;
			speed= 1 r-6, 1 r6, 1 r6;
		}
		water=1;
		ground=1;
		count=15;
	}
	[tracer]
	{
		[properties]
		{
			length = 45;
			pos = -30 r60, 30 r10, -30 r60;
			speed= 1 r-6, 1 r6, 1 r-6;
		}
		water=1;
		ground=1;
		count=15;
	}
	[tracer]
	{
		[properties]
		{
			length = 45;
			pos = -30 r60, 30 r10, -30 r60;
			speed= 1 r6, 1 r6, 1 r-6;
		}
		water=1;
		ground=1;
		count=15;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Smoke2 works. However, since I cannot control the base color, combine with with multiple Smoke2's for varied colors, or conditionally change from one RGB shade to another over the lifetime... it's basically useless. The number of things I can do with an off-yellow cloud ... pretty small.

And the fadeout does something very weird and ugly at the end of the lifetime, clearly showing the edges of the particle. Smoke looks like the refined version of Smoke2, really.

Code: Select all

[TEST_EXPLOSION]
{
	[smoke2]
	{
		[properties]
		{
			wantedPos = 0 r1, 35, 0 r1;
			glowFalloff = 0.02;
			color = 1;
			startSize = 5;
			sizeExpansion = 1;
			ageSpeed=0.03;
			size = 20;
			sizeGrowth = -2;
			pos = -30 r60, r30, -30 r60;
			speed=0.75 r-2, 1.4 r1, 0.75 r-2;
		}
		water=1;
		ground=1;
		count=4;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

GFX does not appear to work. Please show me working code if I am incorrect.

Code: Select all

[TEST_EXPLOSION]
{
	[gfx]
	{
		[properties]
		{
		creationTime = 0;
		lifeTime = 100;
		color = 1, 1, 1, 1;
		speed = 0, 0, 0;
		pos = 0, 0, 0;
		}
		water=1;
		ground=1;
		count=4;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Dirt does not appear to work, either. Again, show me working code if I am incorrect.

Code: Select all

[TEST_EXPLOSION]
{
	[dirt]
	{
		[properties]
		{
		alpha = 1;
		alphaFalloff = 0.01;
		size = 15;
		sizeExpansion = -1;
		slowdown = 1;
		color = 1, 1, 1;
		speed = 0, 0, 0;
		pos = 0, 0, 0;
		}
		water=1;
		ground=1;
		count=4;
	}
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Heatcloud works just fine. Try this one out, it's hilarious:

Code: Select all

[TEST_EXPLOSION]
{
	[heatcloud]
	{
		[properties]
		{
		heat = 5;
		maxheat = 10;
		heatFalloff = -1;
		size = 10;
		sizeGrowth = 1;
		sizemod = 1;
		sizemodmod = -1;
		speed = 1 r5, 1 r10, 1 r5;
		pos = 1 r2, 1 r5, 1, r2;
		}
		water=1;
		ground=1;
		count=4;
	}
}
Word
Posts: 80
Joined: 12 Jun 2006, 09:59

Post by Word »

some explosions are crazy...I had 2 hover transports loaded with rocket kbots (the ones from the advanced lab) and apparently my commander in one they got in a fight with an llt tower and I didn't really care to empty the transports (lol ) then the ground turned white and 3 seconds later that section of the map was GONE a huge crater going through the map was created...not sure if that's supposed to happen but it looked awsome. :D
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Overall, here are my comments after trying everything out:

Having all of these specialized classes of explosion behaviors is a perhaps necessary evil, but personally I think that we could simply have particle generators with two types of projection behavior, with a bunch of options, and get 99% of the things we actually need in a particle generator: a cone projector and a sphere projector. Both would need to be "stackable"- i.e., allowing more than one cone/sphere be defined as part of a projectile, but that's a given no matter where this goes- if I cannot stack more than one of a given effect, then this whole system has a really limited usefulness.

Why a cone and a sphere? Because that's about all you need, really. If you define a cone and then don't specify any random deviations from the cone's center vector, then you have a line. A sphere is there for messier explosions, and we could use multiple spheres with different properties to generate really complex, dynamic FX.

Then give us a few tools, such as allowing gravity/heat/friction to interplay with the initial force and vector applied to the particles... add in a few more basics, such as particle growth, decay, and color shifts, and voila... it's going to do almost everything we could possibly want.

The current system is a HUGE step towards that kind've simple, straightforward potentiality, but it's definately not there yet. I look forward to seeing what everybody else is able to get this code to do- my efforts here are mainly pretty primitive.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Um, anybody have any better luck, yet? Anybody gotten "dirt" or any of the other apparantly-broken ones working? I really wanted to try re-creating the current explosions, but with scalar controls and other things, but this isn't going anywhere.
Post Reply

Return to “Engine”