29 #include "cameraAnimation.h"
39 LBASSERT( _steps.size() > 0 );
40 LBASSERT( _curStep < _steps.size() );
42 if( _steps.size() == 0 )
45 if( _steps.size() == 1 )
46 return _steps[ _curStep ];
48 LBASSERT( _curStep < _steps.size()-1 );
51 if( _curFrame > _steps[_curStep+1].frame )
53 if( _curStep == _steps.size()-2 )
62 const Step& curStep = _steps[ _curStep ];
63 const Step& nextStep = _steps[ _curStep+1 ];
65 if( _curFrame < curStep.frame )
66 _curFrame = curStep.frame+1;
68 const float interval = float( nextStep.frame - curStep.frame );
69 const float curCoeff = ( nextStep.frame - _curFrame ) / interval;
70 const float nextCoeff = ( _curFrame - curStep.frame ) / interval;
72 Step result( _curFrame,
73 curStep.position * curCoeff + nextStep.position * nextCoeff,
74 curStep.rotation * curCoeff + nextStep.rotation * nextCoeff );
80 bool CameraAnimation::loadAnimation(
const std::string& fileName )
84 if( fileName.empty( ))
88 file.open( fileName.c_str( ));
91 LBERROR <<
"Path file could not be opened" << std::endl;
96 file >> _modelRotation.x();
97 file >> _modelRotation.y();
98 file >> _modelRotation.z();
100 const float m =
static_cast<float>(M_PI_2) / 90.f;
106 while ( !file.eof( ))
112 frameNum += LB_MAX( static_cast<int>( v[0] ), 1 );
114 _steps.push_back( Step( frameNum,
115 eq::Vector3f( v[1] , v[2] , v[3] ),
116 eq::Vector3f( -v[5]*m, v[4]*m, v[6]*m )));