File: PanoramicSphericalDisplay

package info (click to toggle)
openscenegraph 3.2.3%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 32,824 kB
  • sloc: cpp: 370,040; ansic: 9,071; java: 1,020; yacc: 548; objc: 288; makefile: 285; xml: 155; lex: 151
file content (75 lines) | stat: -rw-r--r-- 3,098 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSGVIEWER_PanoramicSphericalDisplay
#define OSGVIEWER_PanoramicSphericalDisplay 1

#include <osgViewer/View>

namespace osgViewer {

/** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public ViewConfig
{
    public:
        
        PanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()):
            _radius(radius),
            _collar(collar),
            _screenNum(screenNum),
            _intensityMap(intensityMap),
            _projectorMatrix(projectorMatrix) {}
            
        PanoramicSphericalDisplay(const PanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
            ViewConfig(rhs, copyop),
            _radius(rhs._radius),
            _collar(rhs._collar),
            _screenNum(rhs._screenNum),
            _intensityMap(rhs._intensityMap),
            _projectorMatrix(rhs._projectorMatrix) {}
            
        
        META_Object(osgViewer,PanoramicSphericalDisplay);
        
        virtual void configure(osgViewer::View& view) const;
        
        void setRadius(double r) { _radius = r; }
        double getRadius() const { return _radius; }
        
        void setCollar(double r) { _collar = r; }
        double getCollar() const { return _collar; }
        
        void setScreenNum(unsigned int n) { _screenNum = n; }
        unsigned int getScreenNum() const { return _screenNum; }
        
        void setIntensityMap(osg::Image* im) { _intensityMap = im; }
        const osg::Image* getIntensityMap() const { return _intensityMap.get(); }
        
        void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
        const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }      
        
    protected:
        
        osg::Geometry* createParoramicSphericalDisplayDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, double sphere_radius, double collar_radius, osg::Image* intensityMap, const osg::Matrix& projectorMatrix) const;

        double _radius;
        double _collar;
        unsigned int _screenNum;
        osg::ref_ptr<osg::Image> _intensityMap;
        osg::Matrixd _projectorMatrix;
};

}


#endif