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

152 lines
4.7 KiB
C++
Raw Normal View History

#ifndef GAME_RENDER_NPCANIMATION_H
#define GAME_RENDER_NPCANIMATION_H
#include "animation.hpp"
#include "../mwworld/inventorystore.hpp"
2014-03-12 10:30:44 +00:00
#include "weaponanimation.hpp"
2012-11-08 09:46:24 +00:00
namespace ESM
{
struct NPC;
}
namespace MWRender
{
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
{
private:
MWWorld::Ptr mReference;
public:
HeadAnimationTime(MWWorld::Ptr reference) : mReference(reference) {}
virtual Ogre::Real getValue() const;
virtual void setValue(Ogre::Real value)
{ }
};
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
{
public:
virtual void equipmentChanged() { updateParts(); }
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound);
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
bool mListenerDisabled;
2012-04-12 00:16:22 +00:00
2013-02-02 10:53:22 +00:00
// Bounded Parts
NifOgre::ObjectScenePtr mObjectParts[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;
2012-09-13 17:03:31 +00:00
int mVisibilityFlags;
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
int mPartPriorities[ESM::PRT_Count];
Ogre::Vector3 mFirstPersonOffset;
Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
float mAlpha;
2013-08-07 23:21:57 +00:00
void updateNpcBase();
NifOgre::ObjectScenePtr insertBoundedPart(const std::string &model, int group, const std::string &bonename,
2013-11-19 23:07:26 +00:00
bool enchantedGlow, Ogre::Vector3* 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,
bool enchantedGlow=false, Ogre::Vector3* 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,
bool enchantedGlow=false, Ogre::Vector3* glowColor=NULL);
2012-09-13 17:03:31 +00:00
void applyAlpha(float alpha, Ogre::Entity* ent, NifOgre::ObjectScenePtr scene);
2013-01-09 15:55:55 +00:00
public:
/**
* @param ptr
* @param node
* @param visibilityFlags
* @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 viewMode
*/
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener = false,
ViewMode viewMode=VM_Normal);
2013-01-09 15:55:55 +00:00
virtual ~NpcAnimation();
virtual void setWeaponGroup(const std::string& group) { mWeaponAnimationTime->setGroup(group); }
virtual Ogre::Vector3 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 showa);
virtual void attachArrow();
virtual void releaseArrow();
2014-03-12 10:30:44 +00:00
// WeaponAnimation
virtual NifOgre::ObjectScenePtr getWeapon() { return mObjectParts[ESM::PRT_Weapon]; }
virtual void showWeapon(bool show) { showWeapons(show); }
virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot);
void setViewMode(ViewMode viewMode);
void updateParts();
/// \brief Applies a translation to the arms and hands.
/// This may be called multiple times before the animation
/// is updated to add additional offsets.
void addFirstPersonOffset(const Ogre::Vector3 &offset);
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
void rebuild();
/// Make the NPC only partially visible
virtual void setAlpha(float alpha);
/// Prepare this animation for being rendered with \a camera (rotates billboard nodes)
virtual void preRender (Ogre::Camera* camera);
};
}
#endif