source: experimental/distortionNG/DistortionSet.h @ 360

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