removing the parent of a node with particle system attached

Problems building or running the engine, queries about how to use features etc.
Post Reply
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

removing the parent of a node with particle system attached

Post by Yokom »

Code: Select all

	switch (ParticleType)
		{
		case 1:
			if (pnc3 == 9) {
				pnc3 = 0;
				}
			if (pNode3[pnc3]->getParent()->getName() != "root node")
				{
				pNode3[pnc3]->getParentSceneNode()->removeChild(pNode3[pnc3]->getName());
				}
			pParent->addChild(pNode3[pnc3]);
			pNode3[pnc3]->setPosition(Offset);
			pNode3[pnc3]->setDirection(Direction);

			pEmitter3[pnc3]->setDuration(Duration);
			pEmitter3[pnc3]->setEnabled(true);
			pnc3++;
			return true;
			break;
In this code i have 10 particle systems that can be used in different places and by different ships its a generic particle operation. It works fine for the first 10 objects then when i remove the scenenode and add it to another object the particles dont show. Now the odd thing to keep in mind is the last node the particle scenenode was attached to still can exist and has just been setvisable false or may still be in use, either could be the case as I have alot more bullet nodes in the bullet pool then i have particle system due to the overhead on the particle systems.

The idea is this effect is non critical and can be robbed from one place to another as when bullet get farenough from the firing ship it isnt important to keep the effects on it but to move them to the new bullets being fired.

But to the problem at hand the code still runs fine (well doesnt crash) and the bullets still fire and collide fine but after the first ten bullets the particls shut are not visable.

I have attempted to reattach the particle system when i remove the node from the parent (the bullet) but that crashes as it has the particle system attached. I have tried to refresh the emitter pointer still doesnt work.

Im kinda at a lose for why i cant remove and readd a node and keep the particle system running.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

If you called setVisible(false) on the node before detaching the particle system, the particle system will itself still be hidden. setVisible on a node is simply a shortcut for setting the visibility flag on the attached objects, it isn't a property of the node. This is made clear in the API docs.
Yokom
Halfling
Posts: 88
Joined: Tue Nov 30, 2004 2:34 am

Post by Yokom »

cool i was so involved in tracking the data of the nodes and if they were moving correctly i was just looking right past what was obvious.

Thanks Sinbad for being the understanding person you are and thanks again for all your work.

now where do i buy the ogre coffee mugs again.


edit

Man i didnt know you had the cool sweatshirts with hoods i had to have one for when im coding on cold nights in pajama pants.
Post Reply