Added support for animating volume hulls.
This commit is contained in:
parent
d703a2df44
commit
ed724a730e
@ -312,6 +312,8 @@ public:
|
|||||||
colorModulate(1.0f,1.0f,1.0f,1.0f),
|
colorModulate(1.0f,1.0f,1.0f,1.0f),
|
||||||
technique(RayTraced)
|
technique(RayTraced)
|
||||||
{
|
{
|
||||||
|
hullPositionData.position = osg::Vec3(0.0,0.0,0.0);
|
||||||
|
hullPositionData.frame = osgPresentation::SlideShowConstructor::MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string options;
|
std::string options;
|
||||||
@ -557,6 +559,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
osg::Node* decorateSubgraphForPosition(osg::Node* node, PositionData& positionData);
|
osg::Node* decorateSubgraphForPosition(osg::Node* node, PositionData& positionData);
|
||||||
|
osg::Node* decorateSubgraphForPositionAndAnimation(osg::Node* node, const PositionData& positionData);
|
||||||
|
|
||||||
osg::ref_ptr<osgDB::Options> _options;
|
osg::ref_ptr<osgDB::Options> _options;
|
||||||
|
|
||||||
|
@ -1423,15 +1423,8 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
|
|||||||
osgDB::XmlNode* child = itr->get();
|
osgDB::XmlNode* child = itr->get();
|
||||||
if (match(child->name,"hull"))
|
if (match(child->name,"hull"))
|
||||||
{
|
{
|
||||||
osgPresentation::SlideShowConstructor::PositionData hullPositionData;
|
|
||||||
hullPositionData.position = osg::Vec3(0.0,0.0,0.0);
|
|
||||||
volumeData.hull = child->contents;
|
volumeData.hull = child->contents;
|
||||||
|
getProperties(child, volumeData.hullPositionData);
|
||||||
if (getProperties(child,hullPositionData))
|
|
||||||
{
|
|
||||||
volumeData.hullPositionData = hullPositionData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2134,21 +2134,12 @@ void SlideShowConstructor::addModel(const std::string& filename, const PositionD
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideShowConstructor::addModel(osg::Node* subgraph, const PositionData& positionData, const ModelData& modelData, const ScriptData& scriptData)
|
osg::Node* SlideShowConstructor::decorateSubgraphForPositionAndAnimation(osg::Node* node, const PositionData& positionData)
|
||||||
{
|
{
|
||||||
|
osg::Node* subgraph = node;
|
||||||
osg::Object::DataVariance defaultMatrixDataVariance = osg::Object::DYNAMIC; // STATIC
|
osg::Object::DataVariance defaultMatrixDataVariance = osg::Object::DYNAMIC; // STATIC
|
||||||
|
|
||||||
if (!modelData.effect.empty())
|
OSG_INFO<<"SlideShowConstructor::decorateSubgraphForPositionAndAnimation() "<<std::endl;
|
||||||
{
|
|
||||||
if (modelData.effect=="SpecularHighlights" || modelData.effect=="glossy")
|
|
||||||
{
|
|
||||||
osgFX::SpecularHighlights* specularHighlights = new osgFX::SpecularHighlights;
|
|
||||||
specularHighlights->setTextureUnit(1);
|
|
||||||
specularHighlights->addChild(subgraph);
|
|
||||||
subgraph = specularHighlights;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (positionData.frame==SLIDE)
|
if (positionData.frame==SLIDE)
|
||||||
{
|
{
|
||||||
@ -2191,11 +2182,6 @@ void SlideShowConstructor::addModel(osg::Node* subgraph, const PositionData& pos
|
|||||||
float referenceSizeRatio = 0.707;
|
float referenceSizeRatio = 0.707;
|
||||||
float referenceSize = subgraph->getBound().radius() * referenceSizeRatio;
|
float referenceSize = subgraph->getBound().radius() * referenceSizeRatio;
|
||||||
|
|
||||||
|
|
||||||
// attach any meterial animation.
|
|
||||||
if (positionData.requiresMaterialAnimation())
|
|
||||||
subgraph = attachMaterialAnimation(subgraph,positionData);
|
|
||||||
|
|
||||||
// attached any rotation
|
// attached any rotation
|
||||||
if (positionData.rotation[0]!=0.0)
|
if (positionData.rotation[0]!=0.0)
|
||||||
{
|
{
|
||||||
@ -2299,6 +2285,32 @@ void SlideShowConstructor::addModel(osg::Node* subgraph, const PositionData& pos
|
|||||||
subgraph = animation_transform;
|
subgraph = animation_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return subgraph;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SlideShowConstructor::addModel(osg::Node* subgraph, const PositionData& positionData, const ModelData& modelData, const ScriptData& scriptData)
|
||||||
|
{
|
||||||
|
if (!modelData.effect.empty())
|
||||||
|
{
|
||||||
|
if (modelData.effect=="SpecularHighlights" || modelData.effect=="glossy")
|
||||||
|
{
|
||||||
|
osgFX::SpecularHighlights* specularHighlights = new osgFX::SpecularHighlights;
|
||||||
|
specularHighlights->setTextureUnit(1);
|
||||||
|
specularHighlights->addChild(subgraph);
|
||||||
|
subgraph = specularHighlights;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// attach any meterial animation.
|
||||||
|
if (positionData.requiresMaterialAnimation())
|
||||||
|
subgraph = attachMaterialAnimation(subgraph,positionData);
|
||||||
|
|
||||||
|
|
||||||
|
subgraph = decorateSubgraphForPositionAndAnimation(subgraph, positionData);
|
||||||
|
|
||||||
findImageStreamsAndAddCallbacks(subgraph);
|
findImageStreamsAndAddCallbacks(subgraph);
|
||||||
|
|
||||||
addToCurrentLayer(subgraph);
|
addToCurrentLayer(subgraph);
|
||||||
@ -2847,27 +2859,13 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!volumeData.hull.empty())
|
if (!volumeData.hull.empty())
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Node> hull = osgDB::readNodeFile(volumeData.hull, _options.get());
|
osg::ref_ptr<osg::Node> hull = osgDB::readNodeFile(volumeData.hull, _options.get());
|
||||||
if (hull.valid())
|
if (hull.valid())
|
||||||
{
|
{
|
||||||
if (volumeData.hullPositionData.position!=osg::Vec3(0.0f,0.0f,0.0f) || volumeData.hullPositionData.requiresScale() || volumeData.hullPositionData.requiresRotate())
|
hull = decorateSubgraphForPositionAndAnimation(hull.get(), volumeData.hullPositionData);
|
||||||
{
|
tile->addChild(hull.get());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,9 +626,17 @@ void MultipassTechnique::init()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultipassTechnique::update(osgUtil::UpdateVisitor* /*uv*/)
|
void MultipassTechnique::update(osgUtil::UpdateVisitor* uv)
|
||||||
{
|
{
|
||||||
// OSG_NOTICE<<"MultipassTechnique:update(osgUtil::UpdateVisitor* nv):"<<std::endl;
|
// OSG_NOTICE<<"MultipassTechnique:update(osgUtil::UpdateVisitor* uv):"<<std::endl;
|
||||||
|
if (getVolumeTile()->getNumChildren()>0)
|
||||||
|
{
|
||||||
|
getVolumeTile()->osg::Group::traverse(*uv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_transform->accept(*uv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultipassTechnique::backfaceSubgraphCullTraversal(osgUtil::CullVisitor* cv)
|
void MultipassTechnique::backfaceSubgraphCullTraversal(osgUtil::CullVisitor* cv)
|
||||||
|
Loading…
Reference in New Issue
Block a user