1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGVIEWER_PanoramicSphericalDisplay
15#define OSGVIEWER_PanoramicSphericalDisplay 1
17#include <osgViewer/View>
21/** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
22class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public ViewConfig
26 PanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()):
29 _screenNum(screenNum),
30 _intensityMap(intensityMap),
31 _projectorMatrix(projectorMatrix) {}
33 PanoramicSphericalDisplay(const PanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
34 ViewConfig(rhs, copyop),
37 _screenNum(rhs._screenNum),
38 _intensityMap(rhs._intensityMap),
39 _projectorMatrix(rhs._projectorMatrix) {}
42 META_Object(osgViewer,PanoramicSphericalDisplay);
44 virtual void configure(osgViewer::View& view) const;
46 void setRadius(double r) { _radius = r; }
47 double getRadius() const { return _radius; }
49 void setCollar(double r) { _collar = r; }
50 double getCollar() const { return _collar; }
52 void setScreenNum(unsigned int n) { _screenNum = n; }
53 unsigned int getScreenNum() const { return _screenNum; }
55 void setIntensityMap(osg::Image* im) { _intensityMap = im; }
56 const osg::Image* getIntensityMap() const { return _intensityMap.get(); }
58 void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
59 const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }
63 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;
67 unsigned int _screenNum;
68 osg::ref_ptr<osg::Image> _intensityMap;
69 osg::Matrixd _projectorMatrix;