Fog creation

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
databandit
Posts: 32
Joined: Tue Dec 21, 2004 11:36 am

Fog creation

Post by databandit »

hi,
can someone please give me some fog creation source code . . .
thanks


-zubair-
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

driver->setFog(...);

is enough, of course with the appropriated parameters (http://irrlicht.sourceforge.net/docu/cl ... r.html#a33)
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

YourNode->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

Try something like this.. :)
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

Dogs wrote:YourNode->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

Try something like this.. :)
Ok, sorry to jump in on this. I tried that and it crashed:

Code: Select all

// Fog
	irr::scene::IAnimatedMeshSceneNode* nodeFog; //Sets its node.
	nodeFog->setMaterialFlag(EMF_FOG_ENABLE,true); 
	driver->setFog(SColor(0,30,30,30),true, 0,1300); 
	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); 

No errors or anything, just, CRASH!
Image
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

Well you dont nead to create a fognode but rather add the fog to a node that you have allready...

For example when I add fog to my levels I chose something like my terrian or if its an inside level i chose the building and attach the fog to that node..
For example lets say I used a bsp for my level... the code is below..



//load bsp level//

device->getFileSystem()->addZipFileArchive("../../media/whatever.pk3");

scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/whatever.bsp");
scene::ISceneNode* node = 0;


if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));

// fog // Apply this to the node you want fog ///

node->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);


I dont know the rest of your code but there could be reasons like where you placed this code that would also cause crashes....
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

I was just browsing around and read over my post here and just saw that i made a mistake in my code..
Well its really not a mistake but could cause problems for sure..


driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);


This line here enables 32 bit textures and if this line is placed improperly in your code then it can cause crashes yes...

But I always use this line to enable 32 bit textuers as they look much much better...
Try it with your skyboxes... :)
Hijacker
Posts: 2
Joined: Wed Feb 16, 2005 5:47 am
Location: Kyiv

Post by Hijacker »

Dogs wrote: node->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
I`ve done something like that on my own. Result: NO FOG :(
Than I found this topic and use your code(adapted to my source)
The result is NO FOG!!!
The other code is just for application creation and loading 3ds model.
Could anybody explain that?
deprecated
Posts: 62
Joined: Fri Jan 07, 2005 4:37 pm
Location: California

Post by deprecated »

Using Linux, OpenGL, I have a similar problem...

Whenever I turn on fog, it only gets applied to the ground, basically as a % opacity of the chosen color.

So, in other words, everytime I turn fog on, the ground will turn grey (at 100% or so)

Used the examples on the forum with no luck... Can fog be used with heightmaps or just bsp and such? (which I dont use / havent tried...)

Anyone else have similar problems?
Post Reply