1 #ifndef GAME_RENDER_CREATUREANIMATION_H 2 #define GAME_RENDER_CREATUREANIMATION_H 3 4 #include "actoranimation.hpp" 5 #include "weaponanimation.hpp" 6 #include "../mwworld/inventorystore.hpp" 7 8 namespace MWWorld 9 { 10 class Ptr; 11 } 12 13 namespace MWRender 14 { 15 class CreatureAnimation : public ActorAnimation 16 { 17 public: 18 CreatureAnimation(const MWWorld::Ptr &ptr, const std::string& model, Resource::ResourceSystem* resourceSystem); ~CreatureAnimation()19 virtual ~CreatureAnimation() {} 20 }; 21 22 // For creatures with weapons and shields 23 // Animation is already virtual anyway, so might as well make a separate class. 24 // Most creatures don't need weapons/shields, so this will save some memory. 25 class CreatureWeaponAnimation : public ActorAnimation, public WeaponAnimation, public MWWorld::InventoryStoreListener 26 { 27 public: 28 CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const std::string& model, Resource::ResourceSystem* resourceSystem); ~CreatureWeaponAnimation()29 virtual ~CreatureWeaponAnimation() {} 30 equipmentChanged()31 void equipmentChanged() override { updateParts(); } 32 33 void showWeapons(bool showWeapon) override; 34 getCarriedLeftShown() const35 bool getCarriedLeftShown() const override { return mShowCarriedLeft; } 36 void showCarriedLeft(bool show) override; 37 38 void updateParts(); 39 40 void updatePart(PartHolderPtr& scene, int slot); 41 42 void attachArrow() override; 43 void detachArrow() override; 44 void releaseArrow(float attackStrength) override; 45 // WeaponAnimation 46 osg::Group* getArrowBone() override; 47 osg::Node* getWeaponNode() override; 48 Resource::ResourceSystem* getResourceSystem() override; showWeapon(bool show)49 void showWeapon(bool show) override { showWeapons(show); } setWeaponGroup(const std::string & group,bool relativeDuration)50 void setWeaponGroup(const std::string& group, bool relativeDuration) override { mWeaponAnimationTime->setGroup(group, relativeDuration); } 51 52 void addControllers() override; 53 54 osg::Vec3f runAnimation(float duration) override; 55 56 /// A relative factor (0-1) that decides if and how much the skeleton should be pitched 57 /// to indicate the facing orientation of the character. setPitchFactor(float factor)58 void setPitchFactor(float factor) override { mPitchFactor = factor; } 59 60 protected: 61 bool isArrowAttached() const override; 62 63 private: 64 PartHolderPtr mWeapon; 65 PartHolderPtr mShield; 66 bool mShowWeapons; 67 bool mShowCarriedLeft; 68 69 std::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime; 70 }; 71 } 72 73 #endif 74