setFog Problem !!!

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
CaPGeti
Posts: 9
Joined: Tue Jul 01, 2008 8:41 am

setFog Problem !!!

Post by CaPGeti »

Hy....
How can I use fog for a .irr???
because, to get fog I enable EMF_FOG_ENABLE from a Mesh. But i have a scene!!!
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Walk through the scene from smgr->getRootNode() through all the children, and the children of the children etc. and turn on the fog for each node that requires it to be on.
Image Image Image
CaPGeti
Posts: 9
Joined: Tue Jul 01, 2008 8:41 am

Post by CaPGeti »

ah....sry for my english, but I come from germany. And i new in irrlicht.

How can I get the children?? Can you give me a example please? Sry but I don't know how I solve this.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

If you need to know something the API is your first port of call :)

If you look up ISceneNode you will find a function called getChildren which returns you a list of all the children so you iterate through each child and set the fog (if necessary) and then iterate through each of those child's children and keep repeating until you've done all the nodes, a recursive function is obviously the best way to achieve this.
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Code: Select all

void turnOnFog(scene::ISceneNode * node)
{
	switch(node->getType())
	{
		// Turn on fog for appropriate node types, casting as necessary

	default:
		// Do nothing
		break;
	}
}


// Recurses through all the scene nodes, and passes each one to a function that
// does whatever you want with it. To do different things to every node, just
// call this function with a different "action" function parameter.
void recurseThroughAllNodes(scene::ISceneNode * node, void(*action)(scene::ISceneNode *))
{
	action(node);

	core::list<scene::ISceneNode*> children = node->getChildren();
	core::list<scene::ISceneNode*>::Iterator childIterator = children.begin();
	core::list<scene::ISceneNode*>::Iterator end = children.end();

	while(childIterator != end)
	{
		recurseThroughAllNodes(*childIterator, action);
		childIterator++;
	}
}

//...
// Then kick it off from the root of the scene tree by calling..

recurseThroughAllNodes(smgr->getRootSceneNode(), turnOnFog);
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

I have a simple solution ;))

1. Open your irr file with notepad or vi

2. Replace

Code: Select all

<bool name="FogEnable" value="false" />
with

Code: Select all

<bool name="FogEnable" value="true" />
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Oh, well, if you want to do it the easy way, then I suppose that's fine. :P

Actually, being serious, I doubt that you'd want to switch on fog for all materials, which is why there's a switch() in the sample code above.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply