Index: OpenSceneGraph/trunk/src/osgPlugins/bvh/ReaderWriterBVH.cpp
===================================================================
--- OpenSceneGraph/trunk/src/osgPlugins/bvh/ReaderWriterBVH.cpp (revision 9371)
+++ OpenSceneGraph/trunk/src/osgPlugins/bvh/ReaderWriterBVH.cpp (revision 11009)
@@ -9,4 +9,8 @@
 #include <osgAnimation/Bone>
 #include <osgAnimation/Skeleton>
+#include <osgAnimation/UpdateBone>
+#include <osgAnimation/StackedTransform>
+#include <osgAnimation/StackedTranslateElement>
+#include <osgAnimation/StackedQuaternionElement>
 #include <osgAnimation/BasicAnimationManager>
 
@@ -40,5 +44,15 @@
             {
                 // Process OFFSET section
-                parent->setBindMatrixInBoneSpace( osg::Matrix::translate(offset) );
+                parent->setMatrixInSkeletonSpace( osg::Matrix::translate(offset) *
+                                                  parent->getMatrixInSkeletonSpace() );
+                osgAnimation::UpdateBone* updateBone =
+                    static_cast<osgAnimation::UpdateBone*>( parent->getUpdateCallback() );
+                if ( updateBone )
+                {
+                    osgAnimation::StackedTransform& stack = updateBone->getStackedTransforms();
+                    stack.push_back( new osgAnimation::StackedTranslateElement("position", offset) );
+                    stack.push_back( new osgAnimation::StackedQuaternionElement("quaternion", osg::Quat()) );
+                }
+                
                 if ( _drawingFlag && parent->getNumParents() && level>0 )
                     parent->getParent(0)->addChild( createRefGeometry(offset, 0.5).get() );
@@ -78,7 +92,8 @@
                     // Process End Site section
                     osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( parent->getName()+"End" );
-                    bone->setBindMatrixInBoneSpace( osg::Matrix::translate(offsetEndSite) );
+                    bone->setMatrixInSkeletonSpace( osg::Matrix::translate(offsetEndSite) *
+                                                    bone->getMatrixInSkeletonSpace() );
                     bone->setDataVariance( osg::Object::DYNAMIC );
-                    parent->addChild( bone.get() );
+                    parent->insertChild( 0, bone.get() );
 
                     if ( _drawingFlag )
@@ -95,7 +110,7 @@
             // Process JOINT section
             osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( fr[1].getStr() );
+            bone->setDataVariance( osg::Object::DYNAMIC );
             bone->setDefaultUpdateCallback();
-            bone->setDataVariance( osg::Object::DYNAMIC );
-            parent->addChild( bone.get() );
+            parent->insertChild( 0, bone.get() );
             _joints.push_back( JointNode(bone, 0) );
 
@@ -195,6 +210,11 @@
         fr.attach( &stream );
 
+        osg::ref_ptr<osgAnimation::Bone> boneroot = new osgAnimation::Bone( "Root" );
+        boneroot->setDefaultUpdateCallback();
+
         osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton;
         skelroot->setDefaultUpdateCallback();
+        skelroot->insertChild( 0, boneroot.get() );
+
         osg::ref_ptr<osgAnimation::Animation> anim = new osgAnimation::Animation;
 
@@ -204,5 +224,5 @@
             {
                 ++fr;
-                buildHierarchy( fr, 0, skelroot.get() );
+                buildHierarchy( fr, 0, boneroot.get() );
             }
             else if ( fr.matchSequence("MOTION") )
