00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : R.ALBOU (Sep 2001) 00022 **=======================================================================*/ 00023 #ifndef _SO_SHADOW_GROUP_ 00024 #define _SO_SHADOW_GROUP_ 00025 00026 00027 #include <Inventor/nodes/SoGroup.h> 00028 #include <Inventor/fields/SoSFBool.h> 00029 #include <Inventor/fields/SoSFEnum.h> 00030 #include <Inventor/fields/SoSFFloat.h> 00031 #include <Inventor/fields/SoSFInt32.h> 00032 #include <Inventor/SbMatrix.h> 00033 #include <Inventor/SbPImpl.h> 00034 00035 class SoGLShadowMapping ; 00036 class SoCache ; 00037 class SoGLTexture; 00038 00039 SO_PIMPL_PUBLIC_DECLARATION(SoShadowGroup) 00040 00041 00180 class SoShadowGroup : public SoGroup 00181 { 00182 SO_NODE_HEADER(SoShadowGroup); 00183 SO_PIMPL_PUBLIC_HEADER(SoShadowGroup) 00184 00185 public: 00189 enum VisibilityFlag { 00195 ABSOLUTE_RADIUS, 00196 00203 LONGEST_BBOX_EDGE_FACTOR 00204 } ; 00205 00209 enum ShadowingMethod { 00213 VARIANCE_SHADOW_MAP, 00214 #ifndef HIDDEN_FROM_DOC 00215 LAST_METHOD 00216 #endif 00217 }; 00218 00222 SoShadowGroup(); 00223 00227 SoShadowGroup(int nChildren); 00228 00233 SoSFBool isActive ; 00234 00240 SoSFFloat intensity ; 00241 00253 SoSFFloat precision ; 00254 00261 SoSFFloat quality ; 00262 00268 SoSFBool shadowCachingEnabled ; 00269 00285 SoSFFloat visibilityRadius ; 00286 00291 SoSFEnum visibilityFlag ; 00292 00293 00300 SoSFInt32 smoothFactor; 00301 00312 SoSFFloat minVariance; 00313 00322 SoSFFloat lightBleedingReduction; 00323 00330 SoSFEnum method; 00331 00338 static SbBool isSupported(SoShadowGroup::ShadowingMethod method = SoShadowGroup::VARIANCE_SHADOW_MAP) ; 00339 00340 00341 private: 00343 virtual void GLRender(SoGLRenderAction *action); 00344 00345 /*----------------------------------------------------------------------------*/ 00346 00347 private: 00348 typedef std::vector<int> StackIndexVector; 00349 00350 static void initClass() ; 00351 static void exitClass() ; 00352 00354 const SbMatrix& getLightViewProjectionMatrix() const; 00355 00357 int getLightIndex() const; 00358 00360 static int getShadowMapTextureUnit(SoGLRenderAction* action); 00361 00363 void invalidateLightCaches(); 00364 00367 bool isCacheValid(SoState* state, SoCache* &cache, const StackIndexVector& elemsToCheck); 00368 00369 00371 bool isShadowActive(SoState* state) const; 00372 00374 float getQuality(SoState* state) const; 00375 00379 virtual void notify(SoNotList *list); 00380 00382 SbVec2i32 getShadowMapSize(); 00383 00384 private: 00385 virtual ~SoShadowGroup(); 00386 00387 private: 00388 00389 #if 1 SoDEPRECATED 00395 SoSFBool isShapesBefore; 00396 #endif 00399 void addElementsToCache(SoState* state, SoCache* cache) const; 00400 00402 void chooseShadowingMethod(); 00403 00405 inventor::impl::SoShadowGroupImpl* createImplementation() const; 00406 00407 void commonInit(); 00408 00410 static int s_defaultTextureUnit; 00411 }; 00412 /*----------------------------------------------------------------------------*/ 00413 #endif // _SO_SHADOW_GROUP_ 00414 00415 00416