|
|
|
@ -8,6 +8,7 @@
|
|
|
|
|
#include <osg/Array>
|
|
|
|
|
#include <osg/LOD>
|
|
|
|
|
#include <osg/Switch>
|
|
|
|
|
#include <osg/Sequence>
|
|
|
|
|
#include <osg/TexGen>
|
|
|
|
|
#include <osg/ValueObject>
|
|
|
|
|
|
|
|
|
@ -416,6 +417,33 @@ namespace NifOsg
|
|
|
|
|
return switchNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static osg::ref_ptr<osg::Sequence> prepareSequenceNode(const Nif::Node* nifNode)
|
|
|
|
|
{
|
|
|
|
|
const Nif::NiFltAnimationNode* niFltAnimationNode = static_cast<const Nif::NiFltAnimationNode*>(nifNode);
|
|
|
|
|
osg::ref_ptr<osg::Sequence> sequenceNode (new osg::Sequence);
|
|
|
|
|
sequenceNode->setName(niFltAnimationNode->name);
|
|
|
|
|
if (niFltAnimationNode->children.length()!=0)
|
|
|
|
|
{
|
|
|
|
|
if (niFltAnimationNode->flags & Nif::NiFltAnimationNode::Flag_Swing)
|
|
|
|
|
sequenceNode->setDefaultTime(niFltAnimationNode->mDuration/(niFltAnimationNode->children.length()*2));
|
|
|
|
|
else
|
|
|
|
|
sequenceNode->setDefaultTime(niFltAnimationNode->mDuration/niFltAnimationNode->children.length());
|
|
|
|
|
}
|
|
|
|
|
return sequenceNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void activateSequenceNode(osg::Group* osgNode, const Nif::Node* nifNode)
|
|
|
|
|
{
|
|
|
|
|
const Nif::NiFltAnimationNode* niFltAnimationNode = static_cast<const Nif::NiFltAnimationNode*>(nifNode);
|
|
|
|
|
osg::Sequence* sequenceNode = static_cast<osg::Sequence*>(osgNode);
|
|
|
|
|
if (niFltAnimationNode->flags & Nif::NiFltAnimationNode::Flag_Swing)
|
|
|
|
|
sequenceNode->setInterval(osg::Sequence::SWING, 0,-1);
|
|
|
|
|
else
|
|
|
|
|
sequenceNode->setInterval(osg::Sequence::LOOP, 0,-1);
|
|
|
|
|
sequenceNode->setDuration(1.0f, -1);
|
|
|
|
|
sequenceNode->setMode(osg::Sequence::START);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> handleSourceTexture(const Nif::NiSourceTexture* st, Resource::ImageManager* imageManager)
|
|
|
|
|
{
|
|
|
|
|
if (!st)
|
|
|
|
@ -707,6 +735,12 @@ namespace NifOsg
|
|
|
|
|
node->addChild(lodNode);
|
|
|
|
|
currentNode = lodNode;
|
|
|
|
|
}
|
|
|
|
|
else if (nifNode->recType == Nif::RC_NiFltAnimationNode)
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osg::Sequence> sequenceNode = prepareSequenceNode(nifNode);
|
|
|
|
|
node->addChild(sequenceNode);
|
|
|
|
|
currentNode = sequenceNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(nifNode);
|
|
|
|
|
if(ninode)
|
|
|
|
@ -727,6 +761,9 @@ namespace NifOsg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nifNode->recType == Nif::RC_NiFltAnimationNode)
|
|
|
|
|
activateSequenceNode(currentNode,nifNode);
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|