From Jeremy Moles, new event handler to record the camera path. A few small tweaks by Robert Osfield to make it more consistent with the old osgProducer::Viewer behavior.

This commit is contained in:
Robert Osfield
2007-06-01 10:39:27 +00:00
parent 9b1426e47e
commit 5a80e4bfdc
3 changed files with 128 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#ifndef OSGVIEWER_VIEWEREVENTHANDLER
#define OSGVIEWER_VIEWEREVENTHANDLER 1
#include <osg/AnimationPath>
#include <osgGA/GUIEventHandler>
#include <osgViewer/GraphicsWindow>
@@ -102,6 +103,36 @@ protected:
bool _done;
};
/**
Handler allowing the user to record the animation "path" of a camera. In it's current
implementation, this handler cannot guarantee the final view matrix is correct; it is
conceivable that the matrix may be one frame off. Eh--not a big deal! :)
TODO: Find the good filename.
TODO: Write as we go, not when it's all done.
TODO: Create osgviewer on-screen indication that animation is taking place.
TODO: Explore multi-cameras thing.
TODO: Investigate crash if non-focused camera?
*/
class AnimationPathHandler : public osgGA::GUIEventHandler
{
public:
AnimationPathHandler();
virtual void getUsage(osg::ApplicationUsage &usage) const;
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
protected:
bool _currentlyRecording;
double _interval;
double _delta;
osg::Timer_t _animStartTime;
osg::Timer_t _lastFrameTime;
osg::ref_ptr<osg::AnimationPath> _animPath;
};
}
#endif