Refactor VolumeSettings so that it's subclassed from osgVolume::Property

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14348 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-07-03 10:01:46 +00:00
parent c4f199d1b5
commit 3c6a1ec117
2 changed files with 37 additions and 23 deletions

View File

@@ -15,11 +15,11 @@
#define OSGVOLUMESETTINGS 1
#include <osg/Object>
#include <osgVolume/Export>
#include <osgVolume/Property>
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> _sampleRatioProperty;
osg::ref_ptr<SampleRatioWhenMovingProperty> _sampleRatioWhenMovingProperty;
osg::ref_ptr<AlphaFuncProperty> _cutoffProperty;
osg::ref_ptr<TransparencyProperty> _transparencyProperty;
};
}

View File

@@ -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);
}