2014-01-05 18:22:29 +01:00
|
|
|
#ifndef GAME_RENDER_NPCANIMATION_H
|
|
|
|
#define GAME_RENDER_NPCANIMATION_H
|
2012-07-17 09:27:12 +02:00
|
|
|
|
2011-11-24 01:48:54 -05:00
|
|
|
#include "animation.hpp"
|
2011-12-11 22:40:00 -05:00
|
|
|
|
2013-11-15 02:08:36 +01:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2011-12-11 22:40:00 -05:00
|
|
|
|
2014-03-12 11:30:44 +01:00
|
|
|
#include "weaponanimation.hpp"
|
|
|
|
|
2012-11-08 13:46:24 +04:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct NPC;
|
|
|
|
}
|
|
|
|
|
2013-01-05 21:12:08 -08:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2011-11-24 01:48:54 -05:00
|
|
|
|
2014-01-17 09:41:23 +01:00
|
|
|
class HeadAnimationTime : public Ogre::ControllerValue<Ogre::Real>
|
2013-12-07 14:11:06 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
MWWorld::Ptr mReference;
|
|
|
|
public:
|
2014-01-17 09:41:23 +01:00
|
|
|
HeadAnimationTime(MWWorld::Ptr reference) : mReference(reference) {}
|
2013-12-07 14:11:06 +01:00
|
|
|
|
|
|
|
virtual Ogre::Real getValue() const;
|
|
|
|
virtual void setValue(Ogre::Real value)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2014-03-12 11:30:44 +01:00
|
|
|
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
2013-01-06 05:39:39 -08:00
|
|
|
{
|
2013-11-15 02:08:36 +01:00
|
|
|
public:
|
|
|
|
virtual void equipmentChanged() { updateParts(); }
|
|
|
|
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound);
|
|
|
|
|
2013-01-06 05:39:39 -08:00
|
|
|
public:
|
2013-08-05 18:59:55 -07:00
|
|
|
typedef std::map<ESM::PartReferenceType,std::string> PartBoneMap;
|
2013-01-06 01:59:18 -08:00
|
|
|
|
2013-08-05 18:59:55 -07:00
|
|
|
enum ViewMode {
|
|
|
|
VM_Normal,
|
|
|
|
VM_FirstPerson,
|
|
|
|
VM_HeadOnly
|
|
|
|
};
|
2013-04-09 09:07:05 -07:00
|
|
|
|
2012-04-04 23:23:24 -04:00
|
|
|
private:
|
2013-08-05 18:59:55 -07:00
|
|
|
static const PartBoneMap sPartList;
|
2013-01-06 05:39:39 -08:00
|
|
|
|
2013-11-15 02:08:36 +01:00
|
|
|
bool mListenerDisabled;
|
2012-04-11 20:16:22 -04:00
|
|
|
|
2013-02-02 02:53:22 -08:00
|
|
|
// Bounded Parts
|
2013-12-07 20:12:03 +01:00
|
|
|
NifOgre::ObjectScenePtr mObjectParts[ESM::PRT_Count];
|
2012-11-08 13:46:24 +04:00
|
|
|
|
2013-08-07 16:45:29 -07:00
|
|
|
const ESM::NPC *mNpc;
|
|
|
|
std::string mHeadModel;
|
|
|
|
std::string mHairModel;
|
|
|
|
ViewMode mViewMode;
|
2013-04-28 11:41:01 +01:00
|
|
|
bool mShowWeapons;
|
2013-12-27 22:00:16 +01:00
|
|
|
bool mShowCarriedLeft;
|
2012-11-08 13:46:24 +04:00
|
|
|
|
2014-01-04 20:43:57 +01:00
|
|
|
enum NpcType
|
|
|
|
{
|
|
|
|
Type_Normal,
|
|
|
|
Type_Werewolf,
|
|
|
|
Type_Vampire
|
|
|
|
};
|
|
|
|
NpcType mNpcType;
|
|
|
|
|
2012-09-13 19:03:31 +02:00
|
|
|
int mVisibilityFlags;
|
|
|
|
|
2013-08-05 18:59:55 -07: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 01:59:18 -08:00
|
|
|
|
2013-10-02 05:16:52 -04:00
|
|
|
Ogre::Vector3 mFirstPersonOffset;
|
|
|
|
|
2014-01-17 09:41:23 +01:00
|
|
|
Ogre::SharedPtr<HeadAnimationTime> mHeadAnimationTime;
|
2014-02-04 03:46:15 +01:00
|
|
|
Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
2013-12-07 14:11:06 +01:00
|
|
|
|
2013-12-08 23:05:21 +01:00
|
|
|
float mAlpha;
|
|
|
|
|
2013-08-07 16:21:57 -07:00
|
|
|
void updateNpcBase();
|
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
NifOgre::ObjectScenePtr insertBoundedPart(const std::string &model, int group, const std::string &bonename,
|
2013-11-20 00:07:26 +01:00
|
|
|
bool enchantedGlow, Ogre::Vector3* glowColor=NULL);
|
2013-02-21 23:56:34 +04:00
|
|
|
|
2013-08-05 18:59:55 -07:00
|
|
|
void removeIndividualPart(ESM::PartReferenceType type);
|
|
|
|
void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-11-20 00:07:26 +01:00
|
|
|
bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh,
|
|
|
|
bool enchantedGlow=false, Ogre::Vector3* glowColor=NULL);
|
2012-07-12 20:12:18 -07:00
|
|
|
void removePartGroup(int group);
|
2013-11-20 00:07:26 +01:00
|
|
|
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
|
|
|
bool enchantedGlow=false, Ogre::Vector3* glowColor=NULL);
|
2012-09-13 19:03:31 +02:00
|
|
|
|
2013-12-08 23:05:21 +01:00
|
|
|
void applyAlpha(float alpha, Ogre::Entity* ent, NifOgre::ObjectScenePtr scene);
|
|
|
|
|
2013-01-09 07:55:55 -08:00
|
|
|
public:
|
2013-11-15 02:08:36 +01:00
|
|
|
/**
|
|
|
|
* @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,
|
2013-04-09 09:07:05 -07:00
|
|
|
ViewMode viewMode=VM_Normal);
|
2013-01-09 07:55:55 -08:00
|
|
|
virtual ~NpcAnimation();
|
|
|
|
|
2014-02-04 03:46:15 +01:00
|
|
|
virtual void setWeaponGroup(const std::string& group) { mWeaponAnimationTime->setGroup(group); }
|
|
|
|
|
2013-01-18 16:21:29 -08:00
|
|
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
2013-01-09 07:55:55 -08:00
|
|
|
|
2014-02-04 04:00:52 +01: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 11:41:01 +01:00
|
|
|
virtual void showWeapons(bool showWeapon);
|
2013-12-27 22:00:16 +01:00
|
|
|
virtual void showCarriedLeft(bool showa);
|
2013-04-28 11:41:01 +01:00
|
|
|
|
2014-02-04 04:11:46 +01:00
|
|
|
virtual void attachArrow();
|
|
|
|
virtual void releaseArrow();
|
|
|
|
|
2014-03-12 11:30:44 +01: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);
|
2014-02-04 04:11:46 +01:00
|
|
|
|
2013-04-09 15:10:14 -07:00
|
|
|
void setViewMode(ViewMode viewMode);
|
|
|
|
|
2013-11-14 14:41:10 +01:00
|
|
|
void updateParts();
|
2013-08-08 17:16:24 -07:00
|
|
|
|
2013-10-02 05:16:52 -04:00
|
|
|
/// \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);
|
|
|
|
|
2013-08-08 17:16:24 -07:00
|
|
|
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
|
|
|
|
void rebuild();
|
2013-12-08 23:05:21 +01:00
|
|
|
|
|
|
|
/// Make the NPC only partially visible
|
|
|
|
virtual void setAlpha(float alpha);
|
2013-12-26 18:16:28 +01:00
|
|
|
|
|
|
|
/// Prepare this animation for being rendered with \a camera (rotates billboard nodes)
|
|
|
|
virtual void preRender (Ogre::Camera* camera);
|
2011-11-24 01:48:54 -05:00
|
|
|
};
|
2012-07-12 20:12:18 -07:00
|
|
|
|
2011-11-24 01:48:54 -05:00
|
|
|
}
|
2013-01-05 21:12:08 -08:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#endif
|