Introduce osgVolume::PropertVisitor, and IsoSurface, MaximumImageProjection, Ligting and AlphaFunc Properties

This commit is contained in:
Robert Osfield
2009-01-15 15:57:04 +00:00
parent 3be239bdb2
commit ba94ea8c7d
8 changed files with 364 additions and 11 deletions

View File

@@ -73,6 +73,9 @@ class OSGVOLUME_EXPORT Layer : public osg::Object
/** Get the const Property that informs the VolumeTechnique how this layer should be rendered.*/
const Property* getProperty() const { return _property.get(); }
/** Add a property, automatically creating a CompositePorperty if one isn't already assigned.*/
void addProperty(Property* property);
/** increment the modified count."*/
virtual void dirty() {};

View File

@@ -15,11 +15,39 @@
#define OSGVOLUME_PROPERTY 1
#include <osg/TransferFunction>
#include <osg/Uniform>
#include <osgVolume/Export>
namespace osgVolume {
// forward decarle
class Property;
class CompositeProperty;
class TransferFunctionProperty;
class ScalarProperty;
class IsoSurfaceProperty;
class MaximumIntensityProjectionProperty;
class LightingProperty;
class AlphaFuncProperty;
class PropertyVisitor
{
public:
PropertyVisitor() {}
virtual ~PropertyVisitor() {}
virtual void apply(Property&) {}
virtual void apply(CompositeProperty&) {}
virtual void apply(TransferFunctionProperty&) {}
virtual void apply(ScalarProperty&) {}
virtual void apply(IsoSurfaceProperty&) {}
virtual void apply(AlphaFuncProperty&) {}
virtual void apply(MaximumIntensityProjectionProperty&) {}
virtual void apply(LightingProperty&) {}
};
class OSGVOLUME_EXPORT Property : public osg::Object
{
public:
@@ -31,6 +59,8 @@ class OSGVOLUME_EXPORT Property : public osg::Object
META_Object(osgVolume, Property);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
protected:
virtual ~Property();
@@ -47,6 +77,8 @@ class OSGVOLUME_EXPORT CompositeProperty : public Property
META_Object(osgVolume, CompositeProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
void clear();
typedef std::vector< osg::ref_ptr<Property> > Properties;
@@ -78,10 +110,21 @@ class OSGVOLUME_EXPORT TransferFunctionProperty : public Property
TransferFunctionProperty(osg::TransferFunction* tf = 0);
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
TransferFunctionProperty(const TransferFunctionProperty& tfProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
TransferFunctionProperty(const TransferFunctionProperty& tfp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, TransferFunctionProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
/** Set the transfer function.*/
void setTransferFunction(osg::TransferFunction* tf) { _tf = tf; }
/** Get the transfer function.*/
osg::TransferFunction* getTransferFunction() { return _tf.get(); }
/** Get the const transfer function.*/
const osg::TransferFunction* getTransferFunction() const { return _tf.get(); }
protected:
virtual ~TransferFunctionProperty() {}
@@ -90,6 +133,111 @@ class OSGVOLUME_EXPORT TransferFunctionProperty : public Property
};
class OSGVOLUME_EXPORT ScalarProperty : public Property
{
public:
ScalarProperty();
ScalarProperty(const std::string& scaleName, float value);
ScalarProperty(const ScalarProperty& scalarProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, ScalarProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
/** Set the value.*/
void setValue(float v) { _uniform->set(v); }
/** Get the value.*/
float getValue() const { float v; _uniform->get(v); return v; }
/** Get the underlying uniform.*/
osg::Uniform* getUniform() { return _uniform.get(); }
/** Get the underlying uniform.*/
const osg::Uniform* getUniform() const { return _uniform.get(); }
protected:
virtual ~ScalarProperty() {}
osg::ref_ptr<osg::Uniform> _uniform;
};
class OSGVOLUME_EXPORT IsoSurfaceProperty : public ScalarProperty
{
public:
IsoSurfaceProperty(float value=1.0);
IsoSurfaceProperty(const IsoSurfaceProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, IsoSurfaceProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
protected:
virtual ~IsoSurfaceProperty() {}
};
class OSGVOLUME_EXPORT AlphaFuncProperty : public ScalarProperty
{
public:
AlphaFuncProperty(float value=1.0);
AlphaFuncProperty(const AlphaFuncProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, AlphaFuncProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
protected:
virtual ~AlphaFuncProperty() {}
};
class OSGVOLUME_EXPORT MaximumIntensityProjectionProperty : public Property
{
public:
MaximumIntensityProjectionProperty();
MaximumIntensityProjectionProperty(const MaximumIntensityProjectionProperty& mipp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, MaximumIntensityProjectionProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
protected:
virtual ~MaximumIntensityProjectionProperty() {}
};
class OSGVOLUME_EXPORT LightingProperty : public Property
{
public:
LightingProperty();
LightingProperty(const LightingProperty& mipp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgVolume, LightingProperty);
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
protected:
virtual ~LightingProperty() {}
};
}
#endif

View File

@@ -117,16 +117,17 @@ class OSGVOLUME_EXPORT VolumeTile : public osg::Group
void setLayer(Layer* layer) { _layer = layer; }
Layer* getLayer() { return _layer.get(); }
const Layer* getLayer() const { return _layer.get(); }
const Layer* getLayer() const { return _layer.get(); }
/** Set the VolumeTechnique*/
/** Set the VolumeTechnique that will be used to render this tile. */
void setVolumeTechnique(VolumeTechnique* VolumeTechnique);
/** Get the VolumeTechnique*/
/** Get the VolumeTechnique that will be used to render this tile. */
VolumeTechnique* getVolumeTechnique() { return _volumeTechnique.get(); }
/** Get the const VolumeTechnique*/
/** Get the const VolumeTechnique that will be used to render this tile. */
const VolumeTechnique* getVolumeTechnique() const { return _volumeTechnique.get(); }