PanoramicSphericalDisplay 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  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.
  7. *
  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.
  12. */
  13. #ifndef OSGVIEWER_PanoramicSphericalDisplay
  14. #define OSGVIEWER_PanoramicSphericalDisplay 1
  15. #include <osgViewer/View>
  16. namespace osgViewer {
  17. /** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
  18. class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public ViewConfig
  19. {
  20. public:
  21. PanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()):
  22. _radius(radius),
  23. _collar(collar),
  24. _screenNum(screenNum),
  25. _intensityMap(intensityMap),
  26. _projectorMatrix(projectorMatrix) {}
  27. PanoramicSphericalDisplay(const PanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
  28. ViewConfig(rhs, copyop),
  29. _radius(rhs._radius),
  30. _collar(rhs._collar),
  31. _screenNum(rhs._screenNum),
  32. _intensityMap(rhs._intensityMap),
  33. _projectorMatrix(rhs._projectorMatrix) {}
  34. META_Object(osgViewer,PanoramicSphericalDisplay);
  35. virtual void configure(osgViewer::View& view) const;
  36. void setRadius(double r) { _radius = r; }
  37. double getRadius() const { return _radius; }
  38. void setCollar(double r) { _collar = r; }
  39. double getCollar() const { return _collar; }
  40. void setScreenNum(unsigned int n) { _screenNum = n; }
  41. unsigned int getScreenNum() const { return _screenNum; }
  42. void setIntensityMap(osg::Image* im) { _intensityMap = im; }
  43. const osg::Image* getIntensityMap() const { return _intensityMap.get(); }
  44. void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
  45. const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }
  46. protected:
  47. 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;
  48. double _radius;
  49. double _collar;
  50. unsigned int _screenNum;
  51. osg::ref_ptr<osg::Image> _intensityMap;
  52. osg::Matrixd _projectorMatrix;
  53. };
  54. }
  55. #endif