1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/apps/openmw/mwrender/weaponanimation.hpp

69 lines
2.2 KiB
C++
Raw Normal View History

2014-03-12 10:30:44 +00:00
#ifndef OPENMW_MWRENDER_WEAPONANIMATION_H
#define OPENMW_MWRENDER_WEAPONANIMATION_H
2015-05-30 23:07:43 +00:00
#include <components/sceneutil/controller.hpp>
2014-03-12 10:30:44 +00:00
#include "../mwworld/ptr.hpp"
2015-05-30 23:07:43 +00:00
#include "animation.hpp"
2014-03-12 10:30:44 +00:00
namespace MWRender
{
2015-05-31 16:53:16 +00:00
class RotateController;
2015-05-30 23:07:43 +00:00
class WeaponAnimationTime : public SceneUtil::ControllerSource
2014-03-12 10:30:44 +00:00
{
private:
Animation* mAnimation;
std::string mWeaponGroup;
float mStartTime;
public:
WeaponAnimationTime(Animation* animation) : mAnimation(animation), mStartTime(0) {}
void setGroup(const std::string& group);
void updateStartTime();
2015-05-30 23:07:43 +00:00
virtual float getValue(osg::NodeVisitor* nv);
2014-03-12 10:30:44 +00:00
};
/// Handles attach & release of projectiles for ranged weapons
class WeaponAnimation
{
public:
2015-05-30 23:07:43 +00:00
WeaponAnimation();
2015-05-31 16:53:16 +00:00
virtual ~WeaponAnimation();
2014-03-12 10:30:44 +00:00
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
2015-05-30 23:07:43 +00:00
void attachArrow(MWWorld::Ptr actor);
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
void releaseArrow(MWWorld::Ptr actor, float attackStrength);
2014-03-12 10:30:44 +00:00
2015-05-31 16:53:16 +00:00
/// Add WeaponAnimation-related controllers to \a nodes and store the added controllers in \a map.
void addControllers(const std::map<std::string, osg::ref_ptr<osg::MatrixTransform> >& nodes,
std::multimap<osg::ref_ptr<osg::Node>, osg::ref_ptr<osg::NodeCallback> >& map, osg::Node* objectRoot);
void deleteControllers();
/// Configure controllers, should be called every animation frame.
void configureControllers(float characterPitchRadians);
2014-03-12 10:30:44 +00:00
protected:
2015-05-30 23:07:43 +00:00
PartHolderPtr mAmmunition;
2015-05-31 16:53:16 +00:00
osg::ref_ptr<RotateController> mSpineControllers[2];
2015-05-30 23:07:43 +00:00
virtual osg::Group* getArrowBone() = 0;
virtual osg::Node* getWeaponNode() = 0;
virtual Resource::ResourceSystem* getResourceSystem() = 0;
2014-03-12 10:30:44 +00:00
virtual void showWeapon(bool show) = 0;
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
/// to indicate the facing orientation of the character, for ranged weapon aiming.
float mPitchFactor;
};
}
#endif