VR-Forces 4.0.4 Class Documentation
include/makOsgShadowFX/DtShadowMapImpl.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2008 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: ShadowMapImpl.h,v $ $Revision: 1.5 $ $State: Exp $
00007 ******************************************************************************/
00008 
00009 #ifndef shadowMapImple_H_
00010 #define shadowMapImple_H_
00011 
00012 #include <vrvOsg/vrvOsg.h>
00013 
00014 #include <osg/Camera>
00015 #include <osg/Material>
00016 #include <osg/MatrixTransform>
00017 #include <osg/LightSource>
00018 #include <osgUtil/CullVisitor>
00019 #include <osg/TexGen>
00020 #include <osg/Texture2D>
00021 
00022 namespace makOsgShadowFX 
00023 {
00024 
00025 class DT_DLL_VRVOSG DtShadowMap : public osg::Node
00026 {
00027     public :
00028         DtShadowMap();
00029         DtShadowMap(const DtShadowMap& orig, const osg::CopyOp& op);
00030 
00031         META_Object(makOsgShadowFX, DtShadowMap);
00032 
00033 
00035         virtual void init();
00036 
00038         virtual void cull(osgUtil::CullVisitor& cv);
00039 
00040         virtual osg::Texture2D* shadowTexture() const {return myShadowMap.get();}
00041 
00042         virtual void setShadowScene(osg::Group* scene) {if(scene) myShadowScene=scene;}
00043         virtual osg::Group* shadowScene() {return myShadowScene.get();}
00044 
00045         virtual void traverse(osg::NodeVisitor& nv);
00046 
00047         virtual osg::Camera* shadowCamera() const {return myShadowCamera.get();}
00048 
00049         virtual osg::TexGen* texureGen() const {return myTexGen.get();}
00050 
00051 
00053         virtual void setPolygonOffset(const osg::Vec2& polyOffset);
00054 
00056         virtual const osg::Vec2& getPolygonOffset() const { return myPolyOffset; }
00057 
00059         virtual void setTextureSize(const osg::Vec2s& textureSize);
00060 
00062         virtual const osg::Vec2s& getTextureSize() const { return myShadowMapSize; }
00063 
00065         virtual void setLight(osg::Light* light);
00066         virtual void setLight(osg::LightSource* ls);
00067 
00068         void setMaxDistance(float dist) {myMaxDistance=dist;}
00069         void setMinLightMargin(float mar) {myMinLightMargin=mar;}
00070 
00071 
00072     protected:
00073         virtual ~DtShadowMap(void) {};
00074 
00075         virtual const osg::Light* selectLight( osg::Vec4 &viewLightPos,
00076            osg::Vec3 &viewLightDir );
00077 
00078         virtual void setupShadowReceivingScene();
00079 
00080         virtual void aimShadowCastingCamera( const osg::Light *light,
00081            const osg::Vec4 &worldLightPos, const osg::Vec3 &worldLightDir,                                       
00082            const osg::Vec3 &worldLightUp = osg::Vec3(0,1,0) );
00083 
00084         virtual void generateShadowMap();
00085 
00086         virtual void updateTexGen();
00087 
00088 
00089         osg::ref_ptr<osg::Light>        mySetLight;
00090 
00091         osg::Vec2                        myPolyOffset;
00092 
00093         osg::ref_ptr<osg::Camera>       myShadowCamera;
00094         osg::ref_ptr<osg::StateSet>     myShadowCameraStateSet;
00095         osg::ref_ptr<osg::Texture2D>    myShadowMap;
00096         osg::Vec2s                      myShadowMapSize;
00097         float                           myMaxDistance;
00098         float                           myMinLightMargin;
00099 
00100         osg::observer_ptr< osgUtil::CullVisitor > myCullVisitor;
00101 
00102         osg::ref_ptr<osg::Group> myShadowScene;
00103         osg::ref_ptr<osg::TexGen> myTexGen;
00104 
00105         bool myIsDirty;
00106     };
00107 
00108 } //makOsgShadowFX::
00109 
00110 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)