CSimpleParticleSystem(tests, sample code when it works)

CSimpleParticleSystem(tests, sample code when it works)

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
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

CSimpleParticleSystem(tests, sample code when it works)

Post by Argh »

Tested. Haven't been able to get it to work, yet. Anybody been able to? Using the latest build from buildbot, of course- the following makes Spring crash:

Code: Select all

[particlesystem_TRIROOKGUN_FX01]
   		{
		class=CSimpleParticleSystem;
      		[properties]
      		{
		emitVector=0 1 0;
		gravity=0 0 0;
		colorMap=1.0 1.0 1.0 1.0   1.0 1.0 1.0 1.0;
		AtlasedTexture=LightningStrike_Alpha;
		airdrag=1.0;
		particleLife=60;
		particleLifeSpread=10;
		numParticles=45;
		particleSpeed=3;
		particleSpeedSpread=1;
		particleSize=5;
		particleSizeSpread=r2;
		emitRot=20;
		emitRotSpread=10;
		directional=1;
      		}
	air=1;
      	water=1;
      	ground=1;
      	count=1;
	}
Previous attempts didn't crash... they just didn't work. Do the Float3's require commas, like all of the other ExplosionGenerator code does?
Last edited by Argh on 02 Nov 2006, 09:54, edited 1 time in total.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Found a small error, tried another variant, with commas, still crashed:

Code: Select all

[particlesystem_TRIROOKGUN_FX01]
   		{
		class=CSimpleParticleSystem;
      		[properties]
      		{
		emitVector=0, 1, 0;
		gravity=0, 0, 0;
		colorMap=1.0 1.0 1.0 1.0   1.0 1.0 1.0 1.0;
		AtlasedTexture=LightningStrike_Alpha;
		airdrag=1.0;
		particleLife=60;
		particleLifeSpread=10;
		numParticles=45;
		particleSpeed=3;
		particleSpeedSpread=1;
		particleSize=5;
		particleSizeSpread=2;
		emitRot=20;
		emitRotSpread=10;
		directional=1;
      		}
	air=1;
      	water=1;
      	ground=1;
      	count=1;
	}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

At last, success! Now, to build something that doesn't look terrible ;)

Code: Select all

[particlesystem_TRIROOKGUN_FX01]
   		{
		class=CSimpleParticleSystem;
      		[properties]
      		{
		emitVector=0 1 0;
		gravity=0 0 0;
		colorMap=1.0 1.0 1.0 1.0   1.0 1.0 1.0 1.0;
		Texture=LightningStrike_Alpha.tga;
		airdrag=1.0;
		particleLife=60;
		particleLifeSpread=10;
		numParticles=45;
		particleSpeed=3;
		particleSpeedSpread=1;
		particleSize=5;
		particleSizeSpread=2;
		emitRot=20;
		emitRotSpread=10;
		directional=1;
      		}
	air=1;
      	water=1;
      	ground=1;
      	count=1;
	}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Well, it's working, and I'm getting the hang of things. No pretty screenshots yet, though.

And a few things are immediately annoying. I know this is going to sound like whining, but meh... I'd rather whine now, while the code's still very young, then whine later when it'd be too much of a pain to change it.

1. I hate the Vector system. I hated it when it was used to restrict the aim of weapons. I really hate it now. Is it that much harder to simply specify the cone like this?

ConeAngleX
ConeAngleZ
ConeAngleY
ConeWidth
ConeWidthSpread

This isn't hard to turn back into a cone, but it's a LOT EASIER to work with, conceptually speaking, for the vast majority of content developers. If I have the following values:

ConeAngleX=0;
ConeAngleZ=0;
ConeAngleY=0;
ConeWidth=90;
ConeWidthSpread=45;

Then I have a cone that points straight up, has a default angle of 90 degrees, which can be as much as 135 degrees. Simple... straightforward, easy to think about, for anybody who has done any 3D modeling :P Turning it back into a vector isn't much math, either.

Pleeeeeeease make this less painful. The current system is almost totally the inverse of how I'd design it, because it's very hard to get the results at all right... without doing a chunk of trig.


2. There needs to be some sort've time-delay available, so that we don't have to use multiples of the same system to get a longer-term spew of particles. IOW, I should be able to specify some values like: "SpawnAmount=10" and "SpawnDelay=10" and every 10 ticks, we'd see another spawn of the same particle event, until 10 Spawns had passed. Trust me... I keep going on and on about timing of events because it's really important. Not having it means that this is pretty much limited to very fast, simple events, because who wants a slow event without event timing controls?

3. I see it forming rings, not really random distributions within the cone. It's following the cone sides, but is not distributing particles in lesser angles properly. Which is great, if I wanted rings, but I want vectored cones that are random within the cone, that I can then apply the other factors to.

4. Because of the use of the Vector system and the fact that Spread operates in a 0-to-variable fashion, it's impossible to have cones that grow evenly all the way around with random variables. Which, in my opinion, makes having the ConeSpread variable completely pointless. Here, let me make a picture of what I think most people are going to want, as opposed to what it does:

Image

This is how a cone defined (let's for the sake of argument, stick with your TDF declarations) as the following should look, if it has the following parameters:

emitVector=0 1 0;
emitRot=90;

See? Instead of rotating the vector 90 degrees from 0, which is what it does now, it splits the difference, giving us a 90 degree cone centered on the desired vector. This is how it should've been done with the weapon aiming-arc stuff, and this isn't any better.

Next, let's look at emitRotSpread. What we should get is something like this, if given a value of 30:

Image

Which is not at all what we are currently getting :(

5. Last but not least, at least thus far the alpha doesn't seem to work... and AtlasedTexture seems to be the line that causes the crash. And just plain "texturename" doesn't work- I have to append a filename, which means it's not looking in AtlasedTexture properly yet. So, no pretty fireworks yet.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Also, we need a Pos TDF tag, just like the other ExplosionGenerators. We're not going to want all of these to be centered on the impact, for various reasons. For example, with this code as written, I can now make half-spheres and true spheres quite easily- this is great. However, I'll frequently want them to be at positions offset XYZ, with random outcomes... if I had that and timers, I could rebuild the Nuke with quite a bit less code and quite a bit more awesomeness. Trust me... if you get this darn thing to work the way I'm asking for, it will be worth it in terms of added eye-candy ;)
Yeha
Posts: 96
Joined: 13 Aug 2004, 19:12

Post by Yeha »

This is how it currently works; The emitVector describes a direction for the top of a sphere, with no rotation the particles are emmited in this direction.

With an added rotation of 45 degree from emitRot the particles will be emitted along a thin circle on the sphere, 45 degrees from the emitVector.
Image


The emitRotSpread then gives an allowed spread for the rotation, a emitRot of 45 degree and emitRotSpread of 45 degree would emmit particles along the green band like this:
Image


emitRotSpread of 180 will give you a full circle, 90 a hemmisphere and so on, emitRot is only used to offset the rotation.

The largest reason to have a vector to describe the direction is that everything internally is described by vectors, like the direction vector passed to the explosiongenerator. Say for an example you want a ring of smoke around the barrel when a unit fires, setting emitVector to dir and emitRot to 90 (so the particles are spawned perpendicular to emmitVector) gives you something like this
Image

There allready is a pos tag, just missed it in the documentation.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Hmm. It appears that I'm wrong, and should stop whining. It's not that your vector system doesn't make perfect sense- it's that it has a bug, and that's why my attempts to get it to work kept coming out wrong.

I kept wondering why my particle orientations weren't coming out right, and was getting really frustrated... now I know what's really wrong- it's that the resulting vector is not right- the code works just fine, aside from that part. Should be easily fixed.

Here's s'more code, and a screenshot. I think it may just be buggy- it's clearly emitting at a 45-degree angle in this shot, which is not what the code is calling for. So, maybe it's not that I don't properly understand what you're saying- it's just not working right.

Code: Select all

[particlesystem_TRIROOKGUN_FX01]
	{
		class=CSimpleParticleSystem;
		[properties]
		{
		emitVector=0 1 0;
		gravity=0 0 0;
		colorMap=1.0 1.0 1.0 1.0       1.0 1.0 1.0 0.1.0;
		Texture=circularthingy;
		airdrag=1.0;
		particleLife=60;
		particleLifeSpread=10;
		numParticles=45;
		particleSpeed=3;
		particleSpeedSpread=1;
		particleSize=1;
		particleSizeSpread=2;
		emitRot=0;
		emitRotSpread=0;
		directional=0;
		}
	air=1;
	water=1;
	ground=1;
	count=1;
	}
Screen:

Image

Another screen, very clearly showing that this is a 45 degree angle.

Image


So, that was my problem all along :oops: Please fix this bug, so that I can get my awesome showers of rubble, towering columns of flame and other tricky things working right...
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

That codes makes spring crash for me (1.0 1.0 1.0 0.1.0; <-- there's a .0 too much, I guess you meant 0.01). Also the nightlies crash as well as soon as players spawn. :(

Nevermind, fixed it. :oops:
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo »

Say, yeha, that smoke ejection from the cannon looks really awesome. Can you post the script you use to make it?

Also, the smoke is white. Is that definable in the SFX script or are you using some special image for it?
Yeha
Posts: 96
Joined: 13 Aug 2004, 19:12

Post by Yeha »

Argh:
A float 3 in explosiongenerator needs to be separated by commas, your emitVector should look like this: emitVector=0,1,0;.
The colormap however should be separated by spaces, i should probably change so they use the same separator, i guess its a little confusing currently.

And please do continue with the nagging, its allways helpfull to get sugestions for changes and improvements :)


PauloMorfeo:
Unit script and modell is from rattle, the explosion script looks like this

Code: Select all

[properties]
		{
			emitVector =dir;
			gravity =0,0,0;
			colorMap=1 1 1 0.01 0 0 0 0.01;
			texture =circularthingy;
			airdrag = 0.95;
			particleLife = 40;
			particleLifeSpread = 30;
			numParticles = 200;
			particleSpeed =0.2;
			particleSpeedSpread=0.5;
			particleSize = 1;
			particleSizeSpread = 1;
			emitRot = 90;
			emitRotSpread = 0;
			directional = 1;

		}
The smoke is white because it uses the circularthingy texture which is white and allso define a white color in the colormap, but you can get any color via the colormap and texture.
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

Looks like we are gunna have better effects than warcraft 3, and plenty of other games :twisted:
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Ok, almost ready to distribute some seriously-cool code examples. Following Yeha's advice, I got the darn thing working, and I've been hacking up a modified Nuke sequence that's really cool, among other things.

Before I go to bed, I'd like to make two requests for SimpleParticleSystem:

1. I'd like a size-control-over-time, like we have with HeatCloud. This would allow for a lot of visual FX to be possible that just aren't practical at the moment. SimpleParticleSystem, now that I know what I'm doing, is great, because it isn't using a box, but lacking a size control to make things gradually shrink/grow (preferably with randomizers, just like HeatCloud) means there are a lot of things that I can't make look quite right. I have, for example, some multiple-puff explosions, where the smoke parts should expand as they move outwards, and they look very fake because they can't grow. I could fake it by using multiple generators, of course, but I'd rather not- my objective is to get the best looks with the fewest lines of code I can.

2. Is there maybe some way (preferably through ColorMap) that I can make a particle gracefully disappear? I have a few FX (mainly with the Nuke, since it's big, very complex, and slow) where pop-out is very obvious and ugly. I'd really like to see dying particles fade out a little more gracefully- even a half-second fade that's standardized for speed's sake would be fine imo. If there's a way to get this done through ColorMap, please let me know- I've tried various things, and it doesn't seem to work the way I need it to.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Argh wrote:2. Is there maybe some way (preferably through ColorMap) that I can make a particle gracefully disappear? I have a few FX (mainly with the Nuke, since it's big, very complex, and slow) where pop-out is very obvious and ugly. I'd really like to see dying particles fade out a little more gracefully- even a half-second fade that's standardized for speed's sake would be fine imo. If there's a way to get this done through ColorMap, please let me know- I've tried various things, and it doesn't seem to work the way I need it to.
If I recall correctly from my testing with the flamethrower ColorMap, yes. Since the blending is done via this formula: src_color + dst_color * (1-src_alpha), you can make stuff fade out smoothly by adding an entry with a black color and an almost 0 alpha to the end of the ColorMap:

Code: Select all

...  0 0 0 0.01
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

/me knew that before. 8)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

I have almost gotten done coding the "new nuke". Quite a bit shorter, and it uses nothing but variants on CSimpleParticleSystem. I'll share the source for it and other things soon- I came down with a rather severe cold over my "weekend", which is why I haven't released it yet, but I'll post up my current stuff when I get home tonight aside from the Nuke, which isn't quite where I need it to be ... yet.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Added sizeGrowth and sizeMod to SimpleParticleSystem.
Added DelaySpawner.
Muahahahah....

Oh yeah, and Yeha... thanks... this is going to make some really incredible stuff possible.... trust me on this...
Last edited by Argh on 08 Nov 2006, 01:50, edited 1 time in total.
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

Snipawolf wrote:Looks like we are gunna have better effects than any other up to date game. :twisted:
I corrected it :wink:

Good job everyone, Spring is soaring :-)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

I'm having some z-buffer issues with this system- particles seem to not be drawn in front of each other quite right. You can clearly see it in this shot- it's annoying, trust me :P

That said... with the addition of size modifiers and a timer... well, this early WIP should speak for itself.

Image

It has a lot of flaws, so I am not releasing sourcecode yet. But- good news for all you nuke-lovers out there... this one will scale very easily.
User avatar
NOiZE
Balanced Annihilation Developer
Posts: 3984
Joined: 28 Apr 2005, 19:29

Post by NOiZE »

:shock: :shock: :shock:
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Needs more randomness and driftyness, but :shock: :shock: :shock: indeed
Post Reply

Return to “Engine”