|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
#include "creatureanimation.hpp"
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
#include <osg/MatrixTransform>
|
|
|
|
|
|
|
|
|
|
#include <components/esm/loadcrea.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/resource/resourcesystem.hpp>
|
|
|
|
@ -9,6 +13,8 @@
|
|
|
|
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
|
|
|
|
#include <components/sceneutil/skeleton.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
@ -107,39 +113,51 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
|
|
|
|
else
|
|
|
|
|
bonename = "Shield Bone";
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(item.getClass().getModel(item));
|
|
|
|
|
osg::ref_ptr<osg::Node> attached = SceneUtil::attach(node, mObjectRoot, bonename, bonename);
|
|
|
|
|
mResourceSystem->getSceneManager()->notifyAttached(attached);
|
|
|
|
|
|
|
|
|
|
scene.reset(new PartHolder(attached));
|
|
|
|
|
|
|
|
|
|
if (!item.getClass().getEnchantment(item).empty())
|
|
|
|
|
addGlow(attached, getEnchantmentColor(item));
|
|
|
|
|
|
|
|
|
|
// Crossbows start out with a bolt attached
|
|
|
|
|
// FIXME: code duplicated from NpcAnimation
|
|
|
|
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight &&
|
|
|
|
|
item.getTypeName() == typeid(ESM::Weapon).name() &&
|
|
|
|
|
item.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
|
|
|
|
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
|
|
|
|
attachArrow();
|
|
|
|
|
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(item.getClass().getModel(item));
|
|
|
|
|
|
|
|
|
|
const NodeMap& nodeMap = getNodeMap();
|
|
|
|
|
NodeMap::const_iterator found = getNodeMap().find(Misc::StringUtils::lowerCase(bonename));
|
|
|
|
|
if (found == nodeMap.end())
|
|
|
|
|
throw std::runtime_error("Can't find attachment node " + bonename);
|
|
|
|
|
osg::ref_ptr<osg::Node> attached = SceneUtil::attach(node, mObjectRoot, bonename, found->second.get());
|
|
|
|
|
mResourceSystem->getSceneManager()->notifyAttached(attached);
|
|
|
|
|
|
|
|
|
|
scene.reset(new PartHolder(attached));
|
|
|
|
|
|
|
|
|
|
if (!item.getClass().getEnchantment(item).empty())
|
|
|
|
|
addGlow(attached, getEnchantmentColor(item));
|
|
|
|
|
|
|
|
|
|
// Crossbows start out with a bolt attached
|
|
|
|
|
// FIXME: code duplicated from NpcAnimation
|
|
|
|
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight &&
|
|
|
|
|
item.getTypeName() == typeid(ESM::Weapon).name() &&
|
|
|
|
|
item.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
|
|
|
|
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
|
|
|
|
attachArrow();
|
|
|
|
|
else
|
|
|
|
|
mAmmunition.reset();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mAmmunition.reset();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mAmmunition.reset();
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<SceneUtil::ControllerSource> source;
|
|
|
|
|
boost::shared_ptr<SceneUtil::ControllerSource> source;
|
|
|
|
|
|
|
|
|
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
|
|
|
source = mWeaponAnimationTime;
|
|
|
|
|
else
|
|
|
|
|
source.reset(new NullAnimationTime);
|
|
|
|
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
|
|
|
source = mWeaponAnimationTime;
|
|
|
|
|
else
|
|
|
|
|
source.reset(new NullAnimationTime);
|
|
|
|
|
|
|
|
|
|
SceneUtil::AssignControllerSourcesVisitor assignVisitor(source);
|
|
|
|
|
attached->accept(assignVisitor);
|
|
|
|
|
SceneUtil::AssignControllerSourcesVisitor assignVisitor(source);
|
|
|
|
|
attached->accept(assignVisitor);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception& e)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Error adding creature part: " << e.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureWeaponAnimation::attachArrow()
|
|
|
|
|