pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAME
pfLightModel, pfGetCurLModel - Create, modify and query lighting model
FUNCTION SPECIFICATION
#include <Performer/pr/pfLight.h>
pfLightModel::pfLightModel()
static pfType * pfLightModel::getClassType(void);
static void pfLightModel::apply(void);
void pfLightModel::setAtten(float a0, float a1, float a2);
void pfLightModel::getAtten(float *a0, float *a1,
float *a2);
void pfLightModel::setLocal(int l);
int pfLightModel::getLocal(void);
void pfLightModel::setTwoSide(int t);
int pfLightModel::getTwoSide(void);
void pfLightModel::setAmbient(float r, float g, float b);
void pfLightModel::getAmbient(float *r, float *g, float *b);
pfLightModel * pfGetCurLModel(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfLightModel is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfLightModel. 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);
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 pfLightModel can also be used with these
functions designed for objects of class pfMemory.
Page 1
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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
A pfLightModel defines characteristics of the hardware lighting model
used to illuminate geometry. See the OpenGL glLightModel(3g) man page
for more details on lighting environments and individual parameters.
new(arena) allocates a pfLightModel from the specified memory arena, or
from the process heap if arena is NULL. new allocates a pfLightModel
from the default memory arena (see pfGetSharedArena). Like other
pfObjects, pfLightModels cannot be created statically, automatically on
the stack or in arrays. pfLightModels should be deleted with pfDelete
rather than the delete operator.
pfLightModel::getClassType returns the pfType* for the class
pfLightModel. The pfType* returned by pfLightModel::getClassType is the
same as the pfType* returned by invoking the virtual function getType on
any instance of class pfLightModel. Because OpenGL Performer allows
subclassing of built-in types, when decisions are made based on the type
of an object, it is usually better to use the member function isOfType
to test if an object is of a type derived from a Performer type rather
than to test for strict equality of the pfType*'s.
pfLightModel::setAtten sets the lighting attenuation factors for the
pfLightModel. a1, a2, and a3 specify the constant, linear, and second-
order attenuation factors, respectively. These factors are associated
with all non-infinite lights. The default values for constant, linear,
and quadratic attenuation factors are 1.0, 0.0, and 0.0, respectively,
effectively disabling each. Note that OpenGL light attenuation is done
per-light. See the pfLight::setAtten man page for more information.
pfLightModel::getAtten copies the lighting attenuation factors for the
pfLightModel into the parameters a1, a2, and a3.
Page 2
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
pfLightModel::setLocal specifies whether the light reflection
calculations are to be done based on a local or infinite viewpoint. The
default is PF_OFF signifying an infinite viewer for the light model. In
general, local lighting is more expensive than infinite lighting.
pfLightModel::getLocal returns a boolean value signifying whether or not
the effective viewpoint in the pfLightModel is a local viewpoint.
pfLightModel::setTwoSide specifies whether two-sided lighting is to be
used in the given light model. The default is PF_OFF, disabling two-
sided lighting. See the OpenGL glLightModel man page for more details on
two-sided lighting.
pfLightModel::getTwoSide returns the setting of the pfLightModel's two-
sided lighting mode.
pfLightModel::setAmbient receives three floating point values in the
range from 0.0 through 1.0 to set the red, green, and blue, values for
the amount of the ambient light associated with the scene for the given
light model.
pfLightModel::getAmbient copies the red, green, and blue components of
the ambient in the given light model into the parameters r, g, and b,
respectively. The default value for the ambient red, green, and blue
light components is 0.2.
pfLightModel::apply causes the pfLightModel, with its current settings,
to become the current lighting model. When lighting is enabled (See
below), this lighting model will be applied to all geometry drawn after
pfLightModel::apply is called. Modifications to the pfLightModel, such
as changing the ambient color, or setting two-sided lighting, will not be
applied until pfLightModel::apply is called with the pfLightModel.
For geometry to be illuminated, the following must be true:
1. Lighting must be enabled: pfEnable(PFEN_LIGHTING)
2. A pfLightModel must be applied: pfLightModel::apply
3. A pfMaterial must be applied: pfMaterial::apply
4. One or more pfLights must be on: pfLight::on
5. Illuminated geometry must have normals: pfGeoSet::setAttr,
PFGS_NORMAL3
The lighting model state element is identified by the PFSTATE_LIGHTMODEL
token. Use this token with pfGeoState::setAttr to set the lighting model
of a pfGeoState and with pfOverride to override subsequent lighting model
changes.:
Page 3
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
EXAMPLES
Example 1:
lmodel->setTwoSide(PF_ON);
/* Set up two-sided lighting pfGeoState */
gstate->setMode(PFSTATE_ENLIGHTING, PF_ON);
gstate->setAttr(PFSTATE_LIGHTMODEL, lmodel);
gstate->setAttr(PFSTATE_FRONTMTL, mtl);
gstate->setAttr(PFSTATE_BACKMTL, mtl);
gstate->setMode(PFSTATE_CULLFACE, PF_OFF);
/* Attach gstate to gset */
gset->setGState(gstate);
/* Set normal array. 'gset' is non-indexed */
gset->setAttr(PFGS_NORMAL3, PFGS_PER_VERTEX, norms, NULL);
/* Draw lit, two-sided gset */
gset->draw();
Example 2:
lmodel->apply();
/* Override so that all geometry is lit with 'lmodel' */
pfOverride(PFSTATE_LIGHTMODEL, PF_ON);
pfLightModel::apply is a display-listable command. If a pfDispList has
been opened by pfDispList::open, pfLightModel::apply will not have
immediate effect but will be captured by the pfDispList and will only
have effect when that pfDispList is later drawn with pfDispList::draw.
pfGetCurLModel returns a pointer to the currently active pfLightModel, or
NULL if there is no active pfLightModel.
SEE ALSO
pfDelete, pfDispList, pfGeoState, pfLight, glLightModel, pfMaterial,
pfObject, pfState, lmbind, lmcolor, lmdef
Page 4