Added support for a <hull> tag that can be used within <volume> tag.

This commit is contained in:
Robert Osfield
2014-02-05 11:07:03 +00:00
parent 1909093cac
commit 2b8be97297
3 changed files with 35 additions and 6 deletions

View File

@@ -333,6 +333,7 @@ public:
osg::Vec4 colorModulate;
Technique technique;
std::string hull;
PositionData hullPositionData;
};

View File

@@ -1353,18 +1353,31 @@ osg::TransferFunction1D* ReaderWriterP3DXML::readTransferFunctionFile(const std:
void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode* cur) const
{
osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getModelPositionData();
bool positionRead = getProperties(cur,positionData);
osgPresentation::SlideShowConstructor::VolumeData volumeData;
// check for any hulls
for(osgDB::XmlNode::Children::iterator itr = cur->children.begin();
itr != cur->children.end();
++itr)
{
osgDB::XmlNode* child = itr->get();
OSG_NOTICE<<"parseVolume has child "<<child->contents<<std::endl;
if (match(child->name,"hull"))
{
osgPresentation::SlideShowConstructor::PositionData hullPositionData;
hullPositionData.position = osg::Vec3(0.0,0.0,0.0);
volumeData.hull = child->contents;
if (getProperties(child,hullPositionData))
{
volumeData.hullPositionData = hullPositionData;
}
}
}
osgPresentation::SlideShowConstructor::PositionData positionData = constructor.getModelPositionData();
bool positionRead = getProperties(cur,positionData);
osgPresentation::SlideShowConstructor::VolumeData volumeData;
// check the rendering technique/shading model to use
std::string technique;

View File

@@ -2840,7 +2840,22 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
osg::ref_ptr<osg::Node> hull = osgDB::readNodeFile(volumeData.hull, _options.get());
if (hull.valid())
{
tile->addChild(hull.get());
if (volumeData.hullPositionData.requiresPosition() || volumeData.hullPositionData.requiresScale() || volumeData.hullPositionData.requiresRotate())
{
osg::Matrix matrix(osg::Matrix::scale(1.0f/volumeData.hullPositionData.scale.x(),1.0f/volumeData.hullPositionData.scale.y(),1.0f/volumeData.hullPositionData.scale.z())*
osg::Matrix::rotate(osg::DegreesToRadians(volumeData.hullPositionData.rotate[0]),volumeData.hullPositionData.rotate[1],volumeData.hullPositionData.rotate[2],volumeData.hullPositionData.rotate[3])*
osg::Matrix::translate(volumeData.hullPositionData.position));
osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
transform->setMatrix(osg::Matrix::inverse(matrix));
transform->addChild(hull.get());
tile->addChild(transform.get());
}
else
{
tile->addChild(hull.get());
}
}
}