Using Fog in Scenes
93
// add the lights to the environment light array
park->light()->append(3, spot);
park->light()->append(4, flood);
Using Fog in Scenes
Fog is generated by setting up a csFog node and adding it to the csEnvironment. This
fog description will affect all children of the csEnvironment. Subsequent csFog nodes
will override the current fog description. Fog should also be globally enabled via
csContext::setFogEnable() and can be overridden with csAppearance::setFogEnable().
If csContext::FogEnable is FALSE, it is disabled for the entire scene graph (unless
overridden by csAppearance::fogEnable regardless of the value of csFog::on.
This section discusses the following fog-related topics:
•“Uses of Fog in Cosmo 3D Applications” explores the different uses for fog and
reasons for using it.
•“How to Use Fog in Cosmo 3D Applications” explains how to use fog in a Cosmo
3D application.
•“How to Use Fog” is a code fragment illustrating the information from the
preceding section.
Uses of Fog in Cosmo 3D Applications
Computer images sometimes seem unrealistically sharp and well defined. You can make
an entire image appear more natural by adding fog, which makes objects fade into the
distance. Fog is a general term that describes similar forms of atmospheric effects; it can
be used to simulate haze, mist, smoke, or pollution. Fog is essential in visual-simulation
applications, where limited visibility needs to be approximated. It is often incorporated
into flight-simulator displays.
When fog is enabled, objects that are farther from the viewpoint begin to fade into the fog
color. You can control the density of the fog, which determines the rate at which objects
fade as the distance increases, as well as the fog’s color. Since fog is applied after matrix
transformations, lighting, and texturing are performed, it affects transformed, lit, and
textured objects. Note that with large simulation programs, fog can improve
performance because you can choose not to draw objects that would be too fogged to be
visible.