1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 18:19:55 +00:00
openmw-tes3mp/apps/openmw/mwrender/npcanimation.hpp

165 lines
5.4 KiB
C++
Raw Normal View History

#ifndef GAME_RENDER_NPCANIMATION_H
#define GAME_RENDER_NPCANIMATION_H
#include "animation.hpp"
#include "../mwworld/inventorystore.hpp"
#include "actoranimation.hpp"
2014-03-12 10:30:44 +00:00
#include "weaponanimation.hpp"
2012-11-08 09:46:24 +00:00
namespace ESM
{
struct NPC;
2016-02-08 23:26:22 +00:00
struct BodyPart;
2012-11-08 09:46:24 +00:00
}
namespace MWRender
{
class NeckController;
class HeadAnimationTime;
class NpcAnimation : public ActorAnimation, public WeaponAnimation, public MWWorld::InventoryStoreListener
2013-01-06 13:39:39 +00:00
{
public:
virtual void equipmentChanged();
2016-09-15 14:41:20 +00:00
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew);
2013-01-06 13:39:39 +00:00
public:
typedef std::map<ESM::PartReferenceType,std::string> PartBoneMap;
enum ViewMode {
VM_Normal,
VM_FirstPerson,
VM_HeadOnly
};
2012-04-05 03:23:24 +00:00
private:
static const PartBoneMap sPartList;
2013-01-06 13:39:39 +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];
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;
bool mShowWeapons;
bool mShowCarriedLeft;
2012-11-08 09:46:24 +00:00
enum NpcType
{
Type_Normal,
Type_Werewolf,
Type_Vampire
};
NpcType mNpcType;
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
int mPartPriorities[ESM::PRT_Count];
osg::Vec3f mFirstPersonOffset;
// Field of view to use when rendering first person meshes
float mFirstPersonFieldOfView;
std::shared_ptr<HeadAnimationTime> mHeadAnimationTime;
std::shared_ptr<WeaponAnimationTime> mWeaponAnimationTime;
bool mSoundsDisabled;
bool mAccurateAiming;
float mAimingFactor;
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);
void removeIndividualPart(ESM::PartReferenceType type);
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
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);
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
virtual void setRenderBin();
osg::ref_ptr<NeckController> mFirstPersonNeckController;
static bool isFirstPersonPart(const ESM::BodyPart* bodypart);
static bool isFemalePart(const ESM::BodyPart* bodypart);
protected:
virtual void addControllers();
2013-01-09 15:55:55 +00:00
public:
/**
* @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.
* @param disableSounds Same as \a disableListener but for playing items sounds
* @param viewMode
*/
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);
2013-01-09 15:55:55 +00:00
virtual ~NpcAnimation();
virtual void enableHeadAnimation(bool enable);
/// 1: the first person meshes follow the camera's rotation completely
/// 0: the first person meshes follow the camera with a reduced factor, so you can look down at your own hands
virtual void setAccurateAiming(bool enabled);
2015-04-15 20:11:38 +00:00
virtual void setWeaponGroup(const std::string& group);
2015-04-19 12:42:09 +00:00
virtual osg::Vec3f runAnimation(float timepassed);
2013-01-09 15:55:55 +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; }
virtual void showWeapons(bool showWeapon);
virtual void showCarriedLeft(bool show);
virtual void attachArrow();
virtual void releaseArrow(float attackStrength);
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); }
void setViewMode(ViewMode viewMode);
void updateParts();
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
void rebuild();
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;
virtual void setVampire(bool vampire);
2015-05-14 15:34:55 +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);
2016-02-08 23:26:22 +00:00
/// Get a list of body parts that may be used by an NPC of given race and gender.
/// @note This is a fixed size list, one list item for each ESM::PartReferenceType, may contain NULL body parts.
static const std::vector<const ESM::BodyPart*>& getBodyParts(const std::string& raceId, bool female, bool firstperson, bool werewolf);
};
}
#endif