Support for NiVisController on trishape nodes

openmw-37
scrawl 9 years ago
parent af5a1bc16b
commit 35f5be680b

@ -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::Geode> geode (new osg::Geode);
osg::ref_ptr<osg::Geometry> geometry; osg::ref_ptr<osg::Geometry> geometry;
if(!triShape->controller.empty()) for (Nif::ControllerPtr ctrl = triShape->controller; !ctrl.empty(); ctrl = ctrl->next)
{ {
Nif::ControllerPtr ctrl = triShape->controller; if (!(ctrl->flags & Nif::NiNode::ControllerFlag_Active))
do { continue;
if(ctrl->recType == Nif::RC_NiGeomMorpherController && ctrl->flags & Nif::NiNode::ControllerFlag_Active) if(ctrl->recType == Nif::RC_NiGeomMorpherController)
{ {
geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())); geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()));
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController( osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(
static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr()); static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr());
setupController(ctrl.getPtr(), morphctrl, animflags); setupController(ctrl.getPtr(), morphctrl, animflags);
geometry->setUpdateCallback(morphctrl); geometry->setUpdateCallback(morphctrl);
break; }
} else if (ctrl->recType == Nif::RC_NiVisController)
} while(!(ctrl=ctrl->next).empty()); {
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…
Cancel
Save