Added setting of the IsoSurfaceProperty in VolumeSettings

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14436 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-09-03 15:54:47 +00:00
parent 4f6dbf5623
commit 21fc2fae8d
4 changed files with 40 additions and 15 deletions

View File

@@ -59,25 +59,33 @@ class OSGVOLUME_EXPORT VolumeSettings : public Property
void setSampleRatio(float sr) { _sampleRatioProperty->setValue(sr); dirty(); }
float getSampleRatio() const { return _sampleRatioProperty->getValue(); }
SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); }
const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); }
void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMovingProperty->setValue(sr); dirty(); }
float getSampleRatioWhenMoving() const { return _sampleRatioWhenMovingProperty->getValue(); }
SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); }
const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); }
void setCutoff(float co) { _cutoffProperty->setValue(co); dirty(); }
void setCutoff(float co);
float getCutoff() const { return _cutoffProperty->getValue(); }
AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); }
const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); }
void setTransparency(float t) { _transparencyProperty->setValue(t); dirty(); }
float getTransparency() const { return _transparencyProperty->getValue(); }
SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); }
const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); }
SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); }
const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); }
AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); }
const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); }
TransparencyProperty* getTransparencyProperty() { return _transparencyProperty.get(); }
const TransparencyProperty* getTransparencyProperty() const { return _transparencyProperty.get(); }
protected:
IsoSurfaceProperty* getIsoSurfaceProperty() { return _isoSurfaceProperty.get(); }
const IsoSurfaceProperty* getIsoSurfaceProperty() const { return _isoSurfaceProperty.get(); }
protected:
virtual ~VolumeSettings() {}
@@ -90,6 +98,7 @@ class OSGVOLUME_EXPORT VolumeSettings : public Property
osg::ref_ptr<SampleRatioWhenMovingProperty> _sampleRatioWhenMovingProperty;
osg::ref_ptr<AlphaFuncProperty> _cutoffProperty;
osg::ref_ptr<TransparencyProperty> _transparencyProperty;
osg::ref_ptr<IsoSurfaceProperty> _isoSurfaceProperty;
};
}

View File

@@ -2927,7 +2927,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
{
// Isosurface
osgVolume::IsoSurfaceProperty* isp = new osgVolume::IsoSurfaceProperty(0.1);
osgVolume::IsoSurfaceProperty* isp = vs.valid() ? vs->getIsoSurfaceProperty() : new osgVolume::IsoSurfaceProperty(0.1);
setUpVolumeScalarProperty(tile.get(), isp, volumeData.alphaValue);
sp->addProperty(isp);

View File

@@ -21,7 +21,8 @@ VolumeSettings::VolumeSettings():
_sampleRatioProperty(new SampleRatioProperty(1.0f)),
_sampleRatioWhenMovingProperty(new SampleRatioWhenMovingProperty(1.0f)),
_cutoffProperty(new AlphaFuncProperty(0.0f)),
_transparencyProperty(new TransparencyProperty(1.0f))
_transparencyProperty(new TransparencyProperty(1.0f)),
_isoSurfaceProperty(new IsoSurfaceProperty(0.0f))
{
}
@@ -33,7 +34,8 @@ VolumeSettings::VolumeSettings(const VolumeSettings& vs,const osg::CopyOp& copyo
_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))
_transparencyProperty(osg::clone(vs._transparencyProperty.get(), copyop)),
_isoSurfaceProperty(osg::clone(vs._isoSurfaceProperty.get(), copyop))
{
}
@@ -44,8 +46,21 @@ void VolumeSettings::accept(PropertyVisitor& pv)
void VolumeSettings::traverse(PropertyVisitor& pv)
{
_sampleRatioProperty->accept(pv);
_sampleRatioWhenMovingProperty->accept(pv);
_cutoffProperty->accept(pv);
_transparencyProperty->accept(pv);
if (_sampleRatioProperty.valid()) _sampleRatioProperty->accept(pv);
if (_sampleRatioWhenMovingProperty.valid()) _sampleRatioWhenMovingProperty->accept(pv);
if (_cutoffProperty.valid()) _cutoffProperty->accept(pv);
if (_transparencyProperty.valid()) _transparencyProperty->accept(pv);
if (_isoSurfaceProperty.valid() && _shadingModel==Isosurface) _isoSurfaceProperty->accept(pv);
}
void VolumeSettings::setCutoff(float co)
{
_cutoffProperty->setValue(co);
if (_isoSurfaceProperty.valid())
{
OSG_NOTICE<<"Setting IsoSurface value to "<<co<<std::endl;
_isoSurfaceProperty->setValue(co);
}
dirty();
}

View File

@@ -33,6 +33,7 @@ REGISTER_OBJECT_WRAPPER( osgVolume_VolumeSettings,
ADD_OBJECT_SERIALIZER_NO_SET( SampleRatioWhenMovingProperty, osgVolume::SampleRatioWhenMovingProperty, NULL );
ADD_OBJECT_SERIALIZER_NO_SET( CutoffProperty, osgVolume::AlphaFuncProperty, NULL );
ADD_OBJECT_SERIALIZER_NO_SET( TransparencyProperty, osgVolume::TransparencyProperty, NULL );
ADD_OBJECT_SERIALIZER_NO_SET( IsoSurfaceProperty, osgVolume::IsoSurfaceProperty, NULL );
}