VR-Forces 4.1 Class Documentation
DtShadowMapImpl.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2008 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: ShadowMapImpl.h,v $ $Revision: 1.5 $ $State: Exp $
7 ******************************************************************************/
8 
9 #ifndef shadowMapImple_H_
10 #define shadowMapImple_H_
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/Camera>
15 #include <osg/Material>
16 #include <osg/MatrixTransform>
17 #include <osg/LightSource>
18 #include <osgUtil/CullVisitor>
19 #include <osg/TexGen>
20 #include <osg/Texture2D>
21 
22 namespace makOsgShadowFX
23 {
24 
25 class DT_DLL_VRVOSG DtShadowMap : public osg::Node
26 {
27  public :
28  DtShadowMap();
29  DtShadowMap(const DtShadowMap& orig, const osg::CopyOp& op);
30 
31  META_Object(makOsgShadowFX, DtShadowMap);
32 
33 
35  virtual void init();
36 
38  virtual void cull(osgUtil::CullVisitor& cv);
39 
40  virtual osg::Texture2D* shadowTexture() const {return myShadowMap.get();}
41 
42  virtual void setShadowScene(osg::Group* scene) {if(scene) myShadowScene=scene;}
43  virtual osg::Group* shadowScene() {return myShadowScene.get();}
44 
45  virtual void traverse(osg::NodeVisitor& nv);
46 
47  virtual osg::Camera* shadowCamera() const {return myShadowCamera.get();}
48 
49  virtual osg::TexGen* texureGen() const {return myTexGen.get();}
50 
51 
53  virtual void setPolygonOffset(const osg::Vec2& polyOffset);
54 
56  virtual const osg::Vec2& getPolygonOffset() const { return myPolyOffset; }
57 
59  virtual void setTextureSize(const osg::Vec2s& textureSize);
60 
62  virtual const osg::Vec2s& getTextureSize() const { return myShadowMapSize; }
63 
65  virtual void setLight(osg::Light* light);
66  virtual void setLight(osg::LightSource* ls);
67 
68  void setMaxDistance(float dist) {myMaxDistance=dist;}
69  void setMinLightMargin(float mar) {myMinLightMargin=mar;}
70 
71 
72  protected:
73  virtual ~DtShadowMap(void) {};
74 
75  virtual const osg::Light* selectLight( osg::Vec4 &viewLightPos,
76  osg::Vec3 &viewLightDir );
77 
78  virtual void setupShadowReceivingScene();
79 
80  virtual void aimShadowCastingCamera( const osg::Light *light,
81  const osg::Vec4 &worldLightPos, const osg::Vec3 &worldLightDir,
82  const osg::Vec3 &worldLightUp = osg::Vec3(0,1,0) );
83 
84  virtual void generateShadowMap();
85 
86  virtual void updateTexGen();
87 
88 
89  osg::ref_ptr<osg::Light> mySetLight;
90 
91  osg::Vec2 myPolyOffset;
92 
93  osg::ref_ptr<osg::Camera> myShadowCamera;
94  osg::ref_ptr<osg::StateSet> myShadowCameraStateSet;
95  osg::ref_ptr<osg::Texture2D> myShadowMap;
96  osg::Vec2s myShadowMapSize;
99 
100  osg::observer_ptr< osgUtil::CullVisitor > myCullVisitor;
101 
102  osg::ref_ptr<osg::Group> myShadowScene;
103  osg::ref_ptr<osg::TexGen> myTexGen;
104 
105  bool myIsDirty;
106  };
107 
108 } //makOsgShadowFX::
109 
110 #endif

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)