root/OpenSceneGraph/trunk/src/osgAnimation/Bone.cpp

Revision 14826, 1.9 kB (checked in by robert, 2 years ago)

Release OpenSceneGraph-3.5.1

  • Property svn:eol-style set to native
Line 
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
15#include <osgAnimation/Bone>
16#include <osgAnimation/Skeleton>
17#include <osgAnimation/UpdateBone>
18
19using namespace osgAnimation;
20
21Bone::Bone(const Bone& b, const osg::CopyOp& copyop) : osg::MatrixTransform(b,copyop), _invBindInSkeletonSpace(b._invBindInSkeletonSpace), _boneInSkeletonSpace(b._boneInSkeletonSpace)
22{
23}
24
25Bone::Bone(const std::string& name)
26{
27    if (!name.empty())
28        setName(name);
29}
30
31
32void Bone::setDefaultUpdateCallback(const std::string& name)
33{
34    std::string cbName = name;
35    if (cbName.empty())
36        cbName = getName();
37    setUpdateCallback(new UpdateBone(cbName));
38}
39
40Bone* Bone::getBoneParent()
41{
42    if (getParents().empty())
43        return 0;
44    osg::Node::ParentList parents = getParents();
45    for (osg::Node::ParentList::iterator it = parents.begin(); it != parents.end(); ++it)
46    {
47        Bone* pb = dynamic_cast<Bone*>(*it);
48        if (pb)
49            return pb;
50    }
51    return 0;
52}
53const Bone* Bone::getBoneParent() const
54{
55    if (getParents().empty())
56        return 0;
57    const osg::Node::ParentList& parents = getParents();
58    for (osg::Node::ParentList::const_iterator it = parents.begin(); it != parents.end(); ++it)
59    {
60        const Bone* pb = dynamic_cast<const Bone*>(*it);
61        if (pb)
62            return pb;
63    }
64    return 0;
65}
Note: See TracBrowser for help on using the browser.