2014-01-05 17:22:29 +00:00
|
|
|
#ifndef GAME_RENDER_NPCANIMATION_H
|
|
|
|
#define GAME_RENDER_NPCANIMATION_H
|
2012-07-17 07:27:12 +00:00
|
|
|
|
2011-11-24 06:48:54 +00:00
|
|
|
#include "animation.hpp"
|
2011-12-12 03:40:00 +00:00
|
|
|
|
2013-11-15 01:08:36 +00:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2011-12-12 03:40:00 +00:00
|
|
|
|
2014-03-12 10:30:44 +00:00
|
|
|
#include "weaponanimation.hpp"
|
|
|
|
|
2012-11-08 09:46:24 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct NPC;
|
|
|
|
}
|
|
|
|
|
2013-01-06 05:12:08 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2011-11-24 06:48:54 +00:00
|
|
|
|
2015-05-31 00:26:31 +00:00
|
|
|
class NeckController;
|
2015-06-22 19:12:15 +00:00
|
|
|
class HeadAnimationTime;
|
2015-05-31 00:26:31 +00:00
|
|
|
|
2014-03-12 10:30:44 +00:00
|
|
|
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
2013-01-06 13:39:39 +00:00
|
|
|
{
|
2013-11-15 01:08:36 +00:00
|
|
|
public:
|
2014-10-11 19:05:12 +00:00
|
|
|
virtual void equipmentChanged();
|
2013-11-15 01:08:36 +00:00
|
|
|
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound);
|
|
|
|
|
2013-01-06 13:39:39 +00:00
|
|
|
public:
|
2013-08-06 01:59:55 +00:00
|
|
|
typedef std::map<ESM::PartReferenceType,std::string> PartBoneMap;
|
2013-01-06 09:59:18 +00:00
|
|
|
|
2013-08-06 01:59:55 +00:00
|
|
|
enum ViewMode {
|
|
|
|
VM_Normal,
|
|
|
|
VM_FirstPerson,
|
|
|
|
VM_HeadOnly
|
|
|
|
};
|
2013-04-09 16:07:05 +00:00
|
|
|
|
2012-04-05 03:23:24 +00:00
|
|
|
private:
|
2013-08-06 01:59:55 +00:00
|
|
|
static const PartBoneMap sPartList;
|
2013-01-06 13:39:39 +00:00
|
|
|
|
2013-11-15 01:08:36 +00:00
|
|
|
bool mListenerDisabled;
|
2012-04-12 00:16:22 +00:00
|
|
|
|
2013-02-02 10:53:22 +00:00
|
|
|
// Bounded Parts
|
2015-04-15 20:11:38 +00:00
|
|
|
PartHolderPtr mObjectParts[ESM::PRT_Count];
|
2014-10-11 21:18:09 +00:00
|
|
|
std::string mSoundIds[ESM::PRT_Count];
|
2012-11-08 09:46:24 +00:00
|
|
|
|
2013-08-07 23:45:29 +00:00
|
|
|
const ESM::NPC *mNpc;
|
|
|
|
std::string mHeadModel;
|
|
|
|
std::string mHairModel;
|
|
|
|
ViewMode mViewMode;
|
2013-04-28 10:41:01 +00:00
|
|
|
bool mShowWeapons;
|
2013-12-27 21:00:16 +00:00
|
|
|
bool mShowCarriedLeft;
|
2012-11-08 09:46:24 +00:00
|
|
|
|
2014-01-04 19:43:57 +00:00
|
|
|
enum NpcType
|
|
|
|
{
|
|
|
|
Type_Normal,
|
|
|
|
Type_Werewolf,
|
|
|
|
Type_Vampire
|
|
|
|
};
|
|
|
|
NpcType mNpcType;
|
|
|
|
|
2013-08-06 01:59:55 +00:00
|
|
|
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
|
|
|
|
int mPartPriorities[ESM::PRT_Count];
|
2013-01-06 09:59:18 +00:00
|
|
|
|
2015-05-31 00:26:31 +00:00
|
|
|
osg::Vec3f mFirstPersonOffset;
|
2013-10-02 09:16:52 +00:00
|
|
|
|
2015-04-19 12:42:09 +00:00
|
|
|
boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
|
2015-05-30 23:07:43 +00:00
|
|
|
boost::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
|
2013-12-07 13:11:06 +00:00
|
|
|
|
2014-10-12 09:40:14 +00:00
|
|
|
bool mSoundsDisabled;
|
2014-10-11 19:05:12 +00:00
|
|
|
|
2013-08-07 23:21:57 +00:00
|
|
|
void updateNpcBase();
|
|
|
|
|
2015-05-20 01:54:04 +00:00
|
|
|
PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename,
|
2015-04-16 23:23:37 +00:00
|
|
|
const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=NULL);
|
2013-02-21 19:56:34 +00:00
|
|
|
|
2013-08-06 01:59:55 +00:00
|
|
|
void removeIndividualPart(ESM::PartReferenceType type);
|
|
|
|
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2013-11-19 23:07:26 +00:00
|
|
|
bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh,
|
2015-04-16 23:23:37 +00:00
|
|
|
bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
|
2012-07-13 03:12:18 +00:00
|
|
|
void removePartGroup(int group);
|
2013-11-19 23:07:26 +00:00
|
|
|
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
2015-04-16 23:23:37 +00:00
|
|
|
bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
|
2012-09-13 17:03:31 +00:00
|
|
|
|
2015-05-31 00:26:31 +00:00
|
|
|
osg::ref_ptr<NeckController> mFirstPersonNeckController;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void addControllers();
|
|
|
|
|
2013-01-09 15:55:55 +00:00
|
|
|
public:
|
2013-11-15 01:08:36 +00:00
|
|
|
/**
|
|
|
|
* @param ptr
|
|
|
|
* @param disableListener Don't listen for equipment changes and magic effects. InventoryStore only supports
|
|
|
|
* one listener at a time, so you shouldn't do this if creating several NpcAnimations
|
|
|
|
* for the same Ptr, eg preview dolls for the player.
|
|
|
|
* Those need to be manually rendered anyway.
|
2014-10-12 09:40:14 +00:00
|
|
|
* @param disableSounds Same as \a disableListener but for playing items sounds
|
2013-11-15 01:08:36 +00:00
|
|
|
* @param viewMode
|
|
|
|
*/
|
2015-06-22 19:14:44 +00:00
|
|
|
NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem, bool disableListener = false,
|
2014-10-12 09:40:14 +00:00
|
|
|
bool disableSounds = false, ViewMode viewMode=VM_Normal);
|
2013-01-09 15:55:55 +00:00
|
|
|
virtual ~NpcAnimation();
|
|
|
|
|
2014-08-11 03:00:13 +00:00
|
|
|
virtual void enableHeadAnimation(bool enable);
|
|
|
|
|
2015-04-15 20:11:38 +00:00
|
|
|
virtual void setWeaponGroup(const std::string& group);
|
2014-02-04 02:46:15 +00:00
|
|
|
|
2015-04-19 12:42:09 +00:00
|
|
|
virtual osg::Vec3f runAnimation(float timepassed);
|
2013-01-09 15:55:55 +00:00
|
|
|
|
2014-02-04 03:00:52 +00:00
|
|
|
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
|
|
|
/// to indicate the facing orientation of the character.
|
|
|
|
virtual void setPitchFactor(float factor) { mPitchFactor = factor; }
|
|
|
|
|
2013-04-28 10:41:01 +00:00
|
|
|
virtual void showWeapons(bool showWeapon);
|
2014-12-12 15:49:22 +00:00
|
|
|
virtual void showCarriedLeft(bool show);
|
2013-04-28 10:41:01 +00:00
|
|
|
|
2014-02-04 03:11:46 +00:00
|
|
|
virtual void attachArrow();
|
2015-06-26 03:15:07 +00:00
|
|
|
virtual void releaseArrow(float attackStrength);
|
2014-02-04 03:11:46 +00:00
|
|
|
|
2015-05-30 23:07:43 +00:00
|
|
|
virtual osg::Group* getArrowBone();
|
|
|
|
virtual osg::Node* getWeaponNode();
|
|
|
|
virtual Resource::ResourceSystem* getResourceSystem();
|
|
|
|
|
2014-03-12 10:30:44 +00:00
|
|
|
// WeaponAnimation
|
|
|
|
virtual void showWeapon(bool show) { showWeapons(show); }
|
2014-02-04 03:11:46 +00:00
|
|
|
|
2013-04-09 22:10:14 +00:00
|
|
|
void setViewMode(ViewMode viewMode);
|
|
|
|
|
2013-11-14 13:41:10 +00:00
|
|
|
void updateParts();
|
2013-08-09 00:16:24 +00:00
|
|
|
|
|
|
|
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
|
|
|
|
void rebuild();
|
2013-12-08 22:05:21 +00:00
|
|
|
|
2015-05-20 01:35:52 +00:00
|
|
|
/// Get the inventory slot that the given node path leads into, or -1 if not found.
|
|
|
|
int getSlot(const osg::NodePath& path) const;
|
|
|
|
|
2014-12-12 01:39:59 +00:00
|
|
|
virtual void setVampire(bool vampire);
|
2015-05-14 15:34:55 +00:00
|
|
|
|
2015-05-31 00:26:31 +00:00
|
|
|
/// Set a translation offset (in object root space) to apply to meshes when in first person mode.
|
|
|
|
void setFirstPersonOffset(const osg::Vec3f& offset);
|
|
|
|
|
2015-05-14 15:34:55 +00:00
|
|
|
virtual void updatePtr(const MWWorld::Ptr& updated);
|
2011-11-24 06:48:54 +00:00
|
|
|
};
|
2012-07-13 03:12:18 +00:00
|
|
|
|
2011-11-24 06:48:54 +00:00
|
|
|
}
|
2013-01-06 05:12:08 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#endif
|