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 
42 
43  // Bounded Parts
45  std::string mSoundIds[ESM::PRT_Count];
46 
47  const ESM::NPC *mNpc;
48  std::string mHeadModel;
49  std::string mHairModel;
53 
54  enum NpcType
55  {
59  };
61 
62  int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
64 
65  osg::Vec3f mFirstPersonOffset;
66  // Field of view to use when rendering first person meshes
68 
69  boost::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
70  boost::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
71 
73 
76 
77  void updateNpcBase();
78 
79  PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename,
80  const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=NULL);
81 
83  void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
84 
85  bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh,
86  bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
87  void removePartGroup(int group);
88  void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
89  bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
90 
91  virtual void setRenderBin();
92 
93  osg::ref_ptr<NeckController> mFirstPersonNeckController;
94 
95 protected:
96  virtual void addControllers();
97 
98 public:
108  NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem, bool disableListener = false,
109  bool disableSounds = false, ViewMode viewMode=VM_Normal, float firstPersonFieldOfView=55.f);
110  virtual ~NpcAnimation();
111 
112  virtual void enableHeadAnimation(bool enable);
113 
116  virtual void setAccurateAiming(bool enabled);
117 
118  virtual void setWeaponGroup(const std::string& group);
119 
120  virtual osg::Vec3f runAnimation(float timepassed);
121 
124  virtual void setPitchFactor(float factor) { mPitchFactor = factor; }
125 
126  virtual void showWeapons(bool showWeapon);
127  virtual void showCarriedLeft(bool show);
128 
129  virtual void attachArrow();
130  virtual void releaseArrow(float attackStrength);
131 
132  virtual osg::Group* getArrowBone();
133  virtual osg::Node* getWeaponNode();
135 
136  // WeaponAnimation
137  virtual void showWeapon(bool show) { showWeapons(show); }
138 
139  void setViewMode(ViewMode viewMode);
140 
141  void updateParts();
142 
144  void rebuild();
145 
147  int getSlot(const osg::NodePath& path) const;
148 
149  virtual void setVampire(bool vampire);
150 
152  void setFirstPersonOffset(const osg::Vec3f& offset);
153 
154  virtual void updatePtr(const MWWorld::Ptr& updated);
155 
158  static const std::vector<const ESM::BodyPart*>& getBodyParts(const std::string& raceId, bool female, bool firstperson, bool werewolf);
159 };
160 
161 }
162 
163 #endif
boost::shared_ptr< WeaponAnimationTime > mWeaponAnimationTime
Definition: npcanimation.hpp:70
void updateParts()
Definition: npcanimation.cpp:532
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew)
Definition: npcanimation.cpp:975
virtual void attachArrow()
Definition: npcanimation.cpp:940
void rebuild()
Rebuilds the NPC, updating their root model, animation sources, and equipment.
Definition: npcanimation.cpp:402
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority)
Definition: npcanimation.cpp:718
ViewMode
Definition: npcanimation.hpp:32
void removePartGroup(int group)
Definition: npcanimation.cpp:728
PartHolderPtr mObjectParts[ESM::PRT_Count]
Definition: npcanimation.hpp:44
osg::Vec3f mFirstPersonOffset
Definition: npcanimation.hpp:65
virtual void setPitchFactor(float factor)
Definition: npcanimation.hpp:124
std::string mHairModel
Definition: npcanimation.hpp:49
void removeIndividualPart(ESM::PartReferenceType type)
Definition: npcanimation.cpp:705
virtual void showWeapons(bool showWeapon)
Definition: npcanimation.cpp:886
PartReferenceType
Definition: loadarmo.hpp:13
Definition: npcanimation.hpp:33
virtual ~NpcAnimation()
Definition: npcanimation.cpp:270
Handles attach & release of projectiles for ranged weapons.
Definition: weaponanimation.hpp:29
osg::ref_ptr< NeckController > mFirstPersonNeckController
Definition: npcanimation.hpp:93
const ESM::NPC * mNpc
Definition: npcanimation.hpp:47
virtual osg::Vec3f runAnimation(float timepassed)
Definition: npcanimation.cpp:681
Definition: npcanimation.hpp:58
virtual void setAccurateAiming(bool enabled)
Definition: npcanimation.cpp:1154
bool mShowCarriedLeft
Definition: npcanimation.hpp:52
virtual void equipmentChanged()
Definition: npcanimation.cpp:1013
virtual void showCarriedLeft(bool show)
Definition: npcanimation.cpp:920
float mAimingFactor
Definition: npcanimation.hpp:75
static const std::vector< const ESM::BodyPart * > & getBodyParts(const std::string &raceId, bool female, bool firstperson, bool werewolf)
Definition: npcanimation.cpp:1046
Variant of the ContainerStore for NPCs.
Definition: inventorystore.hpp:20
float mFirstPersonFieldOfView
Definition: npcanimation.hpp:67
static const PartBoneMap sPartList
Definition: npcanimation.hpp:39
Definition: npcanimation.hpp:56
float mPitchFactor
Definition: weaponanimation.hpp:66
Definition: actoranimation.hpp:31
ViewMode mViewMode
Definition: npcanimation.hpp:50
virtual void setVampire(bool vampire)
Definition: npcanimation.cpp:1018
Definition: loadnpc.hpp:23
virtual void enableHeadAnimation(bool enable)
Definition: npcanimation.cpp:1003
bool mAccurateAiming
Definition: npcanimation.hpp:74
void updateNpcBase()
Definition: npcanimation.cpp:427
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:1031
void setViewMode(ViewMode viewMode)
Definition: npcanimation.cpp:317
virtual osg::Node * getWeaponNode()
Definition: npcanimation.cpp:962
int mPartslots[ESM::PRT_Count]
Definition: npcanimation.hpp:62
Definition: loadmgef.hpp:13
NpcAnimation(const MWWorld::Ptr &ptr, osg::ref_ptr< osg::Group > parentNode, Resource::ResourceSystem *resourceSystem, bool disableListener=false, bool disableSounds=false, ViewMode viewMode=VM_Normal, float firstPersonFieldOfView=55.f)
Definition: npcanimation.cpp:287
std::map< ESM::PartReferenceType, std::string > PartBoneMap
Definition: npcanimation.hpp:30
virtual void releaseArrow(float attackStrength)
Definition: npcanimation.cpp:945
bool mSoundsDisabled
Definition: npcanimation.hpp:72
bool mListenerDisabled
Definition: npcanimation.hpp:41
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:412
virtual void updatePtr(const MWWorld::Ptr &updated)
Definition: npcanimation.cpp:1036
bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:737
bool mShowWeapons
Definition: npcanimation.hpp:51
NpcType mNpcType
Definition: npcanimation.hpp:60
virtual osg::Group * getArrowBone()
Definition: npcanimation.cpp:950
Definition: npcanimation.hpp:23
Definition: npcanimation.hpp:57
virtual void addControllers()
Definition: npcanimation.cpp:862
Definition: npcanimation.hpp:35
std::string mSoundIds[ESM::PRT_Count]
Definition: npcanimation.hpp:45
virtual void showWeapon(bool show)
Definition: npcanimation.hpp:137
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:54
std::string mHeadModel
Definition: npcanimation.hpp:48
PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename, const std::string &bonefilter, bool enchantedGlow, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:670
void addPartGroup(int group, int priority, const std::vector< ESM::PartReference > &parts, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
Definition: npcanimation.cpp:814
boost::shared_ptr< HeadAnimationTime > mHeadAnimationTime
Definition: npcanimation.hpp:69
Definition: npcanimation.hpp:34
boost::shared_ptr< PartHolder > PartHolderPtr
Definition: animation.hpp:75
Definition: loadarmo.hpp:43
virtual Resource::ResourceSystem * getResourceSystem()
Definition: npcanimation.cpp:970
virtual void setWeaponGroup(const std::string &group)
Definition: npcanimation.cpp:1008
virtual void setRenderBin()
Set the render bin for this animation's object root. May be customized by subclasses.
Definition: npcanimation.cpp:382
int mPartPriorities[ESM::PRT_Count]
Definition: npcanimation.hpp:63