SphericalDisplay 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_SphericalDisplay
  14. #define OSGVIEWER_SphericalDisplay 1
  15. #include <osgViewer/View>
  16. namespace osgViewer {
  17. /** spherical display using 6 slave cameras rendering the 6 sides of a cube map, and 7th camera doing distortion correction to present on a spherical display.*/
  18. class OSGVIEWER_EXPORT SphericalDisplay : public ViewConfig
  19. {
  20. public:
  21. SphericalDisplay(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. SphericalDisplay(const SphericalDisplay& 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,SphericalDisplay);
  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* create3DSphericalDisplayDistortionMesh(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. #if 0
  55. /** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
  56. class OSGVIEWER_EXPORT ViewForPanoramicSphericalDisplay : public Config
  57. {
  58. public:
  59. ViewForPanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
  60. ViewForPanoramicSphericalDisplay(const ViewForPanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  61. META_Object(osgViewer,ViewOnSingleScreen);
  62. virtual void configure(osgViewer::View& view) const;
  63. void setRadius(double r) { _radius = r; }
  64. double getRadius() const { return _radius; }
  65. void setCollar(double r) { _collar = r; }
  66. double getCollar() const { return _collar; }
  67. void setScreenNum(unsigned int n) { _screenNum = n; }
  68. unsigned int getScreenNum() const { return _screenNum; }
  69. void setIntensityMap(osg::Image* im) { _intensityMap = im; }
  70. const osg::Image* getIntensityMap() const { return _intensityMap; }
  71. void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
  72. const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }
  73. protected:
  74. double _radius;
  75. double _collar;
  76. unsigned int _screenNum;
  77. osg::ref_ref<osg::Image> _intensityMap;
  78. osg::Matrixd _projectorMatrix;
  79. };
  80. /** autostereoscopic Philips WoWvx display.*/
  81. class OSGVIEWER_EXPORT ViewForWoWVxDisplay : public Config
  82. {
  83. public:
  84. ViewForWoWVxDisplay();
  85. ViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C);
  86. ViewForWoWVxDisplay(const ViewForWoWVxDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  87. META_Object(osgViewer,ViewForWoWVxDisplay);
  88. virtual void configure(osgViewer::View& view) const;
  89. void setScreenNum(unsigned int n) { _screenNum = n; }
  90. unsigned int getScreenNum() const { return _screenNum; }
  91. void set(unsigned char c) { _wow_content = c; }
  92. double get() const { return _wow_content; }
  93. void set(unsigned char c) { _wow_factor = c; }
  94. double get() const { return _wow_factor; }
  95. void set(unsigned char c) { _wow_offset = c; }
  96. double get() const { return _wow_offset; }
  97. void setWowDisparityZD(float c) { _wow_disparity_Zd = c; }
  98. float getWowDisparityZD() const { return _wow_disparity_Zd; }
  99. void setWowDisparityVZ(float c) { _wow_disparity_vz = c; }
  100. float getWowDisparityVZ() const { return _wow_disparity_vz; }
  101. void setWowDisparityM(float c) { _wow_disparity_M = c; }
  102. float getWowDisparityM() const { return _wow_disparity_M; }
  103. void setWowDisparityC(float c) { _wow_disparity_C = c; }
  104. float getWowDisparityC() const { return _wow_disparity_C; }
  105. protected:
  106. unsigned int _screenNum;
  107. unsigned char _wow_content;
  108. unsigned char _wow_factor;
  109. unsigned char _wow_offset;
  110. float _wow_disparity_Zd;
  111. float _wow_disparity_vz;
  112. float _wow_disparity_M;
  113. float _wow_disparity_C;
  114. };
  115. /** Configure view with DepthPartition.*/
  116. class OSGVIEWER_EXPORT DepthPartition : public Config
  117. {
  118. public:
  119. DepthPartition(DepthPartitionSettings* dsp=0);
  120. DepthPartition(const ViewForWoWVxDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  121. META_Object(osgViewer,DepthPartition);
  122. void setDepthPartionSettings(DepthPartitionSettings* dsp) const { _dps = dps; }
  123. const DepthPartitionSettings* getDepthPartionSettings() const { return _dps; }
  124. /** for setting up depth partitioning on the specified camera.*/
  125. bool setUpDepthPartitionForCamera(osg::Camera* cameraToPartition, DepthPartitionSettings* dps=0);
  126. virtual void configure(osgViewer::View& view) const;
  127. protected:
  128. };
  129. #endif
  130. }
  131. #endif