setDirection() for particle-emitters

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

setDirection() for particle-emitters

Post by gfxstyler »

I used this to change the direction of the particles after the particle emitter was created (rain dropping according to wind-direction).

IParticleEmitter.h, line 63:

Code: Select all

	virtual void setDirection(const core::vector3df& direction) = 0;
CParticleBoxEmitter.h, line 47:

Code: Select all

	virtual void setDirection(const core::vector3df& direction);
CParticlePointEmitter.h, line 45:

Code: Select all

	virtual void setDirection(const core::vector3df& direction);

CParticlePointEmitter.cpp, line 29:

Code: Select all

void CParticlePointEmitter::setDirection(const core::vector3df& direction)
{
	Direction = direction;
}
CParticleBoxEmitter.cpp, line 29:

Code: Select all

void CParticleBoxEmitter::setDirection(const core::vector3df& direction)
{
	Direction = direction;
}
runelord
Posts: 13
Joined: Sat Jan 21, 2006 10:37 am

Post by runelord »

can we add this to the svn please? :)
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You can also do the same thing by writing your own IParticleAffector. The affector would just modify the vector member of each SParticle. The advantages of using the affector are that it will affect particles that were created previously, and you don't have to modify or recompile the Irrlicht library.

Travis
runelord
Posts: 13
Joined: Sat Jan 21, 2006 10:37 am

Post by runelord »

why cant we just add it to the SVN? There are only benefits from it and I cant think of any drawback.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

First off, we can't add anything to SVN. Second, all I did was propose an alternate way to do the same thing without having to make mods to your local copy of Irrlicht while waiting for it to be added. My way has an obvious downside in that it must iterate over every particle on every render, which can be costly.

But since you asked why this would be a bad thing... This are adding a public interface that changes the definition of what a IParticleEmitter actually is. Now it is implied that _all_ derived particle emitters send their particles off in a particular direction. From a design perspective that _might_ be a bad thing.

Travis
runelord
Posts: 13
Joined: Sat Jan 21, 2006 10:37 am

Post by runelord »

Sorry didnt mean to be rude, of course you cant just add anything to the SVN. :)

Lets me explain what I would need it for.
I have nice rolling waves, a nice ship that climbs them up and falls down on the other side. Whenever the ship hits the water volume I want it to cast clouds of spray in the air.
My way of doing that is by using particles. Now the deeper the ship penetrates the water surface, the bigger the spray.
As I'm going to implement this I have to change the force of the particles and thus change the direction vector.
Now I could use a nasty hack, by scaling its ParticleSceneNode to the desired length. But I think thats really really really really really really ugly and not very intuitive anyway.

Changing the direction vector directly on the emitter would give me more control over that and its more user friendly.
(although I think It'd be better split up in a normalized direction vector and a force value)

Affectors by the way are pretty static, too. All I can do on them is to enable or disable them.
I also can imagine a much bigger diversity on affectors than on emitters, so the interface to interactively modify the force and direction would be the emitters in my opinion. Any emitter that would not use the direction vector, should implement an empty method.

Maybe I'm wrong here, but I think that everyone, who seriously works with particles will sooner or later stumble across the problem to change the particle directions. Or is it just me who likes interaction?
kburkhart84
Posts: 277
Joined: Thu Dec 15, 2005 6:11 pm

Post by kburkhart84 »

I agree with you. In fact, I usually just recompile the engine myself with this change. I also add on a TurnOn/Off function to the emitters that I will use because that also isn't included, rather you have to delete/deattach and make a new one and attach it. I think my method that i add is better. Affectors are supposed to change the original vectors. Like smoke goes up originally, but wind(affector) moves it some direction. Rain drops are like that to. The main force doesn't change as much, but it can. If you have a dynamic body, like a space ship that emits particles, you can attach the emitter/particle system to the ship, and it rotates and moves on it's own. But if the system is by itself, there should be a way.
Post Reply