VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtPlanarReflection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <osg/Camera>
15 #include <osg/ClipNode>
16 #include <osg/Texture2D>
17 
18 // Whether to use an oblique frustum plane or an OpenGL clip plane
19 // for reflection clipping at the waterline.
20 // Remember to also uncomment assignment of gl_ClipVertex in uber_vs.glsl if
21 // you use OpenGL clip planes.
22 #define USE_OBLIQUE_CLIP_PLANE
23 
24 namespace makVrv
25 {
26  class DtDe;
27  class DtOsgCullVisitor;
30  class DtPlanarReflection : public osg::Camera
31  {
32  public:
34  DtPlanarReflection( osg::Camera * mainCamera, DtDe& de );
35 
37  osg::Texture2D * getTexture();
38 
40  osg::RefMatrix * getTextureProjectionMatrix();
41 
42  // Override Node::accept to intercept cull visitor traversal
43  virtual void accept(osg::NodeVisitor& nv);
44 
45  // Enable / disable this reflection camera at runtime.
46  virtual void enable(bool enabled);
47 
48  virtual void releaseGLObjects(osg::State* state = 0);
49 
50 #ifdef USE_OBLIQUE_CLIP_PLANE
51  void setClipPlane(const osg::Vec4d& v) {myClipPlane = v;}
52 #endif
54 
55  void setMirrorMatrix(const osg::Matrix& mirror) { myMirrorMatrix = mirror; }
56 
57  protected:
58  virtual void lodScaleChanged( float lodScale );
59 
60  osg::Matrixd modifyProjectionMatrix(const osg::Matrix& sceneProjection, const osg::Vec4d& clipPlane) const;
61 
63  virtual ~DtPlanarReflection();
64 
65  void setupColorBufferTexture(int format, int sourceFormat, int sourceType);
66 
67  protected:
70 
71  osg::ref_ptr< osg::Texture2D > myTexture, myDepthTexture;
72  osg::ref_ptr< osg::RefMatrix > myTextureProjectionMatrix;
73  osg::ref_ptr< osg::Camera > mySceneCamera;
74 
75  osg::Matrix myMirrorMatrix;
76 
80 
81 
82 #ifdef USE_OBLIQUE_CLIP_PLANE
83  osg::Vec4d myClipPlane;
84 #endif
85  };
86 }
87 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)