VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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) const;
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 
58 
59  protected:
60  virtual void lodScaleChanged( float lodScale );
61 
62  osg::Matrixd modifyProjectionMatrix(const osg::Matrix& sceneProjection, const osg::Vec4d& clipPlane) const;
63 
65  virtual ~DtPlanarReflection();
66 
67  void setupColorBufferTexture(int format, int sourceFormat, int sourceType);
68 
70 
71  protected:
74 
75  osg::ref_ptr< osg::Texture2D > myTexture, myDepthTexture;
76  osg::ref_ptr< osg::RefMatrix > myTextureProjectionMatrix;
77  osg::ref_ptr< osg::Camera > mySceneCamera;
78 
79  osg::Matrix myMirrorMatrix;
80 
84 
85 
86 #ifdef USE_OBLIQUE_CLIP_PLANE
87  osg::Vec4d myClipPlane;
88 #endif
89  };
90 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)