Changed enum usage to use the new osgVolume::VolumeSettings versions and added support for reading a VolumeSettings file.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14349 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-07-03 13:01:05 +00:00
parent 3c6a1ec117
commit 7a18876c5b
3 changed files with 29 additions and 31 deletions

View File

@ -30,7 +30,7 @@
#include <osgDB/FileUtils>
#include <osgVolume/VolumeTile>
#include <osgVolume/Property>
#include <osgVolume/VolumeSettings>
#include <osgPresentation/deprecated/AnimationMaterial>
#include <osgPresentation/deprecated/SlideEventHandler>
@ -284,23 +284,11 @@ public:
struct VolumeData
{
enum ShadingModel
{
Standard,
Light,
Isosurface,
MaximumIntensityProjection
};
enum Technique
{
FixedFunction,
RayTraced,
MultiPass
};
typedef osgVolume::VolumeSettings::ShadingModel ShadingModel;
typedef osgVolume::VolumeSettings::Technique Technique;
VolumeData():
shadingModel(Standard),
shadingModel(osgVolume::VolumeSettings::Standard),
useTabbedDragger(false),
useTrackballDragger(false),
region_in_pixel_coords(false),
@ -311,12 +299,14 @@ public:
sampleRatioValue("1.0"),
colorSpaceOperation(osg::NO_COLOR_SPACE_OPERATION),
colorModulate(1.0f,1.0f,1.0f,1.0f),
technique(RayTraced)
technique(osgVolume::VolumeSettings::RayTraced)
{
hullPositionData.position = osg::Vec3(0.0,0.0,0.0);
hullPositionData.frame = osgPresentation::SlideShowConstructor::MODEL;
}
osg::ref_ptr<osgVolume::VolumeSettings> volumeSettings;
std::string options;
ShadingModel shadingModel;
osg::ref_ptr<osg::TransferFunction1D> transferFunction;

View File

@ -1428,23 +1428,31 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
}
}
std::string vs;
if (getProperty(cur, "vs", vs) || getProperty(cur, "VolumeSettings", vs))
{
volumeData.volumeSettings = osgDB::readFile<osgVolume::VolumeSettings>(vs);
OSG_NOTICE<<"VolumeSetting read "<<vs<<" "<<volumeData.volumeSettings.get()<<std::endl;
}
if (!volumeData.volumeSettings) volumeData.volumeSettings = new osgVolume::VolumeSettings;
// check the rendering technique/shading model to use
std::string technique;
if (getProperty(cur, "technique", technique))
{
if (match(technique,"standard")) volumeData.shadingModel = osgPresentation::SlideShowConstructor::VolumeData::Standard;
else if (match(technique,"mip")) volumeData.shadingModel = osgPresentation::SlideShowConstructor::VolumeData::MaximumIntensityProjection;
else if (match(technique,"isosurface") || match(technique,"iso") ) volumeData.shadingModel = osgPresentation::SlideShowConstructor::VolumeData::Isosurface;
else if (match(technique,"light")) volumeData.shadingModel = osgPresentation::SlideShowConstructor::VolumeData::Light;
if (match(technique,"standard")) volumeData.shadingModel = osgVolume::VolumeSettings::Standard;
else if (match(technique,"mip")) volumeData.shadingModel = osgVolume::VolumeSettings::MaximumIntensityProjection;
else if (match(technique,"isosurface") || match(technique,"iso") ) volumeData.shadingModel = osgVolume::VolumeSettings::Isosurface;
else if (match(technique,"light")) volumeData.shadingModel = osgVolume::VolumeSettings::Light;
}
std::string renderer;
if (getProperty(cur, "renderer", renderer))
{
if (match(renderer,"FixedFunction")) volumeData.technique = osgPresentation::SlideShowConstructor::VolumeData::FixedFunction;
else if (match(renderer,"RayTraced")) volumeData.technique = osgPresentation::SlideShowConstructor::VolumeData::RayTraced;
else if (match(renderer,"MultiPass")) volumeData.technique = osgPresentation::SlideShowConstructor::VolumeData::MultiPass;
if (match(renderer,"FixedFunction")) volumeData.technique = osgVolume::VolumeSettings::FixedFunction;
else if (match(renderer,"RayTraced")) volumeData.technique = osgVolume::VolumeSettings::RayTraced;
else if (match(renderer,"MultiPass")) volumeData.technique = osgVolume::VolumeSettings::MultiPass;
}
std::string hull;

View File

@ -2836,23 +2836,23 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
switch(volumeData.shadingModel)
{
case(VolumeData::Standard): sp->setActiveProperty(0); break;
case(VolumeData::Light): sp->setActiveProperty(1); break;
case(VolumeData::Isosurface): sp->setActiveProperty(2); break;
case(VolumeData::MaximumIntensityProjection): sp->setActiveProperty(3); break;
case(osgVolume::VolumeSettings::Standard): sp->setActiveProperty(0); break;
case(osgVolume::VolumeSettings::Light): sp->setActiveProperty(1); break;
case(osgVolume::VolumeSettings::Isosurface): sp->setActiveProperty(2); break;
case(osgVolume::VolumeSettings::MaximumIntensityProjection): sp->setActiveProperty(3); break;
}
layer->addProperty(sp.get());
switch(volumeData.technique)
{
case(VolumeData::FixedFunction):
case(osgVolume::VolumeSettings::FixedFunction):
tile->setVolumeTechnique(new osgVolume::FixedFunctionTechnique);
break;
case(VolumeData::RayTraced):
case(osgVolume::VolumeSettings::RayTraced):
tile->setVolumeTechnique(new osgVolume::RayTracedTechnique);
break;
case(VolumeData::MultiPass):
case(osgVolume::VolumeSettings::MultiPass):
tile->setVolumeTechnique(new osgVolume::MultipassTechnique);
break;
}