From 754af22eaca38f2bb41147cc420b28a698c82618 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 9 Oct 2003 10:44:15 +0000 Subject: [PATCH] Converted the animation path file reading code to use std::ifstream rather than C style file so that it can handle configurable types better - fixing a bug associated with reading animation paths with the new osg::Quat defaulting to doubles. --- src/osgGA/AnimationPathManipulator.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/osgGA/AnimationPathManipulator.cpp b/src/osgGA/AnimationPathManipulator.cpp index 0f978a314..b519b2694 100644 --- a/src/osgGA/AnimationPathManipulator.cpp +++ b/src/osgGA/AnimationPathManipulator.cpp @@ -27,26 +27,28 @@ AnimationPathManipulator::AnimationPathManipulator( const std::string& filename _timeScale = 1.0f; _isPaused = false; - FILE *fp = fopen( filename.c_str(), "r" ); - if( fp == NULL ) + + std::ifstream in(filename.c_str()); + + if (!in) { osg::notify(osg::WARN) << "AnimationPathManipulator: Cannot open animation path file \"" << filename << "\".\n"; _valid = false; return; } - while( !feof( fp )) + + while (!in.eof()) { double time; - osg::Vec3 position; - osg::Quat rotation; - fscanf( fp, "%lf %f %f %f %f %f %f %f\n", - &time, &position[0], &position[1], &position[2], - &rotation[0], &rotation[1], &rotation[2], &rotation[3] ); - - if( !feof(fp)) - _animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation)); + osg::Vec3 position; + osg::Quat rotation; + in >> time >> position.x() >> position.y() >> position.z() >> rotation.x() >> rotation.y() >> rotation.z() >> rotation.w(); + if(!in.eof()) + _animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation)); } - fclose(fp); + + in.close(); + } void AnimationPathManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter&)