OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MWRender::NpcAnimation Class Reference

#include <npcanimation.hpp>

Inheritance diagram for MWRender::NpcAnimation:
Collaboration diagram for MWRender::NpcAnimation:

Public Types

enum  ViewMode { VM_Normal, VM_FirstPerson, VM_HeadOnly }
 
typedef std::map
< ESM::PartReferenceType,
std::string > 
PartBoneMap
 
- Public Types inherited from MWRender::Animation
enum  BoneGroup { BoneGroup_LowerBody = 0, BoneGroup_Torso, BoneGroup_LeftArm, BoneGroup_RightArm }
 
enum  BlendMask {
  BlendMask_LowerBody = 1<<0, BlendMask_Torso = 1<<1, BlendMask_LeftArm = 1<<2, BlendMask_RightArm = 1<<3,
  BlendMask_UpperBody = BlendMask_Torso | BlendMask_LeftArm | BlendMask_RightArm, BlendMask_All = BlendMask_LowerBody | BlendMask_UpperBody
}
 

Public Member Functions

virtual void equipmentChanged ()
 
virtual void permanentEffectAdded (const ESM::MagicEffect *magicEffect, bool isNew)
 
 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)
 
virtual ~NpcAnimation ()
 
virtual void enableHeadAnimation (bool enable)
 
virtual void setAccurateAiming (bool enabled)
 
virtual void setWeaponGroup (const std::string &group)
 
virtual osg::Vec3f runAnimation (float timepassed)
 
virtual void setPitchFactor (float factor)
 
virtual void showWeapons (bool showWeapon)
 
virtual void showCarriedLeft (bool show)
 
virtual void attachArrow ()
 
virtual void releaseArrow (float attackStrength)
 
virtual osg::Group * getArrowBone ()
 
virtual osg::Node * getWeaponNode ()
 
virtual Resource::ResourceSystemgetResourceSystem ()
 
virtual void showWeapon (bool show)
 
void setViewMode (ViewMode viewMode)
 
void updateParts ()
 
void rebuild ()
 Rebuilds the NPC, updating their root model, animation sources, and equipment. More...
 
int getSlot (const osg::NodePath &path) const
 Get the inventory slot that the given node path leads into, or -1 if not found. More...
 
virtual void setVampire (bool vampire)
 
void setFirstPersonOffset (const osg::Vec3f &offset)
 Set a translation offset (in object root space) to apply to meshes when in first person mode. More...
 
virtual void updatePtr (const MWWorld::Ptr &updated)
 
- Public Member Functions inherited from MWRender::ActorAnimation
 ActorAnimation (const MWWorld::Ptr &ptr, osg::ref_ptr< osg::Group > parentNode, Resource::ResourceSystem *resourceSystem)
 
virtual ~ActorAnimation ()
 
virtual void itemAdded (const MWWorld::ConstPtr &item, int count)
 
virtual void itemRemoved (const MWWorld::ConstPtr &item, int count)
 
- Public Member Functions inherited from MWRender::Animation
void setTextKeyListener (TextKeyListener *listener)
 
 Animation (const MWWorld::Ptr &ptr, osg::ref_ptr< osg::Group > parentNode, Resource::ResourceSystem *resourceSystem)
 
virtual ~Animation ()
 Must be thread safe. More...
 
MWWorld::ConstPtr getPtr () const
 
MWWorld::Ptr getPtr ()
 
void setActive (int active)
 
osg::Group * getOrCreateObjectRoot ()
 
osg::Group * getObjectRoot ()
 
void addEffect (const std::string &model, int effectId, bool loop=false, const std::string &bonename="", const std::string &texture="", float scale=1.0f)
 Add an effect mesh attached to a bone or the insert scene node. More...
 
void removeEffect (int effectId)
 
void getLoopingEffects (std::vector< int > &out) const
 
void addSpellCastGlow (const ESM::MagicEffect *effect, float glowDuration=1.5)
 
bool hasAnimation (const std::string &anim) const
 
void setAccumulation (const osg::Vec3f &accum)
 
void play (const std::string &groupname, const AnimPriority &priority, int blendMask, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops, bool loopfallback=false)
 
void adjustSpeedMult (const std::string &groupname, float speedmult)
 
bool isPlaying (const std::string &groupname) const
 
bool upperBodyReady () const
 Returns true if no important animations are currently playing on the upper body. More...
 
bool getInfo (const std::string &groupname, float *complete=NULL, float *speedmult=NULL) const
 
float getStartTime (const std::string &groupname) const
 Get the absolute position in the animation track of the first text key with the given group. More...
 
float getTextKeyTime (const std::string &textKey) const
 Get the absolute position in the animation track of the text key. More...
 
float getCurrentTime (const std::string &groupname) const
 Get the current absolute position in the animation track for the animation that is currently playing from the given group. More...
 
size_t getCurrentLoopCount (const std::string &groupname) const
 
void disable (const std::string &groupname)
 
float getVelocity (const std::string &groupname) const
 
void setLoopingEnabled (const std::string &groupname, bool enabled)
 
void updateEffects ()
 This is typically called as part of runAnimation, but may be called manually if needed. More...
 
const osg::Node * getNode (const std::string &name) const
 
void setAlpha (float alpha)
 A value < 1 makes the animation translucent, 1.f = fully opaque. More...
 
virtual void setLightEffect (float effect)
 
virtual void setHeadPitch (float pitchRadians)
 
virtual void setHeadYaw (float yawRadians)
 
virtual float getHeadPitch () const
 
virtual float getHeadYaw () const
 
- Public Member Functions inherited from MWRender::WeaponAnimation
 WeaponAnimation ()
 
virtual ~WeaponAnimation ()
 
void attachArrow (MWWorld::Ptr actor)
 
void releaseArrow (MWWorld::Ptr actor, float attackStrength)
 
void addControllers (const std::map< std::string, osg::ref_ptr< osg::MatrixTransform > > &nodes, std::multimap< osg::ref_ptr< osg::Node >, osg::ref_ptr< osg::NodeCallback > > &map, osg::Node *objectRoot)
 Add WeaponAnimation-related controllers to nodes and store the added controllers in map. More...
 
void deleteControllers ()
 
void configureControllers (float characterPitchRadians)
 Configure controllers, should be called every animation frame. More...
 

Static Public Member Functions

static const std::vector
< const ESM::BodyPart * > & 
getBodyParts (const std::string &raceId, bool female, bool firstperson, bool werewolf)
 

Protected Member Functions

virtual void addControllers ()
 
- Protected Member Functions inherited from MWRender::Animation
const NodeMapgetNodeMap () const
 
void resetActiveGroups ()
 
size_t detectBlendMask (const osg::Node *node) const
 
void updatePosition (float oldtime, float newtime, osg::Vec3f &position)
 
bool reset (AnimState &state, const std::multimap< float, std::string > &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback)
 
void handleTextKey (AnimState &state, const std::string &groupname, const std::multimap< float, std::string >::const_iterator &key, const std::multimap< float, std::string > &map)
 
void setObjectRoot (const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
 
void loadAllAnimationsInFolder (const std::string &model, const std::string &baseModel)
 
void addAnimSource (const std::string &model, const std::string &baseModel)
 
void addSingleAnimSource (const std::string &model, const std::string &baseModel)
 
void addExtraLight (osg::ref_ptr< osg::Group > parent, const ESM::Light *light)
 
void clearAnimSources ()
 
osg::Vec4f getEnchantmentColor (const MWWorld::ConstPtr &item) const
 
void addGlow (osg::ref_ptr< osg::Node > node, osg::Vec4f glowColor, float glowDuration=-1)
 
- Protected Member Functions inherited from MWRender::WeaponAnimation
void setControllerRotate (const osg::Quat &rotate)
 
void setControllerEnabled (bool enabled)
 

Private Types

enum  NpcType { Type_Normal, Type_Werewolf, Type_Vampire }
 

Private Member Functions

void updateNpcBase ()
 
PartHolderPtr insertBoundedPart (const std::string &model, const std::string &bonename, const std::string &bonefilter, bool enchantedGlow, osg::Vec4f *glowColor=NULL)
 
void removeIndividualPart (ESM::PartReferenceType type)
 
void reserveIndividualPart (ESM::PartReferenceType type, int group, int priority)
 
bool addOrReplaceIndividualPart (ESM::PartReferenceType type, int group, int priority, const std::string &mesh, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
 
void removePartGroup (int group)
 
void addPartGroup (int group, int priority, const std::vector< ESM::PartReference > &parts, bool enchantedGlow=false, osg::Vec4f *glowColor=NULL)
 
virtual void setRenderBin ()
 Set the render bin for this animation's object root. May be customized by subclasses. More...
 

Static Private Member Functions

static bool isFirstPersonPart (const ESM::BodyPart *bodypart)
 
static bool isFemalePart (const ESM::BodyPart *bodypart)
 

Private Attributes

PartHolderPtr mObjectParts [ESM::PRT_Count]
 
std::string mSoundIds [ESM::PRT_Count]
 
const ESM::NPCmNpc
 
std::string mHeadModel
 
std::string mHairModel
 
ViewMode mViewMode
 
bool mShowWeapons
 
bool mShowCarriedLeft
 
NpcType mNpcType
 
int mPartslots [ESM::PRT_Count]
 
int mPartPriorities [ESM::PRT_Count]
 
osg::Vec3f mFirstPersonOffset
 
float mFirstPersonFieldOfView
 
std::shared_ptr
< HeadAnimationTime
mHeadAnimationTime
 
std::shared_ptr
< WeaponAnimationTime
mWeaponAnimationTime
 
bool mSoundsDisabled
 
bool mAccurateAiming
 
float mAimingFactor
 
osg::ref_ptr< NeckControllermFirstPersonNeckController
 

Static Private Attributes

static const PartBoneMap sPartList = createPartListMap()
 

Additional Inherited Members

- Static Public Attributes inherited from MWRender::Animation
static const size_t sNumBlendMasks = 4
 
- Protected Types inherited from MWRender::Animation
typedef std::map< std::string,
AnimState
AnimStateMap
 
typedef std::vector
< std::shared_ptr< AnimSource > > 
AnimSourceList
 
typedef std::multimap
< osg::ref_ptr< osg::Node >
, osg::ref_ptr
< osg::NodeCallback > > 
ControllerMap
 
typedef std::map< std::string,
osg::ref_ptr
< osg::MatrixTransform > > 
NodeMap
 
- Protected Attributes inherited from MWRender::Animation
AnimStateMap mStates
 
AnimSourceList mAnimSources
 
osg::ref_ptr< osg::Group > mInsert
 
osg::ref_ptr< osg::Group > mObjectRoot
 
SceneUtil::SkeletonmSkeleton
 
osg::ref_ptr< osg::Node > mAccumRoot
 
osg::ref_ptr
< NifOsg::KeyframeController
mAccumCtrl
 
osg::ref_ptr
< ResetAccumRootCallback
mResetAccumRootCallback
 
ControllerMap mActiveControllers
 
std::shared_ptr< AnimationTimemAnimationTimePtr [sNumBlendMasks]
 
NodeMap mNodeMap
 
bool mNodeMapCreated
 
MWWorld::Ptr mPtr
 
Resource::ResourceSystemmResourceSystem
 
osg::Vec3f mAccumulate
 
TextKeyListenermTextKeyListener
 
osg::ref_ptr< RotateControllermHeadController
 
float mHeadYawRadians
 
float mHeadPitchRadians
 
bool mHasMagicEffects
 
osg::ref_ptr
< SceneUtil::LightSource
mGlowLight
 
osg::ref_ptr< GlowUpdatermGlowUpdater
 
float mAlpha
 
std::map< std::string, float > mAnimVelocities
 
osg::ref_ptr
< SceneUtil::LightListCallback
mLightListCallback
 
bool mUseAdditionalSources
 
- Protected Attributes inherited from MWRender::WeaponAnimation
PartHolderPtr mAmmunition
 
osg::ref_ptr< RotateControllermSpineControllers [2]
 
float mPitchFactor
 

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
Type_Normal 
Type_Werewolf 
Type_Vampire 
Enumerator
VM_Normal 
VM_FirstPerson 
VM_HeadOnly 

Constructor & Destructor Documentation

MWRender::NpcAnimation::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 
)
Parameters
ptr
disableListenerDon'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.
disableSoundsSame as disableListener but for playing items sounds
viewMode

Here is the call graph for this function:

MWRender::NpcAnimation::~NpcAnimation ( )
virtual

Member Function Documentation

void MWRender::NpcAnimation::addControllers ( )
protectedvirtual

Provided to allow derived classes adding their own controllers. Note, the controllers must be added to mActiveControllers so they get cleaned up properly on the next controller rebuild. A controller rebuild may be necessary to ensure correct ordering.

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

bool MWRender::NpcAnimation::addOrReplaceIndividualPart ( ESM::PartReferenceType  type,
int  group,
int  priority,
const std::string &  mesh,
bool  enchantedGlow = false,
osg::Vec4f *  glowColor = NULL 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::addPartGroup ( int  group,
int  priority,
const std::vector< ESM::PartReference > &  parts,
bool  enchantedGlow = false,
osg::Vec4f *  glowColor = NULL 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::attachArrow ( )
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::enableHeadAnimation ( bool  enable)
virtual

Reimplemented from MWRender::Animation.

void MWRender::NpcAnimation::equipmentChanged ( )
virtual

Fired when items are equipped or unequipped

Reimplemented from MWWorld::InventoryStoreListener.

Here is the call graph for this function:

osg::Group * MWRender::NpcAnimation::getArrowBone ( )
virtual
const std::vector< const ESM::BodyPart * > & MWRender::NpcAnimation::getBodyParts ( const std::string &  raceId,
bool  female,
bool  firstperson,
bool  werewolf 
)
static

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.

Here is the call graph for this function:

Here is the caller graph for this function:

Resource::ResourceSystem * MWRender::NpcAnimation::getResourceSystem ( )
virtual
int MWRender::NpcAnimation::getSlot ( const osg::NodePath &  path) const

Get the inventory slot that the given node path leads into, or -1 if not found.

osg::Node * MWRender::NpcAnimation::getWeaponNode ( )
virtual
PartHolderPtr MWRender::NpcAnimation::insertBoundedPart ( const std::string &  model,
const std::string &  bonename,
const std::string &  bonefilter,
bool  enchantedGlow,
osg::Vec4f *  glowColor = NULL 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWRender::NpcAnimation::isFemalePart ( const ESM::BodyPart bodypart)
staticprivate

Here is the caller graph for this function:

bool MWRender::NpcAnimation::isFirstPersonPart ( const ESM::BodyPart bodypart)
staticprivate

Here is the caller graph for this function:

void MWRender::NpcAnimation::permanentEffectAdded ( const ESM::MagicEffect magicEffect,
bool  isNew 
)
virtual
Parameters
effect
isNewIs this effect new (e.g. the item for it was just now manually equipped) or was it loaded from a savegame / initial game state?
If it isn't new, non-looping VFX should not be played.
playSoundPlay effect sound?

Reimplemented from MWWorld::InventoryStoreListener.

Here is the call graph for this function:

void MWRender::NpcAnimation::rebuild ( )

Rebuilds the NPC, updating their root model, animation sources, and equipment.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::releaseArrow ( float  attackStrength)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

void MWRender::NpcAnimation::removeIndividualPart ( ESM::PartReferenceType  type)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::removePartGroup ( int  group)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::reserveIndividualPart ( ESM::PartReferenceType  type,
int  group,
int  priority 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

osg::Vec3f MWRender::NpcAnimation::runAnimation ( float  timepassed)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

void MWRender::NpcAnimation::setAccurateAiming ( bool  enabled)
virtual

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

Reimplemented from MWRender::Animation.

void MWRender::NpcAnimation::setFirstPersonOffset ( const osg::Vec3f &  offset)

Set a translation offset (in object root space) to apply to meshes when in first person mode.

Here is the caller graph for this function:

virtual void MWRender::NpcAnimation::setPitchFactor ( float  factor)
inlinevirtual

A relative factor (0-1) that decides if and how much the skeleton should be pitched to indicate the facing orientation of the character.

Reimplemented from MWRender::Animation.

void MWRender::NpcAnimation::setRenderBin ( )
privatevirtual

Set the render bin for this animation's object root. May be customized by subclasses.

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::setVampire ( bool  vampire)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

void MWRender::NpcAnimation::setViewMode ( NpcAnimation::ViewMode  viewMode)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::setWeaponGroup ( const std::string &  group)
virtual

Reimplemented from MWRender::Animation.

void MWRender::NpcAnimation::showCarriedLeft ( bool  show)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MWRender::NpcAnimation::showWeapon ( bool  show)
inlinevirtual

Implements MWRender::WeaponAnimation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::showWeapons ( bool  showWeapon)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::updateNpcBase ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::updateParts ( )

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::NpcAnimation::updatePtr ( const MWWorld::Ptr updated)
virtual

Reimplemented from MWRender::Animation.

Here is the call graph for this function:

Member Data Documentation

bool MWRender::NpcAnimation::mAccurateAiming
private
float MWRender::NpcAnimation::mAimingFactor
private
float MWRender::NpcAnimation::mFirstPersonFieldOfView
private
osg::ref_ptr<NeckController> MWRender::NpcAnimation::mFirstPersonNeckController
private
osg::Vec3f MWRender::NpcAnimation::mFirstPersonOffset
private
std::string MWRender::NpcAnimation::mHairModel
private
std::shared_ptr<HeadAnimationTime> MWRender::NpcAnimation::mHeadAnimationTime
private
std::string MWRender::NpcAnimation::mHeadModel
private
const ESM::NPC* MWRender::NpcAnimation::mNpc
private
NpcType MWRender::NpcAnimation::mNpcType
private
PartHolderPtr MWRender::NpcAnimation::mObjectParts[ESM::PRT_Count]
private
int MWRender::NpcAnimation::mPartPriorities[ESM::PRT_Count]
private
int MWRender::NpcAnimation::mPartslots[ESM::PRT_Count]
private
bool MWRender::NpcAnimation::mShowCarriedLeft
private
bool MWRender::NpcAnimation::mShowWeapons
private
std::string MWRender::NpcAnimation::mSoundIds[ESM::PRT_Count]
private
bool MWRender::NpcAnimation::mSoundsDisabled
private
ViewMode MWRender::NpcAnimation::mViewMode
private
std::shared_ptr<WeaponAnimationTime> MWRender::NpcAnimation::mWeaponAnimationTime
private
const NpcAnimation::PartBoneMap MWRender::NpcAnimation::sPartList = createPartListMap()
staticprivate

The documentation for this class was generated from the following files: