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-2020 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 00034 class SoGLShadowMapping ; 00035 class SoCache ; 00036 class SoShadowGroupImpl; 00037 class SoGLTexture; 00038 00039 #if defined(_WIN32) 00040 #pragma warning(push) 00041 #pragma warning(disable: 4251) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' 00042 #endif 00043 00211 class SoShadowGroup : public SoGroup { 00212 SO_NODE_HEADER( SoShadowGroup ); 00213 00214 public: 00218 enum VisibilityFlag { 00224 ABSOLUTE_RADIUS, 00225 00232 LONGEST_BBOX_EDGE_FACTOR 00233 } ; 00234 00238 enum ShadowingMethod {SoDEPRECATED SHADOW_MAP, 00243 00247 VARIANCE_SHADOW_MAP, 00248 #ifndef HIDDEN_FROM_DOC 00249 LAST_METHOD 00250 #endif 00251 }; 00252 00256 SoShadowGroup(); 00257 00261 SoShadowGroup(int nChildren); 00262 00267 SoSFBool isActive ; 00268 00269 #if 1 SoDEPRECATED 00277 SoSFBool isShapesBefore ; 00278 #endif 00285 SoSFFloat intensity ; 00286 00298 SoSFFloat precision ; 00299 00309 SoSFFloat quality ; 00310 00316 SoSFBool shadowCachingEnabled ; 00317 00333 SoSFFloat visibilityRadius ; 00334 00339 SoSFEnum visibilityFlag ; 00340 00341 00349 SoSFInt32 smoothFactor; 00350 00361 SoSFFloat minVariance; 00362 00371 SoSFFloat lightBleedingReduction; 00372 00379 SoSFEnum method; 00380 00387 static SbBool isSupported(SoShadowGroup::ShadowingMethod method = SoShadowGroup::SHADOW_MAP) ; 00388 00389 00390 private: 00392 virtual void GLRender(SoGLRenderAction *action); 00393 00394 /*----------------------------------------------------------------------------*/ 00395 00396 private: 00397 typedef std::vector<int> StackIndexVector; 00398 00399 static void initClass() ; 00400 static void exitClass() ; 00401 00403 const SbMatrix& getLightViewProjectionMatrix() const; 00404 00406 int getLightIndex() const; 00407 00409 static int getShadowMapTextureUnit(SoGLRenderAction* action); 00410 00412 void invalidateLightCaches(); 00413 00416 bool isCacheValid(SoState* state, SoCache* &cache, const StackIndexVector& elemsToCheck); 00417 00418 00420 bool isShadowActive(SoState* state) const; 00421 00423 float getQuality(SoState* state) const; 00424 00428 virtual void notify(SoNotList *list); 00429 00431 SoGLTexture* getShadowMapTexture(); 00432 00433 private: 00434 virtual ~SoShadowGroup(); 00435 00436 private: 00437 struct Members 00438 { 00439 Members(); 00440 ~Members(); 00441 void unref(); 00442 00443 SoShadowGroupImpl* m_sgImpl; 00444 ShadowingMethod m_currentMethod; 00445 uint64_t m_lastNodeId; 00446 }; 00447 SbThreadStorage<Members*> m_members; 00448 00450 void addElementsToCache(SoState* state, SoCache* cache) const; 00451 00453 void chooseShadowingMethod(); 00454 00455 void commonInit(); 00456 00458 static SoShadowGroup::Members* getMembers(const SoShadowGroup* sg); 00459 00461 static int s_defaultTextureUnit; 00462 }; 00463 /*----------------------------------------------------------------------------*/ 00464 00465 #if defined(_WIN32) 00466 #pragma warning(pop) 00467 #endif 00468 00469 #endif // _SO_SHADOW_GROUP_ 00470 00471 00472