VolumeSettings 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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 OSGVOLUMESETTINGS
  14. #define OSGVOLUMESETTINGS 1
  15. #include <osg/Object>
  16. #include <osgVolume/Property>
  17. namespace osgVolume {
  18. class OSGVOLUME_EXPORT VolumeSettings : public Property
  19. {
  20. public:
  21. VolumeSettings();
  22. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  23. VolumeSettings(const VolumeSettings&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  24. META_Object(osgVolume, VolumeSettings);
  25. virtual void accept(PropertyVisitor& pv);
  26. virtual void traverse(PropertyVisitor& pv);
  27. void setFilename(const std::string& str) { _filename = str; dirty(); }
  28. const std::string& getFilename() const { return _filename; }
  29. enum Technique
  30. {
  31. FixedFunction,
  32. RayTraced,
  33. MultiPass
  34. };
  35. void setTechnique(Technique technique) { _technique = technique; dirty(); }
  36. Technique getTechnique() const { return _technique; }
  37. enum ShadingModel
  38. {
  39. Standard,
  40. Light,
  41. Isosurface,
  42. MaximumIntensityProjection
  43. };
  44. void setShadingModel(ShadingModel sm) { _shadingModel = sm; dirty(); }
  45. ShadingModel getShadingModel() const { return _shadingModel; }
  46. void setSampleRatio(float sr) { _sampleRatioProperty->setValue(sr); dirty(); }
  47. float getSampleRatio() const { return _sampleRatioProperty->getValue(); }
  48. void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMovingProperty->setValue(sr); dirty(); }
  49. float getSampleRatioWhenMoving() const { return _sampleRatioWhenMovingProperty->getValue(); }
  50. void setCutoff(float co);
  51. float getCutoff() const { return _cutoffProperty->getValue(); }
  52. void setTransparency(float t) { _transparencyProperty->setValue(t); dirty(); }
  53. float getTransparency() const { return _transparencyProperty->getValue(); }
  54. SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); }
  55. const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); }
  56. SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); }
  57. const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); }
  58. AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); }
  59. const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); }
  60. TransparencyProperty* getTransparencyProperty() { return _transparencyProperty.get(); }
  61. const TransparencyProperty* getTransparencyProperty() const { return _transparencyProperty.get(); }
  62. IsoSurfaceProperty* getIsoSurfaceProperty() { return _isoSurfaceProperty.get(); }
  63. const IsoSurfaceProperty* getIsoSurfaceProperty() const { return _isoSurfaceProperty.get(); }
  64. protected:
  65. virtual ~VolumeSettings() {}
  66. std::string _filename;
  67. Technique _technique;
  68. ShadingModel _shadingModel;
  69. osg::ref_ptr<SampleRatioProperty> _sampleRatioProperty;
  70. osg::ref_ptr<SampleRatioWhenMovingProperty> _sampleRatioWhenMovingProperty;
  71. osg::ref_ptr<AlphaFuncProperty> _cutoffProperty;
  72. osg::ref_ptr<TransparencyProperty> _transparencyProperty;
  73. osg::ref_ptr<IsoSurfaceProperty> _isoSurfaceProperty;
  74. };
  75. }
  76. #endif