00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_SHADOW_VOLUME_H__
00023 #define __GZ_SHADOW_VOLUME_H__
00024
00030 #include "gzRecursive.h"
00031 #include "gzGeometry.h"
00032 #include "gzNodeAction.h"
00033 #include "gzLight.h"
00034 #include "gzShadowGeometry.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class gzShadowVolume : public gzBaseGeometry
00051 {
00052 public:
00053
00054 GZ_GRAPH_EXPORT gzShadowVolume(gzLight *shadowlight=NULL,gzULong softPasses=0,gzFloat softScale=1.0f,const gzString & name=GZ_EMPTY_STRING);
00055
00056 GZ_GRAPH_EXPORT virtual ~gzShadowVolume(){};
00057
00058 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00059
00060
00061
00062 GZ_GRAPH_EXPORT virtual gzReference* clone() const=0;
00063
00064
00065
00066 GZ_GRAPH_EXPORT gzLight *getShadowLight();
00067
00068 GZ_GRAPH_EXPORT gzVoid setShadowLight(gzLight *shadowLight);
00069
00070
00071
00072 GZ_GRAPH_EXPORT gzVoid setTransformIndex(gzULong index);
00073
00074 GZ_GRAPH_EXPORT gzULong getTransformIndex();
00075
00076
00077
00078 GZ_GRAPH_EXPORT gzVoid useRenderID(gzBool on);
00079 GZ_GRAPH_EXPORT gzBool useRenderID();
00080
00081 GZ_GRAPH_EXPORT gzVoid setRenderID(gzULong id);
00082 GZ_GRAPH_EXPORT gzULong getRenderID();
00083
00084
00085
00086 GZ_GRAPH_EXPORT gzVoid setPrimaryDirection(const gzVec3 &direction,const gzVec3 &base);
00087 GZ_GRAPH_EXPORT gzVec3 getPrimaryDirection();
00088 GZ_GRAPH_EXPORT gzVec3 getPrimaryBase();
00089
00090 GZ_GRAPH_EXPORT gzVoid setNumberOfSoftPasses(gzULong passes);
00091 GZ_GRAPH_EXPORT gzULong getNumberOfSoftPasses();
00092
00093 GZ_GRAPH_EXPORT gzVoid setSoftScale(gzFloat scale);
00094 GZ_GRAPH_EXPORT gzFloat getSoftScale();
00095
00096 GZ_GRAPH_EXPORT gzVoid updateSoftScaleMatrix();
00097
00098 GZ_GRAPH_EXPORT const gzMatrix4 &getSoftScaleMatrix();
00099
00100 private:
00101
00102
00103
00104 gzLight * m_shadowLight;
00105
00106 gzULong m_transformIndex;
00107
00108 gzBool m_useRenderID;
00109
00110 gzULong m_renderID;
00111
00112 gzVec3 m_primaryDirection;
00113
00114 gzVec3 m_primaryBase;
00115
00116 gzFloat m_scaleFactor;
00117
00118 gzULong m_softPasses;
00119
00120 gzMatrix4 m_scaleMatrix;
00121 };
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 class gzShadowVolumeGeometry : public gzShadowVolume
00138 {
00139 public:
00140
00141 GZ_GRAPH_EXPORT gzShadowVolumeGeometry( gzLight *shadowlight=NULL,gzBaseGeometry *geom=NULL,gzULong softPasses=0,gzFloat softScale=1.0f,const gzString & name=GZ_EMPTY_STRING);
00142
00143 GZ_GRAPH_EXPORT virtual ~gzShadowVolumeGeometry(){};
00144
00145 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00146
00147
00148
00149 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00150
00151
00152
00153 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00154
00155
00156
00157 GZ_GRAPH_EXPORT virtual gzVoid updateNode();
00158
00159
00160
00161
00162 GZ_GRAPH_EXPORT gzVoid setGeometry(gzBaseGeometry *geometry);
00163
00164 GZ_GRAPH_EXPORT gzBaseGeometry *getGeometry();
00165
00166 private:
00167
00168 gzRefPointer<gzBaseGeometry> m_geometry;
00169
00170 };
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 class gzIndexBaseGeometry : public gzReference
00187 {
00188 private:
00189
00190 gzIndexBaseGeometry(){};
00191
00192 friend class gzShadowRender;
00193
00194 gzRefPointer<gzBaseGeometry> geometry;
00195
00196 gzULong index;
00197
00198 gzBool equalIndex;
00199 };
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 class gzShadowRender : public gzRecursive
00217 {
00218 public:
00219 GZ_GRAPH_EXPORT gzShadowRender(const gzString & name=GZ_EMPTY_STRING);
00220 GZ_GRAPH_EXPORT virtual ~gzShadowRender(){};
00221
00222 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00223
00224
00225
00226 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00227
00228
00229
00230 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00231 GZ_GRAPH_EXPORT virtual gzVoid postTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00232 GZ_GRAPH_EXPORT virtual gzActionStage useActionStage( gzTraverseAction *actionclass , gzContext *context);
00233
00234
00235
00236 GZ_GRAPH_EXPORT gzVoid addShadowVolume (gzShadowVolume *mask, gzBool addToRender=FALSE);
00237
00238 GZ_GRAPH_EXPORT gzVoid removeShadowVolume (gzShadowVolume *mask);
00239
00240 GZ_GRAPH_EXPORT gzVoid addGeometryMask (gzBaseGeometry *render, gzULong index=0,gzBool equalIndex=FALSE);
00241
00242 GZ_GRAPH_EXPORT gzVoid showVolumes (gzBool show);
00243
00244 GZ_GRAPH_EXPORT gzVoid useClearing(gzBool on);
00245
00246 GZ_GRAPH_EXPORT gzVoid setPassOffset(gzULong offset);
00247
00248
00249 protected:
00250
00251 GZ_GRAPH_EXPORT virtual gzVoid calculateTransform(gzContext *context);
00252
00253 gzRefList<gzShadowVolume> m_volumes;
00254
00255 gzRefList<gzIndexBaseGeometry> m_geometryMasks;
00256
00257 gzULong m_passOffset;
00258
00259 gzBool m_showVolumes:1;
00260
00261 gzBool m_useClearing:1;
00262 };
00263
00264 enum gzShadowGeneratorType
00265 {
00266 GZ_SHADOW_GEOMETRY,
00267 GZ_SHADOW_DEPTHMAP
00268 };
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 class gzShadowGenerator : public gzNode
00286 {
00287 public:
00288 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00289
00290 GZ_GRAPH_EXPORT gzShadowGenerator(gzNode *node , gzShadowVolumeGeometry *shadowVolume , const gzDouble &lengthFactor , gzShadowGeneratorType type, const gzString & name=GZ_EMPTY_STRING);
00291
00292 GZ_GRAPH_EXPORT virtual ~gzShadowGenerator(){};
00293
00294
00295
00296 GZ_GRAPH_EXPORT virtual gzReference* clone() const;
00297
00298
00299
00300 GZ_GRAPH_EXPORT virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context);
00301
00303
00320 GZ_GRAPH_EXPORT static gzVoid addShadowGenerators( gzNode *scene,
00321 gzShadowRender *render,
00322 gzLight *light ,
00323 gzBool useShadowTag=FALSE,
00324 const gzDouble &lengthFactor=5.0,
00325 const gzULong &softPasses=0,
00326 const gzFloat &softScale=1.0f,
00327 gzRefList<gzShadowGenerator> *addedGenerators=NULL,
00328 gzShadowGeneratorType type=GZ_SHADOW_GEOMETRY,
00329 gzULong maxTraverseDepth=0xffffffffUL,
00330 gzBool inShadowTag=FALSE);
00331
00333
00341 GZ_GRAPH_EXPORT static gzBool removeShadowGenerators( gzNode *scene , gzShadowRender *render , gzNode *item=NULL);
00342
00344 GZ_GRAPH_EXPORT gzShadowVolumeGeometry *getShadowVolumeGeometry();
00345
00347 GZ_GRAPH_EXPORT gzNode *getNode();
00348
00349 private:
00350
00351 gzDouble m_lengthFactor;
00352
00353 gzRefPointer<gzNode> m_node;
00354
00355 gzRefPointer<gzShadowVolumeGeometry> m_shadowVolume;
00356
00357 gzULong m_transformUpdateDiff;
00358
00359 gzULong m_lightUpdateID;
00360
00361 gzULong m_nodeUpdateID;
00362
00363 gzULong m_weightUpdateID;
00364
00365 gzArray<gzTriConnectivity> m_triConnectivity;
00366
00367 gzULong m_currentUpdate;
00368
00369 gzULong m_updateCount;
00370
00371 gzShadowGeneratorType m_type;
00372 };
00373
00374
00375
00376 const gzString GZ_USERDATA_MASK_GEOMETRY ="_mskG";
00377
00378 class gzShadowGeometryMask : public gzUserData
00379 {
00380 public:
00381
00382 gzRefPointer<gzGeometry> maskData;
00383 };
00384
00385 #endif