Now particle direction on a dynamic object

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Now particle direction on a dynamic object

Post by Yokom »

Lets say im sending particles out the tail pipe on a space fighter. Thanks to some help here i got this to work. Now when you turn the ship how do you map the direction the particles are being emmitted to the inverse of the ships heading.

I have the node set to be the child of the ship.
I have set a rotation of the node to the rotation of the ship in the run loop.

MySpaceShip.EngPartNode->setRotation(MySpaceShip.NodeShip->getRotation());

I dont see a command of the type

setParticleEmitterDirection(Node,vector3df());

So this leaves me a bit baffled on how this is going to get done since you drop the emitter after you set it right.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

irr::scene::SParticle::vector = (vector3df(0,0,-.1)

I was searching in the datafiles and found the struct that holds the emitter direction. I am attempting to alter it in this fashion, and getting the following error.

c:\Game\Code\Spaceflight\spaceflight.cpp(990): error C2597: illegal reference to non-static member 'irr::scene::SParticle::vector'

I tried to get to it with just irr::scene::Sparticle.vector =

That didnt work, im really not sure i can this type of alter on an irr struct.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

You're correct, the support is not in, however, I got it to work very easily by modifying the source. It's pretty simple, here's the files you need to update and the updates you need to make to them -

IParticleSystemSceneNode.h
IParticleEmitter.h
CParticlePointEmitter.h
CParticlePointEmitter.cpp
CParticleBoxEmitter.h
CParticleBoxEmitter.cpp
CParticleSystemSceneNode.h
CParticleSystemSceneNode.cpp

In - IParticleSystemSceneNode.h - add :

Code: Select all

virtual void setDirection(core::vector3df direction) = 0;
In - IParticleEmitter.h - add :

Code: Select all

virtual void setDirection(core::vector3df direction) = 0;
In - CParticlePointEmitter.h - add :

Code: Select all

virtual void setDirection(core::vector3df direction);
In - CParticlePointEmitter.cpp - add :

Code: Select all

void CParticlePointEmitter::setDirection(core::vector3df direction)
{
	Direction = direction;
}
In - CParticleBoxEmitter.h - add :

Code: Select all

virtual void setDirection(core::vector3df direction);
In - CParticleBoxEmitter.cpp - add :

Code: Select all

void CParticleBoxEmitter::setDirection(core::vector3df direction)
{
	Direction = direction;
}
In - CParticleSystemSceneNode.h - add :

Code: Select all

virtual void setDirection(core::vector3df direction);
In - CParticleSystemSceneNode.cpp - add:

Code: Select all

void CParticleSystemSceneNode::setDirection(core::vector3df direction)
{
	if ( Emitter )
		Emitter->setDirection ( direction );
}
If you need me to email you the files, or if you need any help with recompiling the Irrlict code so you can incorporate these changes into your project, let me know.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

Your a gem for the info Ill take a stab at the mod and let you know how it turned out.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

well snaged already. I loaded the source into vs c++ 2003.net and looked over it a bit. I had a thought to try to compile it the way it is now before i go jacking with it.

Ok it compiled first shot I sat shocked almost how well that went, no to test it. I loaded my project and swaped the dll files. I was thinking that now i should be able to see if it works. Ok the exe loaded fine and im off in my game and all is well. But now framerate has dumped from around 78 to 60 fps and the dll is 1.1 meg as the old one was only 880ish. I did a release build without debug info as that build really slows things down and puffs the dll up 2.6 meg.

So not sure if im compiling it correctly or the dll was out of date with the distrubition.

But ill try to roll with this and lookinto it later.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

Well the intelsense still isnt working in my project on this project thats a bit annoying but the good news is it works. I can set the direction of the particles in the routine where i make the emitter node. Now i just need to assign it to a class link list so i can operate on it in the run loop on different ships at once.

This should be fun.

Just wanted to let you and other know it worked well with this command

EngEmmitter->setDirection(vector3df(0,0.10,-0.06));

EngEmmitter is the pointer

scene::IParticleEmitter* EngEmmitter = MySpaceShip.EngPartNode->createPointEmitter(....options


Thanks for the help and hope others can make use of this. I can see it as a very usefull additions you can have people running around with paticle hair on fire and smoke rolling out of tail pipes or make a guy smoking a pipe with nice smoke coming off it for close in cut scenes.

Now on with the show.
Yokom
Post Reply