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 
52  void setActive(bool active);
53 
54  bool getActive() const;
55 
56  void traverse(osg::NodeVisitor& nv);
57 
58  void markDirty();
59 
60  virtual void childInserted(unsigned int);
61  virtual void childRemoved(unsigned int, unsigned int);
62 
63  private:
64  // The root bone is not a "real" bone, it has no corresponding node in the scene graph.
65  // As far as the scene graph goes we support multiple root bones.
66  std::auto_ptr<Bone> mRootBone;
67 
68  typedef std::map<std::string, std::pair<osg::NodePath, osg::MatrixTransform*> > BoneCache;
71 
73 
74  bool mActive;
75 
76  unsigned int mLastFrameNumber;
79  };
80 
81 }
82 
83 #endif
void setActive(bool active)
Definition: skeleton.cpp:137
virtual void childInserted(unsigned int)
Definition: skeleton.cpp:165
bool getActive() const
Definition: skeleton.cpp:142
std::map< std::string, std::pair< osg::NodePath, osg::MatrixTransform * > > BoneCache
Definition: skeleton.hpp:68
Handles the bone matrices for any number of child RigGeometries.
Definition: skeleton.hpp:36
BoneCache mBoneCache
Definition: skeleton.hpp:69
void operator=(const Bone &)
bool mNeedToUpdateBoneMatrices
Definition: skeleton.hpp:72
void traverse(osg::NodeVisitor &nv)
Definition: skeleton.cpp:155
void update(const osg::Matrixf *parentMatrixInSkeletonSpace)
Update the skeleton-space matrix of this bone and all its children.
Definition: skeleton.cpp:187
bool mBoneCacheInit
Definition: skeleton.hpp:70
Bone()
Definition: skeleton.cpp:175
bool mTraversedEvenFrame
Definition: skeleton.hpp:77
void markDirty()
Definition: skeleton.cpp:147
std::vector< Bone * > mChildren
Definition: skeleton.hpp:23
bool mTraversedOddFrame
Definition: skeleton.hpp:78
osg::MatrixTransform * mNode
Definition: skeleton.hpp:21
Defines a Bone hierarchy, used for updating of skeleton-space bone matrices.
Definition: skeleton.hpp:13
~Bone()
Definition: skeleton.cpp:180
bool mActive
Definition: skeleton.hpp:74
osg::Matrixf mMatrixInSkeletonSpace
Definition: skeleton.hpp:19
unsigned int mLastFrameNumber
Definition: skeleton.hpp:76
Skeleton()
Definition: skeleton.cpp:36
std::auto_ptr< Bone > mRootBone
Definition: skeleton.hpp:66
virtual void childRemoved(unsigned int, unsigned int)
Definition: skeleton.cpp:170
const char * name
Definition: crashcatcher.cpp:59