Added preliminary support for <property_animation>

This commit is contained in:
Robert Osfield
2012-11-27 15:09:44 +00:00
parent a31d603f9a
commit 42529ca415
6 changed files with 229 additions and 90 deletions

View File

@@ -62,7 +62,7 @@ protected:
};
class PropertyAnimation : public osg::NodeCallback
class OSGPRESENTATION_EXPORT PropertyAnimation : public osg::NodeCallback
{
public:
PropertyAnimation():
@@ -93,12 +93,16 @@ public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
virtual void update();
virtual void update(osg::Node* node);
protected:
osg::ref_ptr<PropertyManager> _pm;
void assign(osg::UserDataContainer* destination, osg::UserDataContainer* source);
void assign(osg::UserDataContainer* udc, osg::Object* obj);
KeyFrameMap _keyFrameMap;
double _firstTime;

View File

@@ -22,6 +22,7 @@
#include <osgViewer/Viewer>
#include <osgPresentation/CompileSlideCallback>
#include <osgPresentation/PropertyManager>
namespace osgPresentation
{
@@ -237,69 +238,6 @@ protected:
};
class PropertyManager : protected osg::Object
{
public:
PropertyManager() {}
PropertyManager(const PropertyManager& pm, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
osg::Object(pm,copyop) {}
META_Object(osgPresentation, PropertyManager)
/** Convinience method that casts the named UserObject to osg::TemplateValueObject<T> and gets the value.
* To use this template method you need to include the osg/ValueObject header.*/
template<typename T>
bool getProperty(const std::string& name, T& value) const
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
return getUserValue(name, value);
}
/** Convinience method that creates the osg::TemplateValueObject<T> to store the
* specified value and adds it as a named UserObject.
* To use this template method you need to include the osg/ValueObject header. */
template<typename T>
void setProperty(const std::string& name, const T& value)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
return setUserValue(name, value);
}
int ref() const { return osg::Referenced::ref(); }
int unref() const { return osg::Referenced::unref(); }
protected:
mutable OpenThreads::Mutex _mutex;
};
struct OSGPRESENTATION_EXPORT ImageSequenceUpdateCallback : public osg::NodeCallback
{
ImageSequenceUpdateCallback(osg::ImageSequence* is, PropertyManager* pm, const std::string& propertyName):
_imageSequence(is),
_propertyManager(pm),
_propertyName(propertyName) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
osg::ref_ptr<osg::ImageSequence> _imageSequence;
osg::ref_ptr<PropertyManager> _propertyManager;
std::string _propertyName;
};
struct OSGPRESENTATION_EXPORT PropertyEventCallback : public osgGA::GUIEventHandler
{
PropertyEventCallback(PropertyManager* pm):
_propertyManager(pm) {}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&);
osg::ref_ptr<PropertyManager> _propertyManager;
};
class OSGPRESENTATION_EXPORT SlideEventHandler : public osgGA::GUIEventHandler
{
public:

View File

@@ -30,6 +30,7 @@
#include <osgPresentation/AnimationMaterial>
#include <osgPresentation/SlideEventHandler>
#include <osgPresentation/PropertyManager>
namespace osgPresentation
{
@@ -436,6 +437,8 @@ public:
void layerClickToDoOperation(const std::string& command, Operation operation, const JumpData& jumpData=JumpData());
void layerClickEventOperation(const KeyPosition& keyPos, const JumpData& jumpData=JumpData());
void addPropertyAnimation(PresentationContext presentationContext, PropertyAnimation* propertyAnimation);
void addToCurrentLayer(osg::Node* subgraph);
void addBullet(const std::string& bullet, PositionData& positionData, FontData& fontData);