source: experimental/distortionNG/DistortionSet.h @ 353

Last change on this file since 353 was 353, checked in by Torben Dannhauer, 12 years ago

DistortionManipulator? is working (alpha stadium)

File size: 4.4 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        META_Object(osgViewer,DistortionSet);   // Required for serializer
32
33        DistortionSet(const osgViewer::DistortionSet& ds, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): // Required for serializer
34                _distortionMeshRows(ds._distortionMeshRows),
35                _distortionMeshColumns(ds._distortionMeshColumns),
36                //osg::PrimitiveSet::Mode _MeshType
37                _intensityMap(ds._intensityMap),
38                _texUnitScene(ds._texUnitScene),
39                _texUnitIntensityMap(ds._texUnitIntensityMap),
40                _viewOffset(ds._viewOffset),
41                _projectionOffset(ds._projectionOffset),
42                _showIntesityMapMapOnly(ds._showIntesityMapMapOnly){}
43
44        DistortionSet();
45        virtual ~DistortionSet();
46
47        // Working access
48        osg::Image* getIntensityMap()  { return _intensityMap; }        // Also for manipulating the intensity map
49        bool& getShowIntensityMapOnlyAsRef()    { return _showIntesityMapMapOnly;}
50
51        void setDistortionCamera(osg::Camera* camera)   { _camera = camera;}
52        osg::Camera* getDistortionCamera()      { return _camera.get(); }
53
54        osg::Switch* getDistortionInternals()   { return _distortionInternals; }
55
56
57
58        // Serializer Access
59        void setDistortionMeshRows(int distortionMeshRows)              { _distortionMeshRows = distortionMeshRows; }
60        int getDistortionMeshRows() const       { return _distortionMeshRows; }
61
62        void setDistortionMeshColumns(int distortionMeshColumns)                { _distortionMeshColumns = distortionMeshColumns; }
63        int getDistortionMeshColumns() const    { return _distortionMeshColumns; }
64
65        void setMeshType(GLenum meshType) { _meshType = meshType; }
66    inline GLenum getMeshType() const { return _meshType; }
67
68        void setIntensityMap(osg::Image* intensityMap)          { _intensityMap = intensityMap; }
69        const osg::Image* getIntensityMap() const       { return _intensityMap; }
70
71
72        void setTexUnitScene(unsigned int texUnitScene)         { _texUnitScene = texUnitScene; }
73        unsigned int getTexUnitScene() const    { return _texUnitScene; }
74
75        void setTexUnitIntensityMap(unsigned int texUnitIntensityMap)   { _texUnitIntensityMap = texUnitIntensityMap; }
76        unsigned int getTexUnitIntensityMap() const     { return _texUnitIntensityMap; }
77
78        void setViewOffset(const osg::Matrixd& viewOffset)      { _viewOffset = viewOffset; }
79        const osg::Matrixd& getViewOffset() const       { return _viewOffset; }
80
81        void setProjectionOffset(const osg::Matrixd& projectionOffset)          { _projectionOffset = projectionOffset; }
82        const osg::Matrixd& getProjectionOffset() const { return _projectionOffset; }
83
84        void setShowIntensityMapOnly(bool show) {_showIntesityMapMapOnly = show;}
85        bool getShowIntensityMapOnly() const    { return _showIntesityMapMapOnly;}
86
87
88private:
89        int _distortionMeshRows;
90        int _distortionMeshColumns;
91        GLenum _meshType;
92       
93        osg::ref_ptr<osg::Image> _intensityMap;
94        unsigned int _texUnitScene;
95        unsigned int _texUnitIntensityMap;
96
97        osg::Matrixd _viewOffset;
98        osg::Matrixd _projectionOffset;
99
100        bool _showIntesityMapMapOnly;   // Intensity Blending is done by a frag shader. To control it on runtime, the uniform must be bound to a central variable.
101
102        // Interconnect-Pointer to allow acces between distortion elements (osgViewer) and the distortion manipulator.
103        // These variable are therefor not saved/restored by the serializer but populated on runtime.
104        osg::observer_ptr<osg::Camera> _camera; // is used to pass the distortion cam from osgViewers setupDistortion() method to the manipulator.
105        osg::ref_ptr<osg::Switch> _distortionInternals;
106};
107
108}
109
110
111#endif
Note: See TracBrowser for help on using the repository browser.