In the RecordCameraPathhandler fixed the handling of pressing 'Z' before 'z' which was causing the view
to be reset to 0,0,0 by AnimationPathManipualtor with an empty AnimationPath.
This commit is contained in:
@@ -407,8 +407,6 @@ RecordCameraPathHandler::RecordCameraPathHandler(const std::string& filename, fl
|
||||
_animStartTime(0),
|
||||
_lastFrameTime(osg::Timer::instance()->tick())
|
||||
{
|
||||
_animPath = new osg::AnimationPath();
|
||||
|
||||
const char* str = getenv("OSG_RECORD_CAMERA_PATH_FPS");
|
||||
if (str)
|
||||
{
|
||||
@@ -446,7 +444,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
|
||||
// If our internal _delta is finally large enough to warrant a ControlPoint
|
||||
// insertion, do so now. Be sure and reset the internal _delta, so we can start
|
||||
// calculating when the next insert should happen.
|
||||
if (_currentlyRecording && _delta >= _interval)
|
||||
if (_animPath.valid() && _currentlyRecording && _delta >= _interval)
|
||||
{
|
||||
const osg::Matrixd& m = view->getCamera()->getInverseViewMatrix();
|
||||
double animationPathTime = osg::Timer::instance()->delta_s(_animStartTime, time);
|
||||
@@ -479,7 +477,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
|
||||
{
|
||||
_currentlyRecording = true;
|
||||
_animStartTime = osg::Timer::instance()->tick();
|
||||
_animPath->clear();
|
||||
_animPath = new osg::AnimationPath();
|
||||
|
||||
if (!_filename.empty())
|
||||
{
|
||||
@@ -530,31 +528,41 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
|
||||
_currentlyRecording = false;
|
||||
_delta = 0.0f;
|
||||
|
||||
// In the future this will need to be written continuously, rather
|
||||
// than all at once.
|
||||
osgDB::ofstream out(_filename.c_str());
|
||||
OSG_NOTICE<<"Writing camera file: "<<_filename<<std::endl;
|
||||
_animPath->write(out);
|
||||
out.close();
|
||||
if (_animPath.valid() && !_animPath->empty())
|
||||
{
|
||||
// In the future this will need to be written continuously, rather
|
||||
// than all at once.
|
||||
osgDB::ofstream out(_filename.c_str());
|
||||
OSG_NOTICE<<"Writing camera file: "<<_filename<<std::endl;
|
||||
_animPath->write(out);
|
||||
out.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"No animation path to write out."<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// The user has requested to BEGIN playback.
|
||||
if (!_currentlyPlaying)
|
||||
{
|
||||
_animPathManipulator = new osgGA::AnimationPathManipulator(_animPath.get());
|
||||
_animPathManipulator->home(ea,aa);
|
||||
if (_animPath.valid() && !_animPath->empty())
|
||||
{
|
||||
_animPathManipulator = new osgGA::AnimationPathManipulator(_animPath.get());
|
||||
_animPathManipulator->home(ea,aa);
|
||||
|
||||
|
||||
// If we successfully found our _filename file, set it and keep a copy
|
||||
// around of the original CameraManipulator to restore later.
|
||||
if (_animPathManipulator.valid() && _animPathManipulator->valid())
|
||||
{
|
||||
_oldManipulator = view->getCameraManipulator();
|
||||
view->setCameraManipulator(_animPathManipulator.get());
|
||||
_currentlyPlaying = true;
|
||||
}
|
||||
// If we successfully found our _filename file, set it and keep a copy
|
||||
// around of the original CameraManipulator to restore later.
|
||||
if (_animPathManipulator.valid() && _animPathManipulator->valid())
|
||||
{
|
||||
_oldManipulator = view->getCameraManipulator();
|
||||
view->setCameraManipulator(_animPathManipulator.get());
|
||||
_currentlyPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The user has requested to STOP playback.
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user