forked from teamnwah/openmw-tes3coop
Support for NiVisController on trishape nodes
This commit is contained in:
parent
af5a1bc16b
commit
35f5be680b
1 changed files with 39 additions and 21 deletions
|
@ -609,15 +609,20 @@ namespace NifOsg
|
||||||
}
|
}
|
||||||
else if (ctrl->recType == Nif::RC_NiVisController)
|
else if (ctrl->recType == Nif::RC_NiVisController)
|
||||||
{
|
{
|
||||||
const Nif::NiVisController* visctrl = static_cast<const Nif::NiVisController*>(ctrl.getPtr());
|
handleVisController(static_cast<const Nif::NiVisController*>(ctrl.getPtr()), transformNode, animflags);
|
||||||
|
|
||||||
osg::ref_ptr<VisController> callback(new VisController(visctrl->data.getPtr()));
|
|
||||||
setupController(visctrl, callback, animflags);
|
|
||||||
transformNode->addUpdateCallback(callback);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
std::cerr << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleVisController(const Nif::NiVisController* visctrl, osg::Node* node, int animflags)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<VisController> callback(new VisController(visctrl->data.getPtr()));
|
||||||
|
setupController(visctrl, callback, animflags);
|
||||||
|
node->addUpdateCallback(callback);
|
||||||
|
}
|
||||||
|
|
||||||
void handleMaterialControllers(const Nif::Property *materialProperty, SceneUtil::CompositeStateSetUpdater* composite, int animflags)
|
void handleMaterialControllers(const Nif::Property *materialProperty, SceneUtil::CompositeStateSetUpdater* composite, int animflags)
|
||||||
{
|
{
|
||||||
for (Nif::ControllerPtr ctrl = materialProperty->controller; !ctrl.empty(); ctrl = ctrl->next)
|
for (Nif::ControllerPtr ctrl = materialProperty->controller; !ctrl.empty(); ctrl = ctrl->next)
|
||||||
|
@ -942,28 +947,31 @@ namespace NifOsg
|
||||||
|
|
||||||
void handleTriShape(const Nif::NiTriShape* triShape, osg::Group* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector<int>& boundTextures, int animflags)
|
void handleTriShape(const Nif::NiTriShape* triShape, osg::Group* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector<int>& boundTextures, int animflags)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> geometry;
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
||||||
if(!triShape->controller.empty())
|
|
||||||
{
|
|
||||||
Nif::ControllerPtr ctrl = triShape->controller;
|
|
||||||
do {
|
|
||||||
if(ctrl->recType == Nif::RC_NiGeomMorpherController && ctrl->flags & Nif::NiNode::ControllerFlag_Active)
|
|
||||||
{
|
|
||||||
geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()));
|
|
||||||
|
|
||||||
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(
|
osg::ref_ptr<osg::Geometry> geometry;
|
||||||
static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr());
|
for (Nif::ControllerPtr ctrl = triShape->controller; !ctrl.empty(); ctrl = ctrl->next)
|
||||||
setupController(ctrl.getPtr(), morphctrl, animflags);
|
{
|
||||||
geometry->setUpdateCallback(morphctrl);
|
if (!(ctrl->flags & Nif::NiNode::ControllerFlag_Active))
|
||||||
break;
|
continue;
|
||||||
}
|
if(ctrl->recType == Nif::RC_NiGeomMorpherController)
|
||||||
} while(!(ctrl=ctrl->next).empty());
|
{
|
||||||
|
geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()));
|
||||||
|
|
||||||
|
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(
|
||||||
|
static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr());
|
||||||
|
setupController(ctrl.getPtr(), morphctrl, animflags);
|
||||||
|
geometry->setUpdateCallback(morphctrl);
|
||||||
|
}
|
||||||
|
else if (ctrl->recType == Nif::RC_NiVisController)
|
||||||
|
{
|
||||||
|
handleVisController(static_cast<const Nif::NiVisController*>(ctrl.getPtr()), geode, animflags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!geometry.get())
|
if (!geometry.get())
|
||||||
geometry = new osg::Geometry;
|
geometry = new osg::Geometry;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
|
||||||
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
||||||
|
|
||||||
geode->addDrawable(geometry);
|
geode->addDrawable(geometry);
|
||||||
|
@ -1043,6 +1051,16 @@ namespace NifOsg
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
||||||
|
|
||||||
|
for (Nif::ControllerPtr ctrl = triShape->controller; !ctrl.empty(); ctrl = ctrl->next)
|
||||||
|
{
|
||||||
|
if (!(ctrl->flags & Nif::NiNode::ControllerFlag_Active))
|
||||||
|
continue;
|
||||||
|
if (ctrl->recType == Nif::RC_NiVisController)
|
||||||
|
{
|
||||||
|
handleVisController(static_cast<const Nif::NiVisController*>(ctrl.getPtr()), geode, animflags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
|
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
|
||||||
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue