You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
10 years ago
|
#ifndef OPENMW_COMPONENTS_NIFOSG_SKELETON_H
|
||
|
#define OPENMW_COMPONENTS_NIFOSG_SKELETON_H
|
||
|
|
||
|
#include <osg/Group>
|
||
|
|
||
|
#include <memory>
|
||
|
|
||
10 years ago
|
namespace SceneUtil
|
||
10 years ago
|
{
|
||
|
|
||
|
// Defines a Bone hierarchy, used for updating of skeleton-space bone matrices.
|
||
|
// To prevent unnecessary updates, only bones that are used for skinning will be added to this hierarchy.
|
||
|
class Bone
|
||
|
{
|
||
|
public:
|
||
|
Bone();
|
||
|
~Bone();
|
||
|
|
||
|
osg::Matrix mMatrixInSkeletonSpace;
|
||
|
|
||
|
osg::MatrixTransform* mNode;
|
||
|
|
||
|
std::vector<Bone*> mChildren;
|
||
|
|
||
|
void update(const osg::Matrixf* parentMatrixInSkeletonSpace);
|
||
|
|
||
|
private:
|
||
|
Bone(const Bone&);
|
||
|
void operator=(const Bone&);
|
||
|
};
|
||
|
|
||
|
class Skeleton : public osg::Group
|
||
|
{
|
||
|
public:
|
||
|
Skeleton();
|
||
|
Skeleton(const Skeleton& copy, const osg::CopyOp& copyop);
|
||
|
|
||
|
Bone* getBone(const std::string& name);
|
||
|
|
||
|
META_Node(NifOsg, Skeleton)
|
||
|
|
||
10 years ago
|
void updateBoneMatrices(osg::NodeVisitor* nv);
|
||
10 years ago
|
|
||
|
private:
|
||
|
// The root bone is not a "real" bone, it has no corresponding node in the scene graph.
|
||
|
// As far as the scene graph goes we support multiple root bones.
|
||
|
std::auto_ptr<Bone> mRootBone;
|
||
|
|
||
|
typedef std::map<std::string, std::pair<osg::NodePath, osg::MatrixTransform*> > BoneCache;
|
||
|
BoneCache mBoneCache;
|
||
|
bool mBoneCacheInit;
|
||
|
|
||
|
bool mNeedToUpdateBoneMatrices;
|
||
10 years ago
|
|
||
|
unsigned int mLastFrameNumber;
|
||
10 years ago
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|