OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
skeleton.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_NIFOSG_SKELETON_H
2 #define OPENMW_COMPONENTS_NIFOSG_SKELETON_H
3 
4 #include <osg/Group>
5 
6 #include <memory>
7 
8 namespace SceneUtil
9 {
10 
13  class Bone
14  {
15  public:
16  Bone();
17  ~Bone();
18 
19  osg::Matrixf mMatrixInSkeletonSpace;
20 
21  osg::MatrixTransform* mNode;
22 
23  std::vector<Bone*> mChildren;
24 
26  void update(const osg::Matrixf* parentMatrixInSkeletonSpace);
27 
28  private:
29  Bone(const Bone&);
30  void operator=(const Bone&);
31  };
32 
36  class Skeleton : public osg::Group
37  {
38  public:
39  Skeleton();
40  Skeleton(const Skeleton& copy, const osg::CopyOp& copyop);
41 
42  META_Node(SceneUtil, Skeleton)
43 
44 
45  Bone* getBone(const std::string& name);
46 
48  void updateBoneMatrices(unsigned int traversalNumber);
49 
51  {
55  };
56 
59  void setActive(ActiveType active);
60 
61  bool getActive() const;
62 
63  void traverse(osg::NodeVisitor& nv);
64 
65  void markDirty();
66 
67  virtual void childInserted(unsigned int);
68  virtual void childRemoved(unsigned int, unsigned int);
69 
70  private:
71  // The root bone is not a "real" bone, it has no corresponding node in the scene graph.
72  // As far as the scene graph goes we support multiple root bones.
73  std::unique_ptr<Bone> mRootBone;
74 
75  typedef std::map<std::string, std::pair<osg::NodePath, osg::MatrixTransform*> > BoneCache;
78 
80 
82 
83  unsigned int mLastFrameNumber;
84  unsigned int mLastCullFrameNumber;
85  };
86 
87 }
88 
89 #endif
virtual void childInserted(unsigned int)
Definition: skeleton.cpp:159
bool getActive() const
Definition: skeleton.cpp:132
void copy(const btTransform &src, Nif::Transformation &dst)
Definition: testbulletnifloader.cpp:269
std::map< std::string, std::pair< osg::NodePath, osg::MatrixTransform * > > BoneCache
Definition: skeleton.hpp:75
Handles the bone matrices for any number of child RigGeometries.
Definition: skeleton.hpp:36
BoneCache mBoneCache
Definition: skeleton.hpp:76
void operator=(const Bone &)
Definition: skeleton.hpp:52
unsigned int mLastCullFrameNumber
Definition: skeleton.hpp:84
bool mNeedToUpdateBoneMatrices
Definition: skeleton.hpp:79
void traverse(osg::NodeVisitor &nv)
Definition: skeleton.cpp:144
void update(const osg::Matrixf *parentMatrixInSkeletonSpace)
Update the skeleton-space matrix of this bone and all its children.
Definition: skeleton.cpp:181
bool mBoneCacheInit
Definition: skeleton.hpp:77
Bone()
Definition: skeleton.cpp:169
Like Active, but don't bother with Update (including new bounding box) if we're off-screen.
Definition: skeleton.hpp:54
std::unique_ptr< Bone > mRootBone
Definition: skeleton.hpp:73
ActiveType
Definition: skeleton.hpp:50
void markDirty()
Definition: skeleton.cpp:137
std::vector< Bone * > mChildren
Definition: skeleton.hpp:23
osg::MatrixTransform * mNode
Definition: skeleton.hpp:21
Defines a Bone hierarchy, used for updating of skeleton-space bone matrices.
Definition: skeleton.hpp:13
void setActive(ActiveType active)
Definition: skeleton.cpp:127
~Bone()
Definition: skeleton.cpp:174
osg::Matrixf mMatrixInSkeletonSpace
Definition: skeleton.hpp:19
ActiveType mActive
Definition: skeleton.hpp:81
unsigned int mLastFrameNumber
Definition: skeleton.hpp:83
Skeleton()
Definition: skeleton.cpp:35
virtual void childRemoved(unsigned int, unsigned int)
Definition: skeleton.cpp:164
Definition: skeleton.hpp:53
const char * name
Definition: crashcatcher.cpp:67