source: experimental/distortionNG/DistortionSet.h @ 357

Last change on this file since 357 was 357, checked in by Torben Dannhauer, 12 years ago
File size: 4.5 KB
Line 
1#ifndef OSGVIEWER_DistortionSet
2#define OSGVIEWER_DistortionSet 1
3
4/* -*-c++-*- osgVisual - Copyright (C) 2009-2012 Torben Dannhauer
5 *
6 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
7 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
8 * (at your option) any later version.  The full license is in LICENSE file
9 * included with this distribution, and on the openscenegraph.org website.
10 *
11 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
12 * You have to aquire licenses for all used proprietary modules.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * OpenSceneGraph Public License for more details.
18*/
19
20#include <osg/Object>
21#include <osg/Image>
22#include <osg/Matrixd>
23#include <osg/Camera>
24#include <osg/Switch>
25
26namespace osgViewer {
27
28class DistortionSet : public osg::Object
29{
30public:
31        enum DistortionInternals {
32                MESH = 0,
33                HIGHLIGHTER = 1,
34                HUD = 2
35        };
36
37        META_Object(osgViewer,DistortionSet);   // Required for serializer
38
39        DistortionSet(const osgViewer::DistortionSet& ds, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): // Required for serializer
40                _distortionMeshRows(ds._distortionMeshRows),
41                _distortionMeshColumns(ds._distortionMeshColumns),
42                //osg::PrimitiveSet::Mode _MeshType
43                _intensityMap(ds._intensityMap),
44                _texUnitScene(ds._texUnitScene),
45                _texUnitIntensityMap(ds._texUnitIntensityMap),
46                _viewOffset(ds._viewOffset),
47                _projectionOffset(ds._projectionOffset),
48                _showIntesityMapMapOnly(ds._showIntesityMapMapOnly){}
49
50        DistortionSet();
51        virtual ~DistortionSet();
52
53        // Working access
54        osg::Image* getIntensityMap()  { return _intensityMap; }        // Also for manipulating the intensity map
55        bool& getShowIntensityMapOnlyAsRef()    { return _showIntesityMapMapOnly;}
56
57        void setDistortionCamera(osg::Camera* camera)   { _camera = camera;}
58        osg::Camera* getDistortionCamera()      { return _camera.get(); }
59
60        osg::Switch* getDistortionInternals()   { return _distortionInternals; }
61
62
63
64        // Serializer Access
65        void setDistortionMeshRows(int distortionMeshRows)              { _distortionMeshRows = distortionMeshRows; }
66        int getDistortionMeshRows() const       { return _distortionMeshRows; }
67
68        void setDistortionMeshColumns(int distortionMeshColumns)                { _distortionMeshColumns = distortionMeshColumns; }
69        int getDistortionMeshColumns() const    { return _distortionMeshColumns; }
70
71        void setMeshType(GLenum meshType) { _meshType = meshType; }
72    inline GLenum getMeshType() const { return _meshType; }
73
74        void setIntensityMap(osg::Image* intensityMap)          { _intensityMap = intensityMap; }
75        const osg::Image* getIntensityMap() const       { return _intensityMap; }
76
77
78        void setTexUnitScene(unsigned int texUnitScene)         { _texUnitScene = texUnitScene; }
79        unsigned int getTexUnitScene() const    { return _texUnitScene; }
80
81        void setTexUnitIntensityMap(unsigned int texUnitIntensityMap)   { _texUnitIntensityMap = texUnitIntensityMap; }
82        unsigned int getTexUnitIntensityMap() const     { return _texUnitIntensityMap; }
83
84        void setViewOffset(const osg::Matrixd& viewOffset)      { _viewOffset = viewOffset; }
85        const osg::Matrixd& getViewOffset() const       { return _viewOffset; }
86
87        void setProjectionOffset(const osg::Matrixd& projectionOffset)          { _projectionOffset = projectionOffset; }
88        const osg::Matrixd& getProjectionOffset() const { return _projectionOffset; }
89
90        void setShowIntensityMapOnly(bool show) {_showIntesityMapMapOnly = show;}
91        bool getShowIntensityMapOnly() const    { return _showIntesityMapMapOnly;}
92
93
94private:
95        int _distortionMeshRows;
96        int _distortionMeshColumns;
97        GLenum _meshType;
98       
99        osg::ref_ptr<osg::Image> _intensityMap;
100        unsigned int _texUnitScene;
101        unsigned int _texUnitIntensityMap;
102
103        osg::Matrixd _viewOffset;
104        osg::Matrixd _projectionOffset;
105
106        bool _showIntesityMapMapOnly;   // Intensity Blending is done by a frag shader. To control it on runtime, the uniform must be bound to a central variable.
107
108        // Interconnect-Pointer to allow acces between distortion elements (osgViewer) and the distortion manipulator.
109        // These variable are therefor not saved/restored by the serializer but populated on runtime.
110        osg::observer_ptr<osg::Camera> _camera; // is used to pass the distortion cam from osgViewers setupDistortion() method to the manipulator.
111        osg::ref_ptr<osg::Switch> _distortionInternals; // definition: child #0 = mesh, #1 = highlighter, #2 HUD
112};
113
114}
115
116
117#endif
Note: See TracBrowser for help on using the repository browser.