00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SHADOW_MANAGER__H
00029 #define SHADOW_MANAGER__H
00030
00032 #ifndef DODEBUG
00033 #define DODEBUG 0
00034 #endif
00035 #if DODEBUG
00036
00037 #define ONDEBUG(x) x
00038 #else
00039
00040 #define ONDEBUG(x)
00041 #endif
00042
00044 #define SHOWFACEMODEL 0
00045
00046 #ifndef SE_VERSION
00047 #define SE_VERSION "0.6.2"
00048 #endif
00049
00050
00051
00052
00053
00054 #include "DataStructures.h"
00055
00056 #include <Inventor/nodes/SoSeparator.h>
00057 #include <Inventor/nodes/SoSwitch.h>
00058 #include <Inventor/nodes/SoCallback.h>
00059 #include <Inventor/nodes/SoPolygonOffset.h>
00060 #include <Inventor/nodes/SoTransformation.h>
00061 #include <Inventor/nodes/SoEnvironment.h>
00062
00063 #include <Inventor/nodes/SoLight.h>
00064 #include <Inventor/nodes/SoDirectionalLight.h>
00065 #include <Inventor/nodes/SoPointLight.h>
00066 #include <Inventor/nodes/SoSpotLight.h>
00067
00068 #include <Inventor/manips/SoDirectionalLightManip.h>
00069 #include <Inventor/manips/SoPointLightManip.h>
00070 #include <Inventor/manips/SoSpotLightManip.h>
00071
00072 #include <Inventor/sensors/SoFieldSensor.h>
00073 #include <Inventor/sensors/SoNodeSensor.h>
00074 #include <Inventor/sensors/SoPathSensor.h>
00075
00076 #include <Inventor/actions/SoSearchAction.h>
00077 #include <Inventor/actions/SoGLRenderAction.h>
00078
00079 #include <Inventor/lists/SbList.h>
00080
00081
00082
00083
00084
00096 class CShadowManager
00097 {
00098
00099 public:
00100
00102 enum SCENE_TYPE {
00103 SHADOWS = 0,
00104 SCENE = 1
00105
00106 };
00107
00108
00109 private:
00111 SoSeparator * shadowCastersRoot;
00113 SoSeparator * shadowSceneRoot;
00115 SoSeparator * shadowLightsRoot;
00116
00118 SoSeparator * sceneRoot;
00120 struct TShadowSettings * settings;
00122 enum TShadowAlgorithm algorithm;
00124 int lightIndex;
00126 int objectIndex;
00128 bool first;
00130 SoEnvironment * environment;
00132 static float envIntensity;
00133
00135 SoSwitch * switchNode;
00137 SoSeparator * sceneNoShadows;
00139 SoSeparator * sceneWithShadows;
00141 SoSeparator * sceneWithShadowVolumes;
00142
00143
00144 void createShadowScene();
00145
00146
00147 SoEnvironment * findEnvironmentNode();
00148
00149
00150 static void lightMoveCallback (void * userdata, SoSensor *);
00151 void checkLights();
00152
00153
00154 static void objectMoveCallback(void * userdata, SoSensor * s);
00155 static void objectShapeCallback(void * userdata, SoSensor * s);
00156 int findObject(SoSeparator * object);
00157 void checkObjects();
00158
00159
00160
00161 static void nslightsOffCB(void * userdata, SoAction * action);
00162 static void nslightsOnCB(void * userdata, SoAction * action);
00163 static void nsambientOffCB(void * userdata, SoAction * action);
00164 static void nsambientOnCB(void * userdata, SoAction * action);
00165
00166 static void initCB(void * userdata, SoAction * action);
00167 static void endCB(void * userdata, SoAction * action);
00168
00169
00170 void printMsg(const char * msg);
00171 void printError(const char * msg);
00172
00173 public:
00174 CShadowManager(SoSeparator * sr, SoEnvironment * env);
00175 ~CShadowManager();
00176
00177
00178 void setSceneType(enum CShadowManager::SCENE_TYPE type);
00179
00180
00181 enum TShadowAlgorithm * getAlgorithm();
00182 void method2algorithm();
00183
00184
00185 void setManager(TShadowSettings * s);
00186 const struct TShadowSettings * readSettings();
00187 void setMethod(enum TShadowMethod newMethod);
00188 void setSVDepth(float newfDepth);
00189 void printSettings();
00190 void enableSensors();
00191 void disableSensors();
00192
00193
00194 void createShadows();
00195 void createCasterVolumes(int index);
00196 SoSeparator * getSceneRoot();
00197 SoSeparator * getShadowSceneRoot();
00198
00199
00200 SoEnvironment * getEnvironmentNode();
00201 void setAmbientIntensity(float val);
00202
00203
00204 void addLight(SoLight * light);
00205 void removeLight(SoLight * light);
00206
00207
00208 void addObject(SoSeparator * object);
00209 void removeObject(SoSeparator * object);
00210 void createObjectsShadows(SoSeparator * object);
00211
00212
00213 void export(const char * filename);
00214
00215 };
00216
00217
00218 #endif