Added support to .p3d format's volume tag for the properties:

region="xmin ymin zmin xmax ymax zmax"
   alpha="float_value"
   cutoff="float_value"
   sampleDenstiy="float_value"
This commit is contained in:
Robert Osfield
2009-08-27 16:42:47 +00:00
parent 3f9216800d
commit ca78f3a6bc
3 changed files with 60 additions and 8 deletions

View File

@@ -160,6 +160,7 @@ public:
inline bool read(const char* str, int& value) const;
inline bool read(const char* str, float& value) const;
inline bool read(const char* str, double& value) const;
inline bool read(const char* str, int numberValues, float* values) const;
inline bool read(const char* str, osg::Vec2& value) const;
inline bool read(const char* str, osg::Vec3& value) const;
inline bool read(const char* str, osg::Vec4& value) const;
@@ -167,6 +168,7 @@ public:
inline bool read(const std::string& str, int& value) const;
inline bool read(const std::string& str, float& value) const;
inline bool read(const std::string& str, double& value) const;
inline bool read(const std::string& str, int numberValues, float* values) const;
inline bool read(const std::string& str, osg::Vec2& value) const;
inline bool read(const std::string& str, osg::Vec3& value) const;
inline bool read(const std::string& str, osg::Vec4& value) const;
@@ -175,6 +177,7 @@ public:
bool getProperty(osgDB::XmlNode*cur, const char* token, int& value) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, float& value) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, double& value) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, int numberValues, float* values) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, osg::Vec2& value) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, osg::Vec3& value) const;
bool getProperty(osgDB::XmlNode*cur, const char* token, osg::Vec4& value) const;
@@ -268,6 +271,18 @@ bool ReaderWriterP3DXML::read(const char* str, double& value) const
return !iss.fail();
}
bool ReaderWriterP3DXML::read(const char* str, int numberValues, float* values) const
{
if (!str) return false;
std::istringstream iss((const char*)str);
for(int i=0; i<numberValues && !iss.fail(); i++)
{
iss >> *values;
++values;
}
return !iss.fail();
}
bool ReaderWriterP3DXML::read(const char* str, osg::Vec2& value) const
{
if (!str) return false;
@@ -313,6 +328,18 @@ bool ReaderWriterP3DXML::read(const std::string& str, double& value) const
return !iss.fail();
}
bool ReaderWriterP3DXML::read(const std::string& str, int numberValues, float* values) const
{
std::istringstream iss(str);
for(int i=0; i<numberValues && !iss.fail(); i++)
{
iss >> *values;
++values;
}
return !iss.fail();
}
bool ReaderWriterP3DXML::read(const std::string& str, osg::Vec2& value) const
{
std::istringstream iss(str);
@@ -360,6 +387,13 @@ bool ReaderWriterP3DXML::getProperty(osgDB::XmlNode*cur, const char* token, doub
return read(itr->second,value);
}
bool ReaderWriterP3DXML::getProperty(osgDB::XmlNode*cur, const char* token, int numberValues, float* values) const
{
osgDB::XmlNode::Properties::iterator itr = cur->properties.find(token);
if (itr==cur->properties.end()) return false;
return read(itr->second, numberValues, values);
}
bool ReaderWriterP3DXML::getProperty(osgDB::XmlNode*cur, const char* token, osg::Vec2& value) const
{
osgDB::XmlNode::Properties::iterator itr = cur->properties.find(token);
@@ -896,6 +930,11 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
else if (technique=="light") volumeData.shadingModel = osgPresentation::SlideShowConstructor::VolumeData::Light;
}
if (getProperty(cur, "alpha", volumeData.alphaValue)) {}
if (getProperty(cur, "cutoff", volumeData.cutoffValue)) {}
if (getProperty(cur, "region", 6, volumeData.region)) {}
if (getProperty(cur, "sampleDensity", volumeData.sampleDensityValue)) {}
// check for any transfer function required
std::string transferFunctionFile;
if (getTrimmedProperty(cur, "tf", transferFunctionFile))