~ubuntu-branches/debian/experimental/openscenegraph/experimental

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/bvh/ReaderWriterBVH.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Luaces
  • Date: 2010-05-03 21:42:01 UTC
  • mfrom: (1.1.9 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100503214201-iy060qxb94vsfv87
Tags: 2.8.3-3
* Added README.source. Thanks Manuel Montecelo.
* Removed FindGDAL.cmake file supplied by upstream since it does not
  detect current libgdal1-1.6.0. The script provided by CMake works
  fine.
* Removed openthreads-doc since OpenThreads documentation is shared with
  OpenSceneGraph's, hence this package was empty.
* Now ccache handling is being done automatically by CMake.
* Drop conflict dependencies with previous versions to let them coexist
  with current ones (Closes: #580079 #580081).

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#include <osgAnimation/Bone>
10
10
#include <osgAnimation/Skeleton>
 
11
#include <osgAnimation/UpdateBone>
 
12
#include <osgAnimation/StackedTransform>
 
13
#include <osgAnimation/StackedTranslateElement>
 
14
#include <osgAnimation/StackedQuaternionElement>
11
15
#include <osgAnimation/BasicAnimationManager>
12
16
 
13
17
class BvhMotionBuilder : public osg::Referenced
39
43
            if ( fr.readSequence(offset) )
40
44
            {
41
45
                // Process OFFSET section
42
 
                parent->setBindMatrixInBoneSpace( osg::Matrix::translate(offset) );
 
46
                parent->setMatrixInSkeletonSpace( osg::Matrix::translate(offset) *
 
47
                                                  parent->getMatrixInSkeletonSpace() );
 
48
                osgAnimation::UpdateBone* updateBone =
 
49
                    static_cast<osgAnimation::UpdateBone*>( parent->getUpdateCallback() );
 
50
                if ( updateBone )
 
51
                {
 
52
                    osgAnimation::StackedTransform& stack = updateBone->getStackedTransforms();
 
53
                    stack.push_back( new osgAnimation::StackedTranslateElement("position", offset) );
 
54
                    stack.push_back( new osgAnimation::StackedQuaternionElement("quaternion", osg::Quat()) );
 
55
                }
 
56
                
43
57
                if ( _drawingFlag && parent->getNumParents() && level>0 )
44
58
                    parent->getParent(0)->addChild( createRefGeometry(offset, 0.5).get() );
45
59
            }
77
91
                {
78
92
                    // Process End Site section
79
93
                    osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( parent->getName()+"End" );
80
 
                    bone->setBindMatrixInBoneSpace( osg::Matrix::translate(offsetEndSite) );
 
94
                    bone->setMatrixInSkeletonSpace( osg::Matrix::translate(offsetEndSite) *
 
95
                                                    bone->getMatrixInSkeletonSpace() );
81
96
                    bone->setDataVariance( osg::Object::DYNAMIC );
82
 
                    parent->addChild( bone.get() );
 
97
                    parent->insertChild( 0, bone.get() );
83
98
 
84
99
                    if ( _drawingFlag )
85
100
                        parent->addChild( createRefGeometry(offsetEndSite, 0.5).get() );
94
109
 
95
110
            // Process JOINT section
96
111
            osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( fr[1].getStr() );
 
112
            bone->setDataVariance( osg::Object::DYNAMIC );
97
113
            bone->setDefaultUpdateCallback();
98
 
            bone->setDataVariance( osg::Object::DYNAMIC );
99
 
            parent->addChild( bone.get() );
 
114
            parent->insertChild( 0, bone.get() );
100
115
            _joints.push_back( JointNode(bone, 0) );
101
116
 
102
117
            int entry = fr[1].getNoNestedBrackets();
194
209
        osgDB::Input fr;
195
210
        fr.attach( &stream );
196
211
 
 
212
        osg::ref_ptr<osgAnimation::Bone> boneroot = new osgAnimation::Bone( "Root" );
 
213
        boneroot->setDefaultUpdateCallback();
 
214
 
197
215
        osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton;
198
216
        skelroot->setDefaultUpdateCallback();
 
217
        skelroot->insertChild( 0, boneroot.get() );
 
218
 
199
219
        osg::ref_ptr<osgAnimation::Animation> anim = new osgAnimation::Animation;
200
220
 
201
221
        while( !fr.eof() )
203
223
            if ( fr.matchSequence("HIERARCHY") )
204
224
            {
205
225
                ++fr;
206
 
                buildHierarchy( fr, 0, skelroot.get() );
 
226
                buildHierarchy( fr, 0, boneroot.get() );
207
227
            }
208
228
            else if ( fr.matchSequence("MOTION") )
209
229
            {