pfFog(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFog(3pf)NAME
pfFog, pfGetCurFog - Create, modify and query fog definition
FUNCTION SPECIFICATION
#include <Performer/pr/pfFog.h>
pfFog::pfFog()
static pfType * pfFog::getClassType(void);
void pfFog::setFogType(int type);
int pfFog::getFogType(void);
void pfFog::setColor(float r, float g, float b);
void pfFog::getColor(float *r, float *g, float *b);
void pfFog::setRange(float onset, float opaque);
void pfFog::getRange(float *onset, float *opaque);
void pfFog::setOffsets(float onset, float opaque);
void pfFog::getOffsets(float *onset, float *opaque);
void pfFog::setRamp(int points, float *range,
float *density, float bias);
void pfFog::getRamp(int *points, float *range,
float *density, float *bias);
float pfFog::getDensity(float range);
void pfFog::apply(void);
pfFog * pfGetCurFog(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfFog is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfFog. This is also true for
ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, void *arena);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
Page 1
pfFog(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFog(3pf)
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfFog can also be used with these functions
designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
pfFog is used to simulate atmospheric phenomena such as fog and haze and
for depthcueing. The fog color is blended with the color that is
computed for rendered geometry based on the geometry's range from the
eyepoint. Fog effects may be computed at geometric vertices and then
interpolated or computed precisely at each individual pixel.
new(arena) allocates a pfFog from the specified memory arena, or from the
process heap if arena is NULL. new allocates a pfFog from the default
memory arena (see pfGetSharedArena). Like other pfObjects, pfFogs cannot
be created statically, automatically on the stack or in arrays and should
be deleted with pfDelete rather than the delete operator.
pfFog::getClassType returns the pfType* for the class pfFog. The pfType*
returned by pfFog::getClassType is the same as the pfType* returned by
invoking the virtual function getType on any instance of class pfFog.
When decisions are made based on the type of an object, it is usually
better to use the member function isOfTypeto test if an object is of a
type derived from a Performer type rather than to test for strict
equality of the pfType*'s.
pfFog::setFogType sets the fog type to be used when this pfFog is
applied. type must be one of:
Page 2
pfFog(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFog(3pf)
PFFOG_VTX_LIN
PFFOG_VTX_EXP
PFFOG_VTX_EXP2
PFFOG_PIX_LIN
PFFOG_PIX_EXP
PFFOG_PIX_EXP2
PFFOG_PIX_SPLINE
Detailed descriptions of these fog types are in the OpenGL glFog(3G) man
pages, with the exception of PFFOG_PIX_SPLINE. This is an advanced fog
type that allows the user to define fog densities as a PFFOG_MAXPOINTS
point spline curve as described in pfFog::setRamp. When fog type
PFFOG_PIX_SPLINE is specified the internal fog ramp table will be
recomputed using the current values of fog range, fog offsets, and fog
ramp. The default fog type is PFFOG_PIX_EXP2. pfFog::getFogType returns
the fog type as its value.
pfFog::setColor specifies the color to be used as the fog blend color.
The default fog color is white, whose RGB value is [1.0, 1.0, 1.0].
pfFog::getColor returns the fog color in the variables specified.
pfFog::setRange sets the onset and opaque ranges in world coordinate
distances. The onset is the range at which fog blending first occurs.
The opaque range is the distance at which scene elements are completely
opaque and appear as the fog color. For the fog types PFFOG_VTX_EXP,
PFFOG_VTX_EXP2, PFFOG_PIX_EXP, PFFOG_PIX_EXP2 only the opaque range is
significant; the onset range is always 0.0 in world coordinates. If the
fog type is PFFOG_PIX_SPLINE then the internal fog ramp table will be
recomputed whenever the ranges are specified. pfFog::getRange returns
the current fog range values.
pfFog::setOffsets sets the individual onset and opaque range offsets used
to modify the fog range. These offsets are added to the fog range values
when the pfFog is applied. Calling this function with offsets of zero
causes the ranges defined by pfFog::setRange to be used directly. If the
fog type is PFFOG_PIX_SPLINE then the internal fog ramp table will be
recomputed whenever the offsets are specified. pfFog::getOffsets returns
the current fog offset values.
pfFog::setRamp defines the fog density curve using a table rather than as
an algebraic function of range. The fog ramp table is only used with the
PFFOG_PIX_SPLINE fog type. From four to PFFOG_MAXPOINTS control points
are used to describe this curve. If fewer than four control points are
given, the last point will be replicated to create four points. Each
point consists of a range and fog density pair. These are given in
ascending order in the arrays range and density. The range value is
specified in a normalized form in the numeric range [0..1], with 0.0
corresponding to the fog onset range (plus offset) and 1.0 the fog opaque
range (plus offset). This allows the ranges to be changed while
maintaining the same fog density curve. The fog density at each range
point must also be in the [0..1] range, where 1.0 represents no fog and
0.0 means opaque fog, using the OpenGL- style interpretation. A Catmull-
Page 3
pfFog(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFog(3pf)
Rom spline interpolation is used to create hardware fog tables from this
fog ramp table. If the fog type is PFFOG_PIX_SPLINE then the internal
fog ramp table will be recomputed whenever the fog ramp, fog range, or
fog offsets are specified. The default fog ramp table defines a linear
interpolation between the onset and opaque ranges. Currently, the bias
value must be set to zero. pfFog::getRamp returns the number of points,
range and density arrays, and bias in the variables specified.
pfFog::getDensity returns the density, ranging from 0 to 1 of the pfFog
at range range.
pfFog::apply configures the graphics hardware with the fog parameters
encapsulated by the pfFog. Only the most recently applied pfFog is
active although any number of pfFog definitions may be created. Fogging
must also be enabled (pfEnable(PFEN_FOG)) for this pfFog to take effect.
Modifications made to this pfFog do not have effect until pfFog::apply is
called. If a pfDispList has been opened by pfDispList::open,
pfFog::apply will be captured by the pfDispList and will only have effect
when that pfDispList is later drawn with pfDispList::draw.
The fog state element is identified by the PFSTATE_FOG token. Use this
token with pfGeoState::setAttr to set the fog mode of a pfGeoState and
with pfOverride to override subsequent fog changes:
Example 1:
/* Set up 'fogged' pfGeoState */
gstate->setMode(PFSTATE_ENFOG, PFFOG_ON);
gstate->setAttr(PFSTATE_FOG, fog);
/* Attach gstate to gset */
gset->setGState(gstate);
/* Draw fogged gset */
gset->draw();
Example 2:
/* Override so that all geometry is fogged with 'fog' */
pfEnable(PFEN_FOG);
fog->apply();
pfOverride(PFSTATE_FOG | PFSTATE_ENFOG, PF_ON);
pfGetCurFog returns the currently active pfFog.
Page 4
pfFog(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFog(3pf)NOTES
PFFOG_PIX_SPLINE and PFFOG_PTX* fog modes are not currently supported
under Linux.
PFFOG_PIX_SPLINE is only effective on InfiniteReality and RealityEngine
graphics systems. The visual quality of per-pixel fogging is influenced
by the ratio of the distances from the eye to the far and the eye to the
near clipping planes. This ratio should be minimized for best results.
BUGS
pfFog::getDensity does not properly evaluate PFFOG_PIX_SPLINE; instead it
linearly interpolates the spline points.
SEE ALSO
pfDispList, pfEnable, pfGeoState, pfObject, pfOverride, fogvertex,
lsetdepth, perspective, glFog
Page 5