Provides simple API for adding shadows to any scene object. Shadow Manager has methods to add lights and scene objects for which shadows should be created. Automatically handles lights or objects movements and shape changes of shadow casting objects.
Compilation note: Must be linked with glu32.lib opengl32.lib.
Definition at line 96 of file ShadowManager.h.
Public Types | |
enum | SCENE_TYPE { SHADOWS = 0, SCENE = 1 } |
Enumeration of showed scene types. More... | |
Public Member Functions | |
CShadowManager (SoSeparator *sr, SoEnvironment *env) | |
Constructor. | |
~CShadowManager () | |
Destructor. | |
void | setSceneType (enum CShadowManager::SCENE_TYPE type) |
Sets which type of scene will be shown. | |
enum TShadowAlgorithm * | getAlgorithm () |
Get shadow volumes computing algorithm. | |
void | method2algorithm () |
Set shadow algorithm according to the chosen method. | |
void | setManager (TShadowSettings *s) |
Set up whole shadow manager settings in one step. | |
const struct TShadowSettings * | readSettings () |
Read shadow manager settings. | |
void | setMethod (enum TShadowMethod newMethod) |
Set shadow computation method. | |
void | setSVDepth (float newfDepth) |
Set shadow volumes depth. | |
void | printSettings () |
Print shadow manager's settings. | |
void | enableSensors () |
Enable objects' sensors. | |
void | disableSensors () |
Disable objects' sensors. | |
void | createShadows () |
Recompute shadow volumes for all objects and all lights. | |
void | createCasterVolumes (int index) |
Re-computes shadow volumes of a selected caster. | |
SoSeparator * | getSceneRoot () |
Returns the root node of the user's scene. | |
SoSeparator * | getShadowSceneRoot () |
Returns the root node of the user scene with shadows. | |
SoEnvironment * | getEnvironmentNode () |
Get environment node registered in Shadow Manager. | |
void | setAmbientIntensity (float val) |
Sets global ambient light intensity. | |
void | addLight (SoLight *light) |
Adds a new light to the scene light manager. | |
void | removeLight (SoLight *light) |
Removes light from Shadow Manager and deletes all shadows that are cast by this light. | |
void | addObject (SoSeparator *object) |
Adds a new object to the scene object manager. | |
void | removeObject (SoSeparator *object) |
Removes the first occurence of the object from Shadow Manager. | |
void | createObjectsShadows (SoSeparator *object) |
Forces recomputation of shadows of an object. | |
void | export (const char *filename) |
Export shadow scene graph into a file. | |
Private Member Functions | |
void | createShadowScene () |
Creates scene graph with shadows. | |
SoEnvironment * | findEnvironmentNode () |
Looks for user's environment node in the user's scene. | |
void | checkLights () |
Check all lights. | |
int | findObject (SoSeparator *object) |
Looks for a SoShadowCaster node for this object inside shadow manager. | |
void | checkObjects () |
Check all objects under SVN node. | |
void | printMsg (const char *msg) |
Prints information to stdout. | |
void | printError (const char *msg) |
Error printing method. | |
Static Private Member Functions | |
static void | lightMoveCallback (void *userdata, SoSensor *) |
Action called when any light changes its position. | |
static void | objectMoveCallback (void *userdata, SoSensor *s) |
Action called when something has changed in the path to the object node. | |
static void | objectShapeCallback (void *userdata, SoSensor *s) |
Action called when the object changes its shape. | |
static void | nslightsOffCB (void *userdata, SoAction *action) |
Rendering ambient CB. | |
static void | nslightsOnCB (void *userdata, SoAction *action) |
Rendering ambient end CB. | |
static void | nsambientOffCB (void *userdata, SoAction *action) |
Rendering no shadows light CB. | |
static void | nsambientOnCB (void *userdata, SoAction *action) |
Rendering no shadow end CB. | |
static void | initCB (void *userdata, SoAction *action) |
Rendering preset CB. | |
static void | endCB (void *userdata, SoAction *action) |
Rendering end CB. | |
Private Attributes | |
SoSeparator * | shadowCastersRoot |
Shadow casters root node. | |
SoSeparator * | shadowSceneRoot |
Shadow scene root node. | |
SoSeparator * | shadowLightsRoot |
Root node of all scene shadow volumes. | |
SoSeparator * | sceneRoot |
Scene root node. | |
TShadowSettings * | settings |
Shadow settings data structure. | |
enum TShadowAlgorithm | algorithm |
Shadow algorithm. | |
int | lightIndex |
Auto incremental index (name) of the light. | |
int | objectIndex |
Auto incremental index (name) of the object. | |
bool | first |
Is it the first call of create shadow scene?. | |
SoEnvironment * | environment |
Environment node to set ambient light. | |
SoSwitch * | switchNode |
Node to switch between scene types. | |
SoSeparator * | sceneNoShadows |
Root node of scene without shadows. | |
SoSeparator * | sceneWithShadows |
Root node of scene with shadows. | |
SoSeparator * | sceneWithShadowVolumes |
Root node of scene with shadow volumes. | |
Static Private Attributes | |
static float | envIntensity = 0.0f |
Ambient light intensity saved value. |
|
Enumeration of showed scene types.
Definition at line 102 of file ShadowManager.h. |
|
Constructor. Needs to know the pointers to the user's scene graph and a global environment node. If environment node is NULL, Shadow Manager will try to look for it under the scene root first and if none is fount, it creates its own. The darkness of shadows can be controlled trough the scene ambient light intensity of the user's SoEnvironment node. User MUST ENABLE STENCIL BUFFER to see shadows on his/her own by viewer->setStencilBuffer(TRUE);
Definition at line 68 of file ShadowManager.cpp. References TShadowSettings::dropShadows, environment, TShadowSettings::fDepth, findEnvironmentNode(), first, lightIndex, TShadowSettings::method, method2algorithm(), objectIndex, ONDEBUG, printError(), sceneNoShadows, sceneRoot, sceneWithShadows, sceneWithShadowVolumes, SE_VERSION, setSceneType(), settings, shadowCastersRoot, shadowLightsRoot, SHADOWS, shadowSceneRoot, switchNode, and zpass. |
|
Destructor.
Definition at line 149 of file ShadowManager.cpp. References environment, ONDEBUG, sceneRoot, shadowCastersRoot, shadowLightsRoot, shadowSceneRoot, and switchNode. |
|
Creates scene graph with shadows. Creates scene graph with shadows under the CShadowManager. Definition at line 1046 of file ShadowManager.cpp. References endCB(), initCB(), nsambientOffCB(), nsambientOnCB(), nslightsOffCB(), nslightsOnCB(), ONDEBUG, sceneNoShadows, sceneWithShadows, and shadowLightsRoot. Referenced by getShadowSceneRoot(). |
|
Looks for user's environment node in the user's scene. If the node is found in the user's scene graph (first occurence only), its pointer is passed to the Shadow Manager. There should be only one instance of SoEnvironment in the whole user's scene graph. It is used to set the darkness of shadows according to the ambient light intensity. Definition at line 401 of file ShadowManager.cpp. References ONDEBUG. Referenced by CShadowManager(). |
|
Action called when any light changes its position.
Definition at line 437 of file ShadowManager.cpp. References SoShadowLight::createShadowVolumes(), and ONDEBUG. |
|
Check all lights.
Definition at line 601 of file ShadowManager.cpp. References SoShadowLight::getLight(), ONDEBUG, and shadowLightsRoot. |
|
Action called when something has changed in the path to the object node. For example, the light position has changed or any node has been added to the scene graph before object node. The shadow volume of the object must be recalculated.
Definition at line 652 of file ShadowManager.cpp. References SoShadowCaster::createFaceModel(), SoShadowCaster::createShadowVolumes(), ONDEBUG, and SoShadowCaster::setMoved(). |
|
Action called when the object changes its shape.
Definition at line 737 of file ShadowManager.cpp. References SoShadowCaster::createFaceModel(), SoShadowCaster::createShadowVolumes(), SoShadowCaster::getCasterName(), and ONDEBUG. |
|
Looks for a SoShadowCaster node for this object inside shadow manager.
Definition at line 779 of file ShadowManager.cpp. References ONDEBUG, and shadowCastersRoot. Referenced by addObject(). |
|
Check all objects under SVN node.
Definition at line 992 of file ShadowManager.cpp. References ONDEBUG, and shadowCastersRoot. |
|
Rendering ambient CB. Turns off lights.
Definition at line 1243 of file ShadowManager.cpp. References SoShadowLight::getLight(), ONDEBUG, and SoShadowLight::status. Referenced by createShadowScene(). |
|
Rendering ambient end CB. Turns on lights.
Definition at line 1288 of file ShadowManager.cpp. References SoShadowLight::getLight(), ONDEBUG, and SoShadowLight::status. Referenced by createShadowScene(). |
|
Rendering no shadows light CB. Turns off and save ambient intensity value. Sets additive blending.
Definition at line 1316 of file ShadowManager.cpp. References envIntensity, and ONDEBUG. Referenced by createShadowScene(). |
|
Rendering no shadow end CB. Closes the whole rendering action. Sets default value of ambient light intensity.
Definition at line 1348 of file ShadowManager.cpp. References envIntensity, and ONDEBUG. Referenced by createShadowScene(). |
|
Rendering preset CB. Starts the whole rendering action. Saves light status values and cleares buffers.
Definition at line 1384 of file ShadowManager.cpp. References SoShadowLight::getLight(), ONDEBUG, and SoShadowLight::status. Referenced by createShadowScene(). |
|
Rendering end CB. Closes the whole rendering action. Sets default values and resets the light state according to the saved values.
Definition at line 1428 of file ShadowManager.cpp. References SoShadowLight::getLight(), ONDEBUG, and SoShadowLight::status. Referenced by createShadowScene(). |
|
Prints information to stdout.
Definition at line 1149 of file ShadowManager.cpp. |
|
Error printing method.
Definition at line 1160 of file ShadowManager.cpp. Referenced by addLight(), addObject(), CShadowManager(), and removeLight(). |
|
Sets which type of scene will be shown.
Definition at line 199 of file ShadowManager.cpp. References switchNode. Referenced by CShadowManager(). |
|
Get shadow volumes computing algorithm.
Definition at line 297 of file ShadowManager.cpp. References algorithm. |
|
Set shadow algorithm according to the chosen method.
Definition at line 306 of file ShadowManager.cpp. References algorithm, autoset, TShadowSettings::method, ONDEBUG, settings, zfail, zfailAlg, zpass, and zpassAlg. Referenced by CShadowManager(), setManager(), and setMethod(). |
|
Set up whole shadow manager settings in one step.
Definition at line 211 of file ShadowManager.cpp. References createShadows(), method2algorithm(), and settings. |
|
Read shadow manager settings.
Definition at line 224 of file ShadowManager.cpp. References settings. |
|
Set shadow computation method.
Definition at line 235 of file ShadowManager.cpp. References algorithm, createShadows(), TShadowSettings::method, method2algorithm(), ONDEBUG, printSettings(), and settings. |
|
Set shadow volumes depth.
Definition at line 258 of file ShadowManager.cpp. References createShadows(), TShadowSettings::fDepth, ONDEBUG, printSettings(), and settings. |
|
Print shadow manager's settings.
Definition at line 269 of file ShadowManager.cpp. References algorithm, autoset, TShadowSettings::dropShadows, TShadowSettings::fDepth, TShadowSettings::method, settings, zfail, zpass, and zpassAlg. Referenced by setMethod(), and setSVDepth(). |
|
Enable objects' sensors.
Definition at line 351 of file ShadowManager.cpp. References ONDEBUG, and shadowCastersRoot. |
|
Disable objects' sensors. This method is useful when an user want to change something (that is normally) detected by sensors and causes re-computation of shadows) in his existing scene graph and do not want to re-compute shadows. Just disable sensors, do what you want and enable sensors afterwards. Definition at line 333 of file ShadowManager.cpp. References ONDEBUG, and shadowCastersRoot. |
|
Recompute shadow volumes for all objects and all lights.
Definition at line 177 of file ShadowManager.cpp. References ONDEBUG, and shadowLightsRoot. Referenced by removeLight(), setManager(), setMethod(), and setSVDepth(). |
|
Re-computes shadow volumes of a selected caster.
Definition at line 1011 of file ShadowManager.cpp. References SoShadowVolume::create(), SoShadowVolume::getCasterName(), SoShadowLight::getNumVolumes(), SoShadowLight::getVolume(), and shadowLightsRoot. Referenced by SoShadowCaster::createShadowVolumes(). |
|
Returns the root node of the user's scene.
Definition at line 1135 of file ShadowManager.cpp. References sceneRoot. Referenced by SoShadowCaster::showFaceModel(). |
|
Returns the root node of the user scene with shadows.
Definition at line 1120 of file ShadowManager.cpp. References createShadowScene(), first, and shadowSceneRoot. |
|
Get environment node registered in Shadow Manager.
Definition at line 374 of file ShadowManager.cpp. References environment. Referenced by SoShadowLight::init(). |
|
Sets global ambient light intensity. Default value of Shadow Manager's own environment node is 0.2.
Definition at line 387 of file ShadowManager.cpp. References environment. |
|
Adds a new light to the scene light manager.
Definition at line 451 of file ShadowManager.cpp. References ONDEBUG, printError(), and shadowLightsRoot. |
|
Removes light from Shadow Manager and deletes all shadows that are cast by this light. Note: Remove light from Shadow Manager using this method and after that you can remove it from your scene graph. Otherwise it will not work properly.
Definition at line 558 of file ShadowManager.cpp. References createShadows(), SoShadowLight::getLight(), ONDEBUG, printError(), and shadowLightsRoot. |
|
Adds a new object to the scene object manager.
Each user object can be added into the Shadow Manger only once! Definition at line 814 of file ShadowManager.cpp. References SoShadowLight::addVolume(), findObject(), SoShadowCaster::getCasterName(), SoShadowLight::getLightName(), objectIndex, ONDEBUG, SoShadowCaster::path, printError(), SoShadowCaster::setCasterName(), SoShadowCaster::setMoveSensor(), SoShadowCaster::setShapeSensor(), shadowCastersRoot, and shadowLightsRoot. |
|
Removes the first occurence of the object from Shadow Manager. When object is found in the Shadow Manager, its shadows are destroyed. Also the sensor is detached and deleted.
Definition at line 911 of file ShadowManager.cpp. References SoShadowLight::deleteVolume(), ONDEBUG, shadowCastersRoot, and shadowLightsRoot. |
|
Forces recomputation of shadows of an object. This method is useful when something changes in the scene graph that affects object's shadows and none of Shadow Manager's internal callbacks is trigerred.
Definition at line 963 of file ShadowManager.cpp. References ONDEBUG, and shadowCastersRoot. |
|
Export shadow scene graph into a file.
Definition at line 1171 of file ShadowManager.cpp. |
|
Shadow casters root node.
Definition at line 111 of file ShadowManager.h. Referenced by addObject(), checkObjects(), createObjectsShadows(), CShadowManager(), disableSensors(), enableSensors(), findObject(), removeObject(), and ~CShadowManager(). |
|
Shadow scene root node.
Definition at line 113 of file ShadowManager.h. Referenced by CShadowManager(), getShadowSceneRoot(), and ~CShadowManager(). |
|
Root node of all scene shadow volumes.
Definition at line 115 of file ShadowManager.h. Referenced by addLight(), addObject(), checkLights(), createCasterVolumes(), createShadows(), createShadowScene(), CShadowManager(), removeLight(), removeObject(), and ~CShadowManager(). |
|
Scene root node.
Definition at line 118 of file ShadowManager.h. Referenced by CShadowManager(), getSceneRoot(), and ~CShadowManager(). |
|
Shadow settings data structure.
Definition at line 120 of file ShadowManager.h. Referenced by CShadowManager(), method2algorithm(), printSettings(), readSettings(), setManager(), setMethod(), and setSVDepth(). |
|
Shadow algorithm.
Definition at line 122 of file ShadowManager.h. Referenced by getAlgorithm(), method2algorithm(), printSettings(), and setMethod(). |
|
Auto incremental index (name) of the light.
Definition at line 124 of file ShadowManager.h. Referenced by CShadowManager(). |
|
Auto incremental index (name) of the object.
Definition at line 126 of file ShadowManager.h. Referenced by addObject(), and CShadowManager(). |
|
Is it the first call of create shadow scene?.
Definition at line 128 of file ShadowManager.h. Referenced by CShadowManager(), and getShadowSceneRoot(). |
|
Environment node to set ambient light.
Definition at line 130 of file ShadowManager.h. Referenced by CShadowManager(), getEnvironmentNode(), setAmbientIntensity(), and ~CShadowManager(). |
|
Ambient light intensity saved value.
Definition at line 132 of file ShadowManager.h. Referenced by nsambientOffCB(), and nsambientOnCB(). |
|
Node to switch between scene types.
Definition at line 135 of file ShadowManager.h. Referenced by CShadowManager(), setSceneType(), and ~CShadowManager(). |
|
Root node of scene without shadows.
Definition at line 137 of file ShadowManager.h. Referenced by createShadowScene(), and CShadowManager(). |
|
Root node of scene with shadows.
Definition at line 139 of file ShadowManager.h. Referenced by createShadowScene(), and CShadowManager(). |
|
Root node of scene with shadow volumes.
Definition at line 141 of file ShadowManager.h. Referenced by CShadowManager(). |