A SERVICE OF

logo

Using Fog in Scenes
95
In general whoever is OFF has precedence.
If csContext::fogEnable is OFF, no fog is drawn unless there is a csAppearance that
has fogEnable ON. In this case, fog is enabled for that shape only if it is within the
scope of a fog node that is turned on (that is, under a csEnvironment that has fog
enabled).
If the csFog node is OFF, there will be no fog drawn in any circumstances, even if
the fogEnable in the csAppearance or csContext is TRUE.
The fog description will affect all children of the csEnvironment. Subsequent csFog
nodes override the current fog description.
How to Use Fog
The following code fragments from the csFog manpage illustrates how to use of fog:
static csVec4f fogClr(0.2f, 0.2f, 0.2f, 1.0f);
<...>
// Create environment node for scene
csEnvironment *env = new csEnvironment;
// Add enabled fog node to environment
csFog* fog = new csFog;
fog->setOn(TRUE);
fog->setColor(fogClr);
fog->setEnd(400.0f);
fog->setMode(csFog::LINEAR_FOG);
env->setFog(fog);
// Enable fog for default state
ctx->setFogEnable(TRUE);
<...>
// In frame function
ctx->clear(csContext::COLOR_CLEAR | csContext::DEPTH_CLEAR,
fogClr[0], fogClr[1], fogClr[2], fogClr[3]);