From 2b8be972976f0ff04edf50320979d960babe4bd8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 5 Feb 2014 11:07:03 +0000 Subject: [PATCH] Added support for a tag that can be used within tag. --- .../deprecated/SlideShowConstructor | 1 + src/osgPlugins/p3d/ReaderWriterP3D.cpp | 23 +++++++++++++++---- .../deprecated/SlideShowConstructor.cpp | 17 +++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/osgPresentation/deprecated/SlideShowConstructor b/include/osgPresentation/deprecated/SlideShowConstructor index df241c797..078a9e676 100644 --- a/include/osgPresentation/deprecated/SlideShowConstructor +++ b/include/osgPresentation/deprecated/SlideShowConstructor @@ -333,6 +333,7 @@ public: osg::Vec4 colorModulate; Technique technique; std::string hull; + PositionData hullPositionData; }; diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index b75385299..052df5051 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -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 "<contents<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; diff --git a/src/osgPresentation/deprecated/SlideShowConstructor.cpp b/src/osgPresentation/deprecated/SlideShowConstructor.cpp index 43c0ba2d5..c3a471126 100644 --- a/src/osgPresentation/deprecated/SlideShowConstructor.cpp +++ b/src/osgPresentation/deprecated/SlideShowConstructor.cpp @@ -2840,7 +2840,22 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position osg::ref_ptr 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 transform = new osg::MatrixTransform; + transform->setMatrix(osg::Matrix::inverse(matrix)); + + transform->addChild(hull.get()); + tile->addChild(transform.get()); + } + else + { + tile->addChild(hull.get()); + } } }