Added SampleDensityWhenMovingProperty to control LOD property of osgVolume.

This commit is contained in:
Robert Osfield
2011-03-17 15:37:39 +00:00
parent 79cb22eb06
commit 89eadcfe82
5 changed files with 49 additions and 6 deletions

View File

@@ -179,6 +179,21 @@ SampleDensityProperty::SampleDensityProperty(const SampleDensityProperty& isp,co
}
/////////////////////////////////////////////////////////////////////////////
//
// SampleDensityWhenMovingProperty
//
SampleDensityWhenMovingProperty::SampleDensityWhenMovingProperty(float value):
ScalarProperty("SampleDensityValue",value)
{
}
SampleDensityWhenMovingProperty::SampleDensityWhenMovingProperty(const SampleDensityWhenMovingProperty& isp,const osg::CopyOp& copyop):
ScalarProperty(isp, copyop)
{
}
/////////////////////////////////////////////////////////////////////////////
//
// TransparencyProperty
@@ -246,6 +261,7 @@ void CollectPropertiesVisitor::apply(AlphaFuncProperty& af) { _afProperty = ⁡
void CollectPropertiesVisitor::apply(MaximumIntensityProjectionProperty& mip) { _mipProperty = &mip; }
void CollectPropertiesVisitor::apply(LightingProperty& lp) { _lightingProperty = &lp; }
void CollectPropertiesVisitor::apply(SampleDensityProperty& sdp) { _sampleDensityProperty = &sdp; }
void CollectPropertiesVisitor::apply(SampleDensityWhenMovingProperty& sdp) { _sampleDensityWhenMovingProperty = &sdp; }
void CollectPropertiesVisitor::apply(TransparencyProperty& tp) { _transparencyProperty = &tp; }

View File

@@ -534,9 +534,11 @@ void RayTracedTechnique::init()
}
_lodStateSet = new osg::StateSet;
_lodStateSet->addUniform(new osg::Uniform("SampleDensityValue",0.01f), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
if (cpv._sampleDensityWhenMovingProperty.valid())
{
_whenMovingStateSet = new osg::StateSet;
_whenMovingStateSet->addUniform(cpv._sampleDensityWhenMovingProperty->getUniform(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
}
}
void RayTracedTechnique::update(osgUtil::UpdateVisitor* uv)
@@ -548,7 +550,7 @@ void RayTracedTechnique::cull(osgUtil::CullVisitor* cv)
{
if (!_transform.valid()) return;
if (_lodStateSet.valid())
if (_whenMovingStateSet.valid())
{
bool moving = false;
{
@@ -570,7 +572,7 @@ void RayTracedTechnique::cull(osgUtil::CullVisitor* cv)
if (moving)
{
cv->pushStateSet(_lodStateSet.get());
cv->pushStateSet(_whenMovingStateSet.get());
_transform->accept(*cv);
cv->popStateSet();
}