Bone 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* -*-c++-*-
  2. * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
  3. *
  4. * This library is open source and may be redistributed and/or modified under
  5. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  6. * (at your option) any later version. The full license is in LICENSE file
  7. * included with this distribution, and on the openscenegraph.org website.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * OpenSceneGraph Public License for more details.
  13. *
  14. * Authors:
  15. * Cedric Pinson <cedric.pinson@plopbyte.net>
  16. * Michael Platings <mplatings@pixelpower.com>
  17. */
  18. #ifndef OSGANIMATION_BONE
  19. #define OSGANIMATION_BONE 1
  20. #include <osg/MatrixTransform>
  21. #include <osgAnimation/Export>
  22. namespace osgAnimation
  23. {
  24. // A bone can't have more than one parent Bone, so sharing a part of Bone's hierarchy
  25. // makes no sense. You can share the entire hierarchy but not only a part of it.
  26. class OSGANIMATION_EXPORT Bone : public osg::MatrixTransform
  27. {
  28. public:
  29. typedef osg::Matrix MatrixType;
  30. META_Node(osgAnimation, Bone);
  31. Bone(const Bone& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY);
  32. Bone(const std::string& name = "");
  33. void setDefaultUpdateCallback(const std::string& name = "");
  34. Bone* getBoneParent();
  35. const Bone* getBoneParent() const;
  36. const osg::Matrix& getMatrixInBoneSpace() const { return getMatrix();}
  37. const osg::Matrix& getMatrixInSkeletonSpace() const { return _boneInSkeletonSpace; }
  38. const osg::Matrix& getInvBindMatrixInSkeletonSpace() const { return _invBindInSkeletonSpace;}
  39. void setMatrixInSkeletonSpace(const osg::Matrix& matrix) { _boneInSkeletonSpace = matrix; }
  40. void setInvBindMatrixInSkeletonSpace(const osg::Matrix& matrix) { _invBindInSkeletonSpace = matrix; }
  41. protected:
  42. // bind data
  43. osg::Matrix _invBindInSkeletonSpace;
  44. // bone updated
  45. osg::Matrix _boneInSkeletonSpace;
  46. };
  47. typedef std::map<std::string, osg::ref_ptr<Bone> > BoneMap;
  48. }
  49. #endif