OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
npcanimation.hpp
Go to the documentation of this file.
1 #ifndef GAME_RENDER_NPCANIMATION_H
2 #define GAME_RENDER_NPCANIMATION_H
3 
4 #include "animation.hpp"
5 
6 #include "../mwworld/inventorystore.hpp"
7 
8 #include "actoranimation.hpp"
9 #include "weaponanimation.hpp"
10 
11 namespace ESM
12 {
13  struct NPC;
14  struct BodyPart;
15 }
16 
17 namespace MWRender
18 {
19 
20 class NeckController;
21 class HeadAnimationTime;
22 
24 {
25 public:
26  virtual void equipmentChanged();
27  virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew);
28 
29 public:
30  typedef std::map<ESM::PartReferenceType,std::string> PartBoneMap;
31 
32  enum ViewMode {
36  };
37 
38 private:
39  static const PartBoneMap sPartList;
40 
41  // Bounded Parts
43  std::string mSoundIds[ESM::PRT_Count];
44 
45  const ESM::NPC *mNpc;
46  std::string mHeadModel;
47  std::string mHairModel;
51 
52  enum NpcType
53  {
57  };
59 
60  int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
62 
63  osg::Vec3f mFirstPersonOffset;
64  // Field of view to use when rendering first person meshes
66 
67  std::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
68  std::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
69 
71 
74 
75  void updateNpcBase();
76 
77  PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename,
78  const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=NULL);
79 
81  void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
82 
83  bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh,
84  bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
85  void removePartGroup(int group);
86  void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
87  bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
88 
89  virtual void setRenderBin();
90 
91  osg::ref_ptr<NeckController> mFirstPersonNeckController;
92 
93  static bool isFirstPersonPart(const ESM::BodyPart* bodypart);
94  static bool isFemalePart(const ESM::BodyPart* bodypart);
95 
96 protected:
97  virtual void addControllers();
98 
99 public:
109  NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem,
110  bool disableSounds = false, ViewMode viewMode=VM_Normal, float firstPersonFieldOfView=55.f);
111  virtual ~NpcAnimation();
112 
113  virtual void enableHeadAnimation(bool enable);
114 
117  virtual void setAccurateAiming(bool enabled);
118 
119  virtual void setWeaponGroup(const std::string& group);
120 
121  virtual osg::Vec3f runAnimation(float timepassed);
122 
125  virtual void setPitchFactor(float factor) { mPitchFactor = factor; }
126 
127  virtual void showWeapons(bool showWeapon);
128  virtual void showCarriedLeft(bool show);
129 
130  virtual void attachArrow();
131  virtual void releaseArrow(float attackStrength);
132 
133  virtual osg::Group* getArrowBone();
134  virtual osg::Node* getWeaponNode();
136 
137  // WeaponAnimation
138  virtual void showWeapon(bool show) { showWeapons(show); }
139 
140  void setViewMode(ViewMode viewMode);
141 
142  void updateParts();
143 
145  void rebuild();
146 
148  int getSlot(const osg::NodePath& path) const;
149 
150  virtual void setVampire(bool vampire);
151 
153  void setFirstPersonOffset(const osg::Vec3f& offset);
154 
155  virtual void updatePtr(const MWWorld::Ptr& updated);
156 
159  static const std::vector<const ESM::BodyPart*>& getBodyParts(const std::string& raceId, bool female, bool firstperson, bool werewolf);
160 };
161 
162 }
163 
164 #endif
void updateParts()
Definition: npcanimation.cpp:496
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew)
Definition: npcanimation.cpp:971
virtual void attachArrow()
Definition: npcanimation.cpp:936
void rebuild()
Rebuilds the NPC, updating their root model, animation sources, and equipment.
Definition: npcanimation.cpp:390
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:30
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority)
Definition: npcanimation.cpp:693
ViewMode
Definition: npcanimation.hpp:32
NpcAnimation(const MWWorld::Ptr &ptr, osg::ref_ptr< osg::Group > parentNode, Resource::ResourceSystem *resourceSystem, bool disableSounds=false, ViewMode viewMode=VM_Normal, float firstPersonFieldOfView=55.f)
Definition: npcanimation.cpp:279
void removePartGroup(int group)
Definition: npcanimation.cpp:703
PartHolderPtr mObjectParts[ESM::PRT_Count]
Definition: npcanimation.hpp:42
osg::Vec3f mFirstPersonOffset
Definition: npcanimation.hpp:63
virtual void setPitchFactor(float factor)
Definition: npcanimation.hpp:125
std::string mHairModel
Definition: npcanimation.hpp:47
void removeIndividualPart(ESM::PartReferenceType type)
Definition: npcanimation.cpp:680
virtual void showWeapons(bool showWeapon)
Definition: npcanimation.cpp:878
PartReferenceType
Definition: loadarmo.hpp:13
Definition: npcanimation.hpp:33
virtual ~NpcAnimation()
Definition: npcanimation.cpp:274
Handles attach & release of projectiles for ranged weapons.
Definition: weaponanimation.hpp:29
osg::ref_ptr< NeckController > mFirstPersonNeckController
Definition: npcanimation.hpp:91
const ESM::NPC * mNpc
Definition: npcanimation.hpp:45
virtual osg::Vec3f runAnimation(float timepassed)
Definition: npcanimation.cpp:656
std::shared_ptr< HeadAnimationTime > mHeadAnimationTime
Definition: npcanimation.hpp:67
Definition: npcanimation.hpp:56
virtual void setAccurateAiming(bool enabled)
Definition: npcanimation.cpp:1183
bool mShowCarriedLeft
Definition: npcanimation.hpp:50
virtual void equipmentChanged()
Definition: npcanimation.cpp:1009
virtual void showCarriedLeft(bool show)
Definition: npcanimation.cpp:914
std::shared_ptr< PartHolder > PartHolderPtr
Definition: animation.hpp:72
float mAimingFactor
Definition: npcanimation.hpp:73
static const std::vector< const ESM::BodyPart * > & getBodyParts(const std::string &raceId, bool female, bool firstperson, bool werewolf)
Definition: npcanimation.cpp:1042
Variant of the ContainerStore for NPCs.
Definition: inventorystore.hpp:20
float mFirstPersonFieldOfView
Definition: npcanimation.hpp:65
static const PartBoneMap sPartList
Definition: npcanimation.hpp:39
Definition: npcanimation.hpp:54
float mPitchFactor
Definition: weaponanimation.hpp:66
std::shared_ptr< WeaponAnimationTime > mWeaponAnimationTime
Definition: npcanimation.hpp:68
Definition: actoranimation.hpp:31
ViewMode mViewMode
Definition: npcanimation.hpp:48
virtual void setVampire(bool vampire)
Definition: npcanimation.cpp:1014
Definition: loadnpc.hpp:23
virtual void enableHeadAnimation(bool enable)
Definition: npcanimation.cpp:999
bool mAccurateAiming
Definition: npcanimation.hpp:72
void updateNpcBase()
Definition: npcanimation.cpp:412
void setFirstPersonOffset(const osg::Vec3f &offset)
Set a translation offset (in object root space) to apply to meshes when in first person mode...
Definition: npcanimation.cpp:1027
void setViewMode(ViewMode viewMode)
Definition: npcanimation.cpp:305
virtual osg::Node * getWeaponNode()
Definition: npcanimation.cpp:958
int mPartslots[ESM::PRT_Count]
Definition: npcanimation.hpp:60
Definition: loadmgef.hpp:13
std::map< ESM::PartReferenceType, std::string > PartBoneMap
Definition: npcanimation.hpp:30
virtual void releaseArrow(float attackStrength)
Definition: npcanimation.cpp:941
bool mSoundsDisabled
Definition: npcanimation.hpp:70
static bool isFirstPersonPart(const ESM::BodyPart *bodypart)
Definition: npcanimation.cpp:712
int getSlot(const osg::NodePath &path) const
Get the inventory slot that the given node path leads into, or -1 if not found.
Definition: npcanimation.cpp:397
virtual void updatePtr(const MWWorld::Ptr &updated)
Definition: npcanimation.cpp:1032
bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:725
bool mShowWeapons
Definition: npcanimation.hpp:49
NpcType mNpcType
Definition: npcanimation.hpp:58
static bool isFemalePart(const ESM::BodyPart *bodypart)
Definition: npcanimation.cpp:720
virtual osg::Group * getArrowBone()
Definition: npcanimation.cpp:946
Definition: npcanimation.hpp:23
Definition: npcanimation.hpp:55
virtual void addControllers()
Definition: npcanimation.cpp:854
Definition: npcanimation.hpp:35
std::string mSoundIds[ESM::PRT_Count]
Definition: npcanimation.hpp:43
Definition: loadbody.hpp:12
virtual void showWeapon(bool show)
Definition: npcanimation.hpp:138
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void enable(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:870
NpcType
Definition: npcanimation.hpp:52
std::string mHeadModel
Definition: npcanimation.hpp:46
PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename, const std::string &bonefilter, bool enchantedGlow, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:640
void addPartGroup(int group, int priority, const std::vector< ESM::PartReference > &parts, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:806
Definition: npcanimation.hpp:34
Definition: loadarmo.hpp:43
virtual Resource::ResourceSystem * getResourceSystem()
Definition: npcanimation.cpp:966
virtual void setWeaponGroup(const std::string &group)
Definition: npcanimation.cpp:1004
virtual void setRenderBin()
Set the render bin for this animation's object root. May be customized by subclasses.
Definition: npcanimation.cpp:370
int mPartPriorities[ESM::PRT_Count]
Definition: npcanimation.hpp:61