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
RevLine 
[344]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>
[353]23#include <osg/Camera>
24#include <osg/Switch>
[360]25#include <osg/Shader>
[344]26
27namespace osgViewer {
28
29class DistortionSet : public osg::Object
30{
31public:
[357]32        enum DistortionInternals {
33                MESH = 0,
34                HIGHLIGHTER = 1,
35                HUD = 2
36        };
37
[344]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),
[350]48                _projectionOffset(ds._projectionOffset),
49                _showIntesityMapMapOnly(ds._showIntesityMapMapOnly){}
[344]50
51        DistortionSet();
52        virtual ~DistortionSet();
53
[350]54        // Working access
55        osg::Image* getIntensityMap()  { return _intensityMap; }        // Also for manipulating the intensity map
56        bool& getShowIntensityMapOnlyAsRef()    { return _showIntesityMapMapOnly;}
57
[353]58        void setDistortionCamera(osg::Camera* camera)   { _camera = camera;}
59        osg::Camera* getDistortionCamera()      { return _camera.get(); }
[350]60
[353]61        osg::Switch* getDistortionInternals()   { return _distortionInternals; }
[350]62
[353]63
64
[360]65
66
[350]67        // Serializer Access
[344]68        void setDistortionMeshRows(int distortionMeshRows)              { _distortionMeshRows = distortionMeshRows; }
[345]69        int getDistortionMeshRows() const       { return _distortionMeshRows; }
[344]70
71        void setDistortionMeshColumns(int distortionMeshColumns)                { _distortionMeshColumns = distortionMeshColumns; }
[345]72        int getDistortionMeshColumns() const    { return _distortionMeshColumns; }
[344]73
[345]74        void setMeshType(GLenum meshType) { _meshType = meshType; }
75    inline GLenum getMeshType() const { return _meshType; }
76
[344]77        void setIntensityMap(osg::Image* intensityMap)          { _intensityMap = intensityMap; }
[350]78        const osg::Image* getIntensityMap() const       { return _intensityMap; }
[344]79
[350]80
[344]81        void setTexUnitScene(unsigned int texUnitScene)         { _texUnitScene = texUnitScene; }
[345]82        unsigned int getTexUnitScene() const    { return _texUnitScene; }
[344]83
84        void setTexUnitIntensityMap(unsigned int texUnitIntensityMap)   { _texUnitIntensityMap = texUnitIntensityMap; }
[345]85        unsigned int getTexUnitIntensityMap() const     { return _texUnitIntensityMap; }
[344]86
87        void setViewOffset(const osg::Matrixd& viewOffset)      { _viewOffset = viewOffset; }
[345]88        const osg::Matrixd& getViewOffset() const       { return _viewOffset; }
[344]89
90        void setProjectionOffset(const osg::Matrixd& projectionOffset)          { _projectionOffset = projectionOffset; }
[345]91        const osg::Matrixd& getProjectionOffset() const { return _projectionOffset; }
[344]92
[350]93        void setShowIntensityMapOnly(bool show) {_showIntesityMapMapOnly = show;}
94        bool getShowIntensityMapOnly() const    { return _showIntesityMapMapOnly;}
95
96
[344]97private:
98        int _distortionMeshRows;
99        int _distortionMeshColumns;
[345]100        GLenum _meshType;
[344]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
[350]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.
[353]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.
[357]114        osg::ref_ptr<osg::Switch> _distortionInternals; // definition: child #0 = mesh, #1 = highlighter, #2 HUD
[344]115};
116
117}
118
119
120#endif
Note: See TracBrowser for help on using the repository browser.