How create FOG?

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
FlashMX
Posts: 6
Joined: Fri Jul 21, 2006 5:54 pm

How create FOG?

Post by FlashMX »

Hello,

How can I produce fog for the whole world?
How can I color the fog?

I need this information for my mini game, will create a underwater world.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I've also been wondering something like this and the search tool doesn't like me sooo...someone please answer this soon =D
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

vitek wrote:Try IVideoDriver::setFog().

Code: Select all

   virtual void setFog (SColor color = SColor(0, 255, 255, 255),  
            bool  linearFog = true,  
            f32  start = 50.0f,  
            f32  end = 100.0f,  
            f32  density = 0.01f,  
            bool  pixelFog = false,  
            bool  rangeFog = false 
            )[pure virtual]
`pure' undeclared (first use this function)

I use dev-cpp I have everything included and I can't figure out how to fix this.

Have the lib linked and everything. (also searched the forums so no flaming on that note either.)
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

You don't copy and paste that entire code, that is API/documentation and will not compile.

To use fog in your code, you use:

Code: Select all

driver->setFog(SColor(0,255,255,255),true,50.0f,100.0f,0.01f,false,false);
Obviously changing the variables that need to be changed.

The documentation is to note what each parameter is for (fog color, fog start, end, etc.) and what the function may return if not void.

And did you try searching with your eyes open?

http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
Last edited by zeno60 on Sun Jul 30, 2006 7:36 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The function you want to call is called setFog(). It is an abstract method of the IVideoDriver interface. Being so, you need to call the function on an object of type IVideoDriver.

When you declare or define a function, you tell the compiler the type of each of the parameters. When you invoke a function, you do not specify the type of each of the parameters, you just specify the values.

If you have trouble understanding any of what I've said above, you should go find a basic C/C++ tutorial and learn the language _before_ you continue learning about Irrlicht any further. It will make your life as a programmer much easier.

And just because I know someone else will spoon feed you the answer as soon as I tell you to learn the language, I'm going to save them the time.

Code: Select all

// add camera
smgr->addCameraSceneNodeFPS();

ISceneNode* terrain = smgr->addTerrainSceneNode("media/terrain-heightmap.bmp");
terrain->setMaterialTexture(0, driver->getTexture("media/terrain-texture.jpg"));
terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true);
terrain->setScale(core::vector3df(10, 1, 10));

driver->setFog(video::SColor(32, 160, 192, 212), true, 100.f, 1000.f, .005f, false, true);
driver->setAmbientLight(video::SColorf(.3f, .3f, .3f, 1.f));
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

zeno60 wrote:You don't copy and paste that entire code, that is API/documentation and will not compile.

To use fog in your code, you use:

Code: Select all

driver->setFog(SColor(0,255,255,255),true,50.0f,100.0f,0.01f,false,false);
Obviously changing the variables that need to be changed.

The documentation is to note what each parameter is for (fog color, fog start, end, etc.) and what the function may return if not void.

And did you try searching with your eyes open?

http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog
http://irrlicht.sourceforge.net/phpBB2/ ... ght=setfog

Thanks much for the help...and sorry I'm half asleep and I was never any good with that search button :oops:
Spanky
Posts: 5
Joined: Wed Jul 20, 2005 1:10 pm

Post by Spanky »

Thanks Vitek! I've been struggling to figure out why my fog won't work and just seen that I've been missing this...

Code: Select all

terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true);
silly silly me.... :oops:
Of all the things i've lost, i miss my mind the most...
Post Reply