diff --git a/include/osgVolume/VolumeSettings b/include/osgVolume/VolumeSettings index cafc19cc7..609afdaa7 100644 --- a/include/osgVolume/VolumeSettings +++ b/include/osgVolume/VolumeSettings @@ -15,11 +15,11 @@ #define OSGVOLUMESETTINGS 1 #include -#include +#include namespace osgVolume { -class OSGVOLUME_EXPORT VolumeSettings : public osg::Object +class OSGVOLUME_EXPORT VolumeSettings : public Property { public: @@ -30,6 +30,8 @@ class OSGVOLUME_EXPORT VolumeSettings : public osg::Object META_Object(osgVolume, VolumeSettings); + virtual void accept(PropertyVisitor& pv); + enum Technique { FixedFunction, @@ -51,17 +53,21 @@ class OSGVOLUME_EXPORT VolumeSettings : public osg::Object void setShadingModel(ShadingModel sm) { _shadingModel = sm; } ShadingModel getShadingModel() const { return _shadingModel; } - void setSampleRatio(float sr) { _sampleRatio = sr; } - float getSampleRatio() const { return _sampleRatio; } + void setSampleRatio(float sr) { _sampleRatioProperty->setValue(sr); } + float getSampleRatio() const { return _sampleRatioProperty->getValue(); } + SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); } - void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMoving = sr; } - float getSampleRatioWhenMoving() const { return _sampleRatioWhenMoving; } + void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMovingProperty->setValue(sr); } + float getSampleRatioWhenMoving() const { return _sampleRatioWhenMovingProperty->getValue(); } + SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); } - void setCutoff(float co) { _cutoff = co; } - float getCutoff() const { return _cutoff; } + void setCutoff(float co) { _cutoffProperty->setValue(co); } + float getCutoff() const { return _cutoffProperty->getValue(); } + AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); } - void setTransparency(float t) { _transparency = t; } - float getTransparency() const { return _transparency; } + void setTransparency(float t) { _transparencyProperty->setValue(t); } + float getTransparency() const { return _transparencyProperty->getValue(); } + TransparencyProperty* getTransparencyProperty() const { return _transparencyProperty.get(); } protected: @@ -69,11 +75,11 @@ class OSGVOLUME_EXPORT VolumeSettings : public osg::Object Technique _technique; ShadingModel _shadingModel; - float _sampleRatio; - float _sampleRatioWhenMoving; - float _cutoff; - float _transparency; + osg::ref_ptr _sampleRatioProperty; + osg::ref_ptr _sampleRatioWhenMovingProperty; + osg::ref_ptr _cutoffProperty; + osg::ref_ptr _transparencyProperty; }; } diff --git a/src/osgVolume/VolumeSettings.cpp b/src/osgVolume/VolumeSettings.cpp index 696def6b6..343ca464e 100644 --- a/src/osgVolume/VolumeSettings.cpp +++ b/src/osgVolume/VolumeSettings.cpp @@ -18,20 +18,28 @@ using namespace osgVolume; VolumeSettings::VolumeSettings(): _technique(MultiPass), _shadingModel(Standard), - _sampleRatio(1.0f), - _sampleRatioWhenMoving(1.0f), - _cutoff(0.0f), - _transparency(1.0f) + _sampleRatioProperty(new SampleRatioProperty(1.0f)), + _sampleRatioWhenMovingProperty(new SampleRatioWhenMovingProperty(1.0f)), + _cutoffProperty(new AlphaFuncProperty(0.0f)), + _transparencyProperty(new TransparencyProperty(1.0f)) { } VolumeSettings::VolumeSettings(const VolumeSettings& vs,const osg::CopyOp& copyop): - osg::Object(vs, copyop), + Property(vs, copyop), _technique(vs._technique), _shadingModel(vs._shadingModel), - _sampleRatio(vs._sampleRatio), - _sampleRatioWhenMoving(vs._sampleRatioWhenMoving), - _cutoff(vs._cutoff), - _transparency(vs._transparency) + _sampleRatioProperty(osg::clone(vs._sampleRatioProperty.get(), copyop)), + _sampleRatioWhenMovingProperty(osg::clone(vs._sampleRatioWhenMovingProperty.get(), copyop)), + _cutoffProperty(osg::clone(vs._cutoffProperty.get(), copyop)), + _transparencyProperty(osg::clone(vs._transparencyProperty.get(), copyop)) { } + +void VolumeSettings::accept(PropertyVisitor& pv) +{ + _sampleRatioProperty->accept(pv); + _sampleRatioWhenMovingProperty->accept(pv); + _cutoffProperty->accept(pv); + _transparencyProperty->accept(pv); +}