diff --git a/examples/osganimationmorph/osganimationmorph.cpp b/examples/osganimationmorph/osganimationmorph.cpp index 81a437f38..be8649f04 100644 --- a/examples/osganimationmorph/osganimationmorph.cpp +++ b/examples/osganimationmorph/osganimationmorph.cpp @@ -72,7 +72,7 @@ int main (int argc, char* argv[]) animation->addChannel(channel0); animation->setName("Morph"); animation->computeDuration(); - animation->setPlaymode(osgAnimation::Animation::PPONG); + animation->setPlayMode(osgAnimation::Animation::PPONG); osgAnimation::BasicAnimationManager* bam = new osgAnimation::BasicAnimationManager; bam->registerAnimation(animation); diff --git a/examples/osganimationsolid/osganimationsolid.cpp b/examples/osganimationsolid/osganimationsolid.cpp index 6ce649b78..255767522 100644 --- a/examples/osganimationsolid/osganimationsolid.cpp +++ b/examples/osganimationsolid/osganimationsolid.cpp @@ -99,7 +99,7 @@ int main (int argc, char* argv[]) channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(2, osg::Vec3(1,1,0))); osgAnimation::Animation* anim1 = new osgAnimation::Animation; anim1->addChannel(channelAnimation1); - anim1->setPlaymode(osgAnimation::Animation::PPONG); + anim1->setPlayMode(osgAnimation::Animation::PPONG); osgAnimation::Vec3LinearChannel* channelAnimation2 = new osgAnimation::Vec3LinearChannel; @@ -109,7 +109,7 @@ int main (int argc, char* argv[]) channelAnimation2->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(1.5, osg::Vec3(2*osg::PI,0,0))); osgAnimation::Animation* anim2 = new osgAnimation::Animation; anim2->addChannel(channelAnimation2); - anim2->setPlaymode(osgAnimation::Animation::LOOP); + anim2->setPlayMode(osgAnimation::Animation::LOOP); // We register all animation inside the scheduler diff --git a/include/osgAnimation/Action b/include/osgAnimation/Action index b61e45c39..9cdaacbc6 100644 --- a/include/osgAnimation/Action +++ b/include/osgAnimation/Action @@ -113,7 +113,7 @@ namespace osgAnimation double getDuration() const { return _numberFrame * 1.0 / _fps; } // 0 means infini else it's the number of loop - virtual void setLoop(int nb) { _loop = nb; } + virtual void setLoop(unsigned int nb) { _loop = nb; } virtual unsigned int getLoop() const { return _loop;} // get the number of loop, the frame relative to loop. diff --git a/include/osgAnimation/Animation b/include/osgAnimation/Animation index c5311340a..655245e00 100644 --- a/include/osgAnimation/Animation +++ b/include/osgAnimation/Animation @@ -74,7 +74,7 @@ namespace osgAnimation bool update (double time, int priority = 0); void resetTargets(); - void setPlaymode (PlayMode mode) { _playmode = mode; } + void setPlayMode (PlayMode mode) { _playmode = mode; } PlayMode getPlayMode() const { return _playmode; } void setStartTime(double time) { _startTime = time;} diff --git a/include/osgAnimation/AnimationManagerBase b/include/osgAnimation/AnimationManagerBase index b501b626d..e043fecce 100644 --- a/include/osgAnimation/AnimationManagerBase +++ b/include/osgAnimation/AnimationManagerBase @@ -54,7 +54,8 @@ namespace osgAnimation /// set a flag to define the behaviour void setAutomaticLink(bool); - bool isAutomaticLink() const; + bool getAutomaticLink() const; + bool isAutomaticLink() const { return getAutomaticLink(); } void dirty(); protected: diff --git a/include/osgAnimation/StackedRotateAxisElement b/include/osgAnimation/StackedRotateAxisElement index d5a160869..7b5d47912 100644 --- a/include/osgAnimation/StackedRotateAxisElement +++ b/include/osgAnimation/StackedRotateAxisElement @@ -39,9 +39,9 @@ namespace osgAnimation void update(); const osg::Vec3& getAxis() const; - const double getAngle() const; + double getAngle() const; void setAxis(const osg::Vec3&); - void setAngle(const double&); + void setAngle(double); virtual Target* getOrCreateTarget(); virtual Target* getTarget() {return _target.get();} diff --git a/include/osgDB/ObjectWrapper b/include/osgDB/ObjectWrapper index d93536395..c78c95163 100644 --- a/include/osgDB/ObjectWrapper +++ b/include/osgDB/ObjectWrapper @@ -139,6 +139,13 @@ protected: typedef CLASS MyClass; \ void wrapper_propfunc_##NAME(osgDB::ObjectWrapper* wrapper) +#define REGISTER_OBJECT_WRAPPER2(NAME, PROTO, CLASS, CLASSNAME, ASSOCIATES) \ + extern void wrapper_propfunc_##NAME(osgDB::ObjectWrapper*); \ + static osgDB::RegisterWrapperProxy wrapper_proxy_##NAME( \ + PROTO, CLASSNAME, ASSOCIATES, &wrapper_propfunc_##NAME); \ + typedef CLASS MyClass; \ + void wrapper_propfunc_##NAME(osgDB::ObjectWrapper* wrapper) + class OSGDB_EXPORT RegisterCompressorProxy { public: diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index 089f3fa19..1fd20987a 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -499,7 +499,8 @@ public: { is >> BEGIN_BRACKET; P* value = dynamic_cast( is.readObject() ); - (object.*_setter)( value ); + if ( ParentType::_defaultValue!=value ) + (object.*_setter)( value ); is >> END_BRACKET; } } @@ -567,7 +568,8 @@ public: { is >> BEGIN_BRACKET; P* value = dynamic_cast( is.readImage() ); - (object.*_setter)( value ); + if ( ParentType::_defaultValue!=value ) + (object.*_setter)( value ); is >> END_BRACKET; } } diff --git a/src/osgAnimation/AnimationManagerBase.cpp b/src/osgAnimation/AnimationManagerBase.cpp index 166165380..f2ab20ba1 100644 --- a/src/osgAnimation/AnimationManagerBase.cpp +++ b/src/osgAnimation/AnimationManagerBase.cpp @@ -38,7 +38,7 @@ void AnimationManagerBase::dirty() } void AnimationManagerBase::setAutomaticLink(bool state) { _automaticLink = state; } -bool AnimationManagerBase::isAutomaticLink() const { return _automaticLink; } +bool AnimationManagerBase::getAutomaticLink() const { return _automaticLink; } void AnimationManagerBase::operator()(osg::Node* node, osg::NodeVisitor* nv) { @@ -108,7 +108,7 @@ void AnimationManagerBase::unregisterAnimation (Animation* animation) buildTargetReference(); } -bool AnimationManagerBase::needToLink() const { return _needToLink && isAutomaticLink(); } +bool AnimationManagerBase::needToLink() const { return _needToLink && getAutomaticLink(); } void AnimationManagerBase::setLinkVisitor(LinkVisitor* visitor) diff --git a/src/osgAnimation/StackedRotateAxisElement.cpp b/src/osgAnimation/StackedRotateAxisElement.cpp index a6188601a..2424da372 100644 --- a/src/osgAnimation/StackedRotateAxisElement.cpp +++ b/src/osgAnimation/StackedRotateAxisElement.cpp @@ -34,13 +34,13 @@ void StackedRotateAxisElement::update() } const osg::Vec3& StackedRotateAxisElement::getAxis() const { return _axis; } -const double StackedRotateAxisElement::getAngle() const { return _angle; } +double StackedRotateAxisElement::getAngle() const { return _angle; } void StackedRotateAxisElement::setAxis(const osg::Vec3& axis) { _axis = axis; } -void StackedRotateAxisElement::setAngle(const double& angle) +void StackedRotateAxisElement::setAngle(double angle) { _angle = angle; } diff --git a/src/osgPlugins/osg/XmlStreamOperator.h b/src/osgPlugins/osg/XmlStreamOperator.h index c2e69754b..51906f1e5 100644 --- a/src/osgPlugins/osg/XmlStreamOperator.h +++ b/src/osgPlugins/osg/XmlStreamOperator.h @@ -35,10 +35,10 @@ public: { addToCurrentNode( b ? std::string("TRUE") : std::string("FALSE") ); } virtual void writeChar( char c ) - { _sstream << c; addToCurrentNode( _sstream.str() ); _sstream.str(""); } + { _sstream << (short)c; addToCurrentNode( _sstream.str() ); _sstream.str(""); } virtual void writeUChar( unsigned char c ) - { _sstream << c; addToCurrentNode( _sstream.str() ); _sstream.str(""); } + { _sstream << (unsigned short)c; addToCurrentNode( _sstream.str() ); _sstream.str(""); } virtual void writeShort( short s ) { _sstream << s; addToCurrentNode( _sstream.str() ); _sstream.str(""); } @@ -326,13 +326,25 @@ public: } virtual void readChar( char& c ) - { if ( prepareStream() ) _sstream >> c; } + { + short s = 0; + if ( prepareStream() ) _sstream >> s; + c = (char)s; + } virtual void readSChar( signed char& c ) - { if ( prepareStream() ) _sstream >> c; } + { + short s = 0; + if ( prepareStream() ) _sstream >> s; + c = (signed char)s; + } virtual void readUChar( unsigned char& c ) - { if ( prepareStream() ) _sstream >> c; } + { + unsigned short s = 0; + if ( prepareStream() ) _sstream >> s; + c = (unsigned char)s; + } virtual void readShort( short& s ) { if ( prepareStream() ) _sstream >> s; } diff --git a/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp b/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp index 5a91eb2f6..183d9c3e9 100644 --- a/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp +++ b/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp @@ -187,10 +187,10 @@ bool Animation_readLocalData(Object& obj, Input& fr) if (fr.matchSequence("playmode %w")) { - if (fr[1].matchWord("ONCE")) anim.setPlaymode(osgAnimation::Animation::ONCE); - else if (fr[1].matchWord("STAY")) anim.setPlaymode(osgAnimation::Animation::STAY); - else if (fr[1].matchWord("LOOP")) anim.setPlaymode(osgAnimation::Animation::LOOP); - else if (fr[1].matchWord("PPONG")) anim.setPlaymode(osgAnimation::Animation::PPONG); + if (fr[1].matchWord("ONCE")) anim.setPlayMode(osgAnimation::Animation::ONCE); + else if (fr[1].matchWord("STAY")) anim.setPlayMode(osgAnimation::Animation::STAY); + else if (fr[1].matchWord("LOOP")) anim.setPlayMode(osgAnimation::Animation::LOOP); + else if (fr[1].matchWord("PPONG")) anim.setPlayMode(osgAnimation::Animation::PPONG); fr += 2; iteratorAdvanced = true; } diff --git a/src/osgWrappers/introspection/osgAnimation/Action.cpp b/src/osgWrappers/introspection/osgAnimation/Action.cpp index 7f100ee44..b391e9431 100644 --- a/src/osgWrappers/introspection/osgAnimation/Action.cpp +++ b/src/osgWrappers/introspection/osgAnimation/Action.cpp @@ -120,9 +120,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::Action) __double__getDuration, "", ""); - I_Method1(void, setLoop, IN, int, nb, + I_Method1(void, setLoop, IN, unsigned int, nb, Properties::VIRTUAL, - __void__setLoop__int, + __void__setLoop__unsigned_int, "", ""); I_Method0(unsigned int, getLoop, @@ -150,9 +150,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::Action) I_SimpleProperty(unsigned int, FramesPerSecond, __unsigned_int__getFramesPerSecond, 0); - I_SimpleProperty(int, Loop, - 0, - __void__setLoop__int); + I_SimpleProperty(unsigned int, Loop, + __unsigned_int__getLoop, + __void__setLoop__unsigned_int); I_SimpleProperty(unsigned int, NumFrames, 0, __void__setNumFrames__unsigned_int); diff --git a/src/osgWrappers/introspection/osgAnimation/ActionStripAnimation.cpp b/src/osgWrappers/introspection/osgAnimation/ActionStripAnimation.cpp index de0f828ce..57cf805d5 100644 --- a/src/osgWrappers/introspection/osgAnimation/ActionStripAnimation.cpp +++ b/src/osgWrappers/introspection/osgAnimation/ActionStripAnimation.cpp @@ -112,7 +112,7 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::ActionStripAnimation) "", ""); I_Method1(void, setLoop, IN, unsigned int, loop, - Properties::NON_VIRTUAL, + Properties::VIRTUAL, __void__setLoop__unsigned_int, "", ""); diff --git a/src/osgWrappers/introspection/osgAnimation/Animation.cpp b/src/osgWrappers/introspection/osgAnimation/Animation.cpp index 814289d4b..f95876d53 100644 --- a/src/osgWrappers/introspection/osgAnimation/Animation.cpp +++ b/src/osgWrappers/introspection/osgAnimation/Animation.cpp @@ -116,9 +116,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::Animation) __void__resetTargets, "", ""); - I_Method1(void, setPlaymode, IN, osgAnimation::Animation::PlayMode, mode, + I_Method1(void, setPlayMode, IN, osgAnimation::Animation::PlayMode, mode, Properties::NON_VIRTUAL, - __void__setPlaymode__PlayMode, + __void__setPlayMode__PlayMode, "", ""); I_Method0(osgAnimation::Animation::PlayMode, getPlayMode, @@ -150,10 +150,7 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::Animation) __void__setDuration__double); I_SimpleProperty(osgAnimation::Animation::PlayMode, PlayMode, __PlayMode__getPlayMode, - 0); - I_SimpleProperty(osgAnimation::Animation::PlayMode, Playmode, - 0, - __void__setPlaymode__PlayMode); + __void__setPlayMode__PlayMode); I_SimpleProperty(double, StartTime, __double__getStartTime, __void__setStartTime__double); diff --git a/src/osgWrappers/introspection/osgAnimation/AnimationManagerBase.cpp b/src/osgWrappers/introspection/osgAnimation/AnimationManagerBase.cpp index ba5725faf..9756f98d5 100644 --- a/src/osgWrappers/introspection/osgAnimation/AnimationManagerBase.cpp +++ b/src/osgWrappers/introspection/osgAnimation/AnimationManagerBase.cpp @@ -93,6 +93,11 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgAnimation::AnimationManagerBase) __void__setAutomaticLink__bool, "set a flag to define the behaviour ", ""); + I_Method0(bool, getAutomaticLink, + Properties::NON_VIRTUAL, + __bool__getAutomaticLink, + "", + ""); I_Method0(bool, isAutomaticLink, Properties::NON_VIRTUAL, __bool__isAutomaticLink, @@ -107,7 +112,7 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgAnimation::AnimationManagerBase) __C5_AnimationList_R1__getAnimationList, 0); I_SimpleProperty(bool, AutomaticLink, - 0, + __bool__getAutomaticLink, __void__setAutomaticLink__bool); I_SimpleProperty(osgAnimation::LinkVisitor *, LinkVisitor, 0, diff --git a/src/osgWrappers/introspection/osgAnimation/StackedRotateAxisElement.cpp b/src/osgWrappers/introspection/osgAnimation/StackedRotateAxisElement.cpp index 60e1bee27..e2bc0c456 100644 --- a/src/osgWrappers/introspection/osgAnimation/StackedRotateAxisElement.cpp +++ b/src/osgWrappers/introspection/osgAnimation/StackedRotateAxisElement.cpp @@ -93,9 +93,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::StackedRotateAxisElement) __C5_osg_Vec3_R1__getAxis, "", ""); - I_Method0(const double, getAngle, + I_Method0(double, getAngle, Properties::NON_VIRTUAL, - __C5_double__getAngle, + __double__getAngle, "", ""); I_Method1(void, setAxis, IN, const osg::Vec3 &, x, @@ -103,9 +103,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::StackedRotateAxisElement) __void__setAxis__C5_osg_Vec3_R1, "", ""); - I_Method1(void, setAngle, IN, const double &, x, + I_Method1(void, setAngle, IN, double, x, Properties::NON_VIRTUAL, - __void__setAngle__C5_double_R1, + __void__setAngle__double, "", ""); I_Method0(osgAnimation::Target *, getOrCreateTarget, @@ -123,9 +123,9 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::StackedRotateAxisElement) __C5_Target_P1__getTarget, "", ""); - I_SimpleProperty(const double &, Angle, - 0, - __void__setAngle__C5_double_R1); + I_SimpleProperty(double, Angle, + __double__getAngle, + __void__setAngle__double); I_SimpleProperty(osg::Matrix, AsMatrix, __osg_Matrix__getAsMatrix, 0); diff --git a/src/osgWrappers/serializers/CMakeLists.txt b/src/osgWrappers/serializers/CMakeLists.txt index 56ebfbcbb..b7004a79e 100644 --- a/src/osgWrappers/serializers/CMakeLists.txt +++ b/src/osgWrappers/serializers/CMakeLists.txt @@ -23,6 +23,11 @@ IF(MSVC80 OR MSVC90) ENDIF() ENDIF() +IF(MSVC) + # Avoid C4121 warnings + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zp16") +ENDIF() + SET(TARGET_DEFAULT_PREFIX "osgdb_serializers_") SET(TARGET_DEFAULT_LABEL_PREFIX "Plugins osg serializer") SET(TARGET_COMMON_LIBRARIES @@ -33,6 +38,7 @@ SET(TARGET_COMMON_LIBRARIES ) ADD_SUBDIRECTORY(osg) +ADD_SUBDIRECTORY(osgAnimation) ADD_SUBDIRECTORY(osgParticle) ADD_SUBDIRECTORY(osgTerrain) ADD_SUBDIRECTORY(osgText) diff --git a/src/osgWrappers/serializers/osg/Geometry.cpp b/src/osgWrappers/serializers/osg/Geometry.cpp index eec79942d..6b5cd2049 100644 --- a/src/osgWrappers/serializers/osg/Geometry.cpp +++ b/src/osgWrappers/serializers/osg/Geometry.cpp @@ -111,5 +111,5 @@ REGISTER_OBJECT_WRAPPER( Geometry, ADD_USER_SERIALIZER( TexCoordData ); // _texCoordList ADD_USER_SERIALIZER( VertexAttribData ); // _vertexAttribList ADD_BOOL_SERIALIZER( FastPathHint, true ); // _fastPathHint - ADD_OBJECT_SERIALIZER( InternalOptimizedGeometry, osg::Geometry, NULL ); // _internalOptimizedGeometry + //ADD_OBJECT_SERIALIZER( InternalOptimizedGeometry, osg::Geometry, NULL ); // _internalOptimizedGeometry } diff --git a/src/osgWrappers/serializers/osgAnimation/Action.cpp b/src/osgWrappers/serializers/osgAnimation/Action.cpp new file mode 100644 index 000000000..5f55e874d --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/Action.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_Action, + new osgAnimation::Action, + osgAnimation::Action, + "osg::Object osgAnimation::Action" ) +{ + //ADD_USER_SERIALIZER( Callback ); // _framesCallback + ADD_UINT_SERIALIZER( NumFrames, 25 ); // _numberFrame + ADD_UINT_SERIALIZER( Loop, 1 ); // _loop +} diff --git a/src/osgWrappers/serializers/osgAnimation/ActionAnimation.cpp b/src/osgWrappers/serializers/osgAnimation/ActionAnimation.cpp new file mode 100644 index 000000000..b34529754 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/ActionAnimation.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_ActionAnimation, + new osgAnimation::ActionAnimation, + osgAnimation::ActionAnimation, + "osg::Object osgAnimation::Action osgAnimation::ActionAnimation" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/ActionBlendIn.cpp b/src/osgWrappers/serializers/osgAnimation/ActionBlendIn.cpp new file mode 100644 index 000000000..89638c877 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/ActionBlendIn.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_ActionBlendIn, + new osgAnimation::ActionBlendIn, + osgAnimation::ActionBlendIn, + "osg::Object osgAnimation::Action osgAnimation::ActionBlendIn" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/ActionBlendOut.cpp b/src/osgWrappers/serializers/osgAnimation/ActionBlendOut.cpp new file mode 100644 index 000000000..aef3ff344 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/ActionBlendOut.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_ActionBlendOut, + new osgAnimation::ActionBlendOut, + osgAnimation::ActionBlendOut, + "osg::Object osgAnimation::Action osgAnimation::ActionBlendOut" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/ActionStripAnimation.cpp b/src/osgWrappers/serializers/osgAnimation/ActionStripAnimation.cpp new file mode 100644 index 000000000..d0a963e96 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/ActionStripAnimation.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_ActionStripAnimation, + new osgAnimation::ActionStripAnimation, + osgAnimation::ActionStripAnimation, + "osg::Object osgAnimation::Action osgAnimation::ActionStripAnimation" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/Animation.cpp b/src/osgWrappers/serializers/osgAnimation/Animation.cpp new file mode 100644 index 000000000..30e599324 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/Animation.cpp @@ -0,0 +1,252 @@ +#include +#include +#include +#include + +// reading channel helpers + +static void readChannel( osgDB::InputStream& is, osgAnimation::Channel* ch ) +{ + std::string name, targetName; + is >> osgDB::PROPERTY("Name") >> name; + is >> osgDB::PROPERTY("TargetName") >> targetName; + ch->setName( name ); + ch->setTargetName( targetName ); +} +#include +template +static void readContainer( osgDB::InputStream& is, ContainerType* container ) +{ + typedef typename ContainerType::KeyType KeyType; + bool hasContainer = false; + is >> osgDB::PROPERTY("KeyFrameContainer") >> hasContainer; + if ( hasContainer ) + { + unsigned int size = 0; + is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> time >> value; + container->push_back( KeyType(time, value) ); + } + is >> osgDB::END_BRACKET; + } +} + +template +static void readContainer2( osgDB::InputStream& is, ContainerType* container ) +{ + typedef typename ContainerType::KeyType KeyType; + bool hasContainer = false; + is >> osgDB::PROPERTY("KeyFrameContainer") >> hasContainer; + if ( hasContainer ) + { + unsigned int size = 0; + is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> time >> pos >> ptIn >> ptOut; + container->push_back( KeyType(time, ValueType(pos, ptIn, ptOut)) ); + } + is >> osgDB::END_BRACKET; + } +} + +#define READ_CHANNEL_FUNC( NAME, CHANNEL, CONTAINER, VALUE ) \ + if ( type==#NAME ) { \ + CHANNEL* ch = new CHANNEL; \ + readChannel( is, ch ); \ + readContainer( is, ch->getOrCreateSampler()->getOrCreateKeyframeContainer() ); \ + is >> osgDB::END_BRACKET; \ + if ( ch ) ani.addChannel( ch ); \ + continue; \ + } + +#define READ_CHANNEL_FUNC2( NAME, CHANNEL, CONTAINER, VALUE, INVALUE ) \ + if ( type==#NAME ) { \ + CHANNEL* ch = new CHANNEL; \ + readChannel( is, ch ); \ + readContainer2( is, ch->getOrCreateSampler()->getOrCreateKeyframeContainer() ); \ + is >> osgDB::END_BRACKET; \ + if ( ch ) ani.addChannel( ch ); \ + continue; \ + } + +// writing channel helpers + +static void writeChannel( osgDB::OutputStream& os, osgAnimation::Channel* ch ) +{ + os << osgDB::PROPERTY("Name") << ch->getName() << std::endl; + os << osgDB::PROPERTY("TargetName") << ch->getTargetName() << std::endl; +} + +template +static void writeContainer( osgDB::OutputStream& os, ContainerType* container ) +{ + os << osgDB::PROPERTY("KeyFrameContainer") << (container!=NULL); + if ( container!=NULL ) + { + os << container->size() << osgDB::BEGIN_BRACKET << std::endl; + for ( unsigned int i=0; isize(); ++i ) + { + os << (*container)[i].getTime() << (*container)[i].getValue() << std::endl; + } + os << osgDB::END_BRACKET; + } + os << std::endl; +} + +template +static void writeContainer2( osgDB::OutputStream& os, ContainerType* container ) +{ + typedef typename ContainerType::KeyType KeyType; + os << osgDB::PROPERTY("KeyFrameContainer") << (container!=NULL); + if ( container!=NULL ) + { + os << container->size() << osgDB::BEGIN_BRACKET << std::endl; + for ( unsigned int i=0; isize(); ++i ) + { + const KeyType& keyframe = (*container)[i]; + os << keyframe.getTime() << keyframe.getValue().getPosition() + << keyframe.getValue().getControlPointIn() + << keyframe.getValue().getControlPointOut() << std::endl; + } + os << osgDB::END_BRACKET; + } + os << std::endl; +} + +#define WRITE_CHANNEL_FUNC( NAME, CHANNEL, CONTAINER ) \ + CHANNEL* ch_##NAME = dynamic_cast(ch); \ + if ( ch_##NAME ) { \ + os << osgDB::PROPERTY("Type") << std::string(#NAME) << osgDB::BEGIN_BRACKET << std::endl; \ + writeChannel( os, ch_##NAME ); \ + writeContainer( os, ch_##NAME ->getSamplerTyped()->getKeyframeContainerTyped() ); \ + os << osgDB::END_BRACKET << std::endl; \ + continue; \ + } + +#define WRITE_CHANNEL_FUNC2( NAME, CHANNEL, CONTAINER ) \ + CHANNEL* ch_##NAME = dynamic_cast(ch); \ + if ( ch_##NAME ) { \ + os << osgDB::PROPERTY("Type") << #NAME << osgDB::BEGIN_BRACKET << std::endl; \ + writeChannel( os, ch_##NAME ); \ + writeContainer2( os, ch_##NAME ->getSamplerTyped()->getKeyframeContainerTyped() ); \ + os << osgDB::END_BRACKET << std::endl; \ + continue; \ + } + +// _channels + +static bool checkChannels( const osgAnimation::Animation& ani ) +{ + return ani.getChannels().size()>0; +} + +static bool readChannels( osgDB::InputStream& is, osgAnimation::Animation& ani ) +{ + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> osgDB::PROPERTY("Type") >> type >> osgDB::BEGIN_BRACKET; + + READ_CHANNEL_FUNC( DoubleStepChannel, osgAnimation::DoubleStepChannel, osgAnimation::DoubleKeyframeContainer, double ); + READ_CHANNEL_FUNC( FloatStepChannel, osgAnimation::FloatStepChannel, osgAnimation::FloatKeyframeContainer, float ); + READ_CHANNEL_FUNC( Vec2StepChannel, osgAnimation::Vec2StepChannel, osgAnimation::Vec2KeyframeContainer, osg::Vec2 ); + READ_CHANNEL_FUNC( Vec3StepChannel, osgAnimation::Vec3StepChannel, osgAnimation::Vec3KeyframeContainer, osg::Vec3 ); + READ_CHANNEL_FUNC( Vec4StepChannel, osgAnimation::Vec4StepChannel, osgAnimation::Vec4KeyframeContainer, osg::Vec4 ); + READ_CHANNEL_FUNC( QuatStepChannel, osgAnimation::QuatStepChannel, osgAnimation::QuatKeyframeContainer, osg::Quat ); + READ_CHANNEL_FUNC( DoubleLinearChannel, osgAnimation::DoubleLinearChannel, osgAnimation::DoubleKeyframeContainer, double ); + READ_CHANNEL_FUNC( FloatLinearChannel, osgAnimation::FloatLinearChannel, osgAnimation::FloatKeyframeContainer, float ); + READ_CHANNEL_FUNC( Vec2LinearChannel, osgAnimation::Vec2LinearChannel, osgAnimation::Vec2KeyframeContainer, osg::Vec2 ); + READ_CHANNEL_FUNC( Vec3LinearChannel, osgAnimation::Vec3LinearChannel, osgAnimation::Vec3KeyframeContainer, osg::Vec3 ); + READ_CHANNEL_FUNC( Vec4LinearChannel, osgAnimation::Vec4LinearChannel, osgAnimation::Vec4KeyframeContainer, osg::Vec4 ); + READ_CHANNEL_FUNC( QuatSphericalLinearChannel, osgAnimation::QuatSphericalLinearChannel, + osgAnimation::QuatKeyframeContainer, osg::Quat ); + READ_CHANNEL_FUNC( MatrixLinearChannel, osgAnimation::MatrixLinearChannel, + osgAnimation::MatrixKeyframeContainer, osg::Matrix ); + READ_CHANNEL_FUNC2( FloatCubicBezierChannel, osgAnimation::FloatCubicBezierChannel, + osgAnimation::FloatCubicBezierKeyframeContainer, + osgAnimation::FloatCubicBezier, float ); + READ_CHANNEL_FUNC2( DoubleCubicBezierChannel, osgAnimation::DoubleCubicBezierChannel, + osgAnimation::DoubleCubicBezierKeyframeContainer, + osgAnimation::DoubleCubicBezier, double ); + READ_CHANNEL_FUNC2( Vec2CubicBezierChannel, osgAnimation::Vec2CubicBezierChannel, + osgAnimation::Vec2CubicBezierKeyframeContainer, + osgAnimation::Vec2CubicBezier, osg::Vec2 ); + READ_CHANNEL_FUNC2( Vec3CubicBezierChannel, osgAnimation::Vec3CubicBezierChannel, + osgAnimation::Vec3CubicBezierKeyframeContainer, + osgAnimation::Vec3CubicBezier, osg::Vec3 ); + READ_CHANNEL_FUNC2( Vec4CubicBezierChannel, osgAnimation::Vec4CubicBezierChannel, + osgAnimation::Vec4CubicBezierKeyframeContainer, + osgAnimation::Vec4CubicBezier, osg::Vec4 ); + is.advanceToCurrentEndBracket(); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeChannels( osgDB::OutputStream& os, const osgAnimation::Animation& ani ) +{ + const osgAnimation::ChannelList& channels = ani.getChannels(); + os << channels.size() << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::ChannelList::const_iterator itr=channels.begin(); + itr!=channels.end(); ++itr ) + { + osgAnimation::Channel* ch = itr->get(); + WRITE_CHANNEL_FUNC( DoubleStepChannel, osgAnimation::DoubleStepChannel, osgAnimation::DoubleKeyframeContainer ); + WRITE_CHANNEL_FUNC( FloatStepChannel, osgAnimation::FloatStepChannel, osgAnimation::FloatKeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec2StepChannel, osgAnimation::Vec2StepChannel, osgAnimation::Vec2KeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec3StepChannel, osgAnimation::Vec3StepChannel, osgAnimation::Vec3KeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec4StepChannel, osgAnimation::Vec4StepChannel, osgAnimation::Vec4KeyframeContainer ); + WRITE_CHANNEL_FUNC( QuatStepChannel, osgAnimation::QuatStepChannel, osgAnimation::QuatKeyframeContainer ); + WRITE_CHANNEL_FUNC( DoubleLinearChannel, osgAnimation::DoubleLinearChannel, osgAnimation::DoubleKeyframeContainer ); + WRITE_CHANNEL_FUNC( FloatLinearChannel, osgAnimation::FloatLinearChannel, osgAnimation::FloatKeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec2LinearChannel, osgAnimation::Vec2LinearChannel, osgAnimation::Vec2KeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec3LinearChannel, osgAnimation::Vec3LinearChannel, osgAnimation::Vec3KeyframeContainer ); + WRITE_CHANNEL_FUNC( Vec4LinearChannel, osgAnimation::Vec4LinearChannel, osgAnimation::Vec4KeyframeContainer ); + WRITE_CHANNEL_FUNC( QuatSphericalLinearChannel, osgAnimation::QuatSphericalLinearChannel, + osgAnimation::QuatKeyframeContainer ); + WRITE_CHANNEL_FUNC( MatrixLinearChannel, osgAnimation::MatrixLinearChannel, + osgAnimation::MatrixKeyframeContainer ); + WRITE_CHANNEL_FUNC2( FloatCubicBezierChannel, osgAnimation::FloatCubicBezierChannel, + osgAnimation::FloatCubicBezierKeyframeContainer ); + WRITE_CHANNEL_FUNC2( DoubleCubicBezierChannel, osgAnimation::DoubleCubicBezierChannel, + osgAnimation::DoubleCubicBezierKeyframeContainer ); + WRITE_CHANNEL_FUNC2( Vec2CubicBezierChannel, osgAnimation::Vec2CubicBezierChannel, + osgAnimation::Vec2CubicBezierKeyframeContainer ); + WRITE_CHANNEL_FUNC2( Vec3CubicBezierChannel, osgAnimation::Vec3CubicBezierChannel, + osgAnimation::Vec3CubicBezierKeyframeContainer ); + WRITE_CHANNEL_FUNC2( Vec4CubicBezierChannel, osgAnimation::Vec4CubicBezierChannel, + osgAnimation::Vec4CubicBezierKeyframeContainer ); + + os << osgDB::PROPERTY("Type") << std::string("UnknownChannel") << osgDB::BEGIN_BRACKET << std::endl; + os << osgDB::END_BRACKET << std::endl; + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgAnimation_Animation, + new osgAnimation::Animation, + osgAnimation::Animation, + "osg::Object osgAnimation::Animation" ) +{ + ADD_DOUBLE_SERIALIZER( Duration, 0.0f ); // _duration + ADD_FLOAT_SERIALIZER( Weight, 0.0f ); // _weight + ADD_DOUBLE_SERIALIZER( StartTime, 0.0f ); // _startTime + + BEGIN_ENUM_SERIALIZER( PlayMode, LOOP ); + ADD_ENUM_VALUE( ONCE ); + ADD_ENUM_VALUE( STAY ); + ADD_ENUM_VALUE( LOOP ); + ADD_ENUM_VALUE( PPONG ); + END_ENUM_SERIALIZER(); // _playmode + + ADD_USER_SERIALIZER( Channels ); // _channels +} diff --git a/src/osgWrappers/serializers/osgAnimation/AnimationManagerBase.cpp b/src/osgWrappers/serializers/osgAnimation/AnimationManagerBase.cpp new file mode 100644 index 000000000..4b4216250 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/AnimationManagerBase.cpp @@ -0,0 +1,49 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +static bool checkAnimations( const osgAnimation::AnimationManagerBase& manager ) +{ + return manager.getAnimationList().size()>0; +} + +static bool readAnimations( osgDB::InputStream& is, osgAnimation::AnimationManagerBase& manager ) +{ + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i( is.readObject() ); + if ( ani ) manager.registerAnimation( ani ); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeAnimations( osgDB::OutputStream& os, const osgAnimation::AnimationManagerBase& manager ) +{ + const osgAnimation::AnimationList& animations = manager.getAnimationList(); + os << animations.size() << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::AnimationList::const_iterator itr=animations.begin(); + itr!=animations.end(); ++itr ) + { + os << itr->get(); + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgAnimation_AnimationManagerBase, + /*new osgAnimation::AnimationManagerBase*/NULL, + osgAnimation::AnimationManagerBase, + "osg::Object osg::NodeCallback osgAnimation::AnimationManagerBase" ) +{ + ADD_USER_SERIALIZER( Animations ); // _animations + ADD_BOOL_SERIALIZER( AutomaticLink, true ); // _automaticLink +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/BasicAnimationManager.cpp b/src/osgWrappers/serializers/osgAnimation/BasicAnimationManager.cpp new file mode 100644 index 000000000..22b913a0c --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/BasicAnimationManager.cpp @@ -0,0 +1,17 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_BasicAnimationManager, + new osgAnimation::BasicAnimationManager, + osgAnimation::BasicAnimationManager, + "osg::Object osg::NodeCallback osgAnimation::AnimationManagerBase osgAnimation::BasicAnimationManager" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/Bone.cpp b/src/osgWrappers/serializers/osgAnimation/Bone.cpp new file mode 100644 index 000000000..a6ba60eb2 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/Bone.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_Bone, + new osgAnimation::Bone, + osgAnimation::Bone, + "osg::Object osg::Node osg::Group osg::Transform osg::MatrixTransform osgAnimation::Bone" ) +{ + ADD_MATRIX_SERIALIZER( InvBindMatrixInSkeletonSpace, osg::Matrix() ); // _invBindInSkeletonSpace + ADD_MATRIX_SERIALIZER( MatrixInSkeletonSpace, osg::Matrix() ); // _boneInSkeletonSpace +} diff --git a/src/osgWrappers/serializers/osgAnimation/CMakeLists.txt b/src/osgWrappers/serializers/osgAnimation/CMakeLists.txt new file mode 100644 index 000000000..0b0c55688 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB TARGET_SRC *.cpp) +FILE(GLOB TARGET_H *.h) + +SET(TARGET_ADDED_LIBRARIES osgAnimation ) + +#### end var setup ### +SETUP_PLUGIN(osganimation) diff --git a/src/osgWrappers/serializers/osgAnimation/MorphGeometry.cpp b/src/osgWrappers/serializers/osgAnimation/MorphGeometry.cpp new file mode 100644 index 000000000..6cc6aa4f1 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/MorphGeometry.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#include + +static bool checkMorphTargets( const osgAnimation::MorphGeometry& geom ) +{ + return geom.getMorphTargetList().size()>0; +} + +static bool readMorphTargets( osgDB::InputStream& is, osgAnimation::MorphGeometry& geom ) +{ + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> osgDB::PROPERTY("MorphTarget") >> weight; + osg::Geometry* target = dynamic_cast( is.readObject() ); + if ( target ) geom.addMorphTarget( target, weight ); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeMorphTargets( osgDB::OutputStream& os, const osgAnimation::MorphGeometry& geom ) +{ + const osgAnimation::MorphGeometry::MorphTargetList& targets = geom.getMorphTargetList(); + os << targets.size() << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::MorphGeometry::MorphTargetList::const_iterator itr=targets.begin(); + itr!=targets.end(); ++itr ) + { + os << osgDB::PROPERTY("MorphTarget") << itr->getWeight() << std::endl; + os << itr->getGeometry(); + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgAnimation_MorphGeometry, + new osgAnimation::MorphGeometry, + osgAnimation::MorphGeometry, + "osg::Object osg::Drawable osg::Geometry osgAnimation::MorphGeometry" ) +{ + BEGIN_ENUM_SERIALIZER( Method, NORMALIZED ); + ADD_ENUM_VALUE( NORMALIZED ); + ADD_ENUM_VALUE( RELATIVE ); + END_ENUM_SERIALIZER(); // _method + + ADD_USER_SERIALIZER( MorphTargets ); // _morphTargets + ADD_BOOL_SERIALIZER( MorphNormals, true ); // _morphNormals +} diff --git a/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp b/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp new file mode 100644 index 000000000..0d16cd2f4 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +static bool checkInfluenceMap( const osgAnimation::RigGeometry& geom ) +{ + return geom.getInfluenceMap()->size()>0; +} + +static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry& geom ) +{ + osgAnimation::VertexInfluenceMap* map = new osgAnimation::VertexInfluenceMap; + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> osgDB::PROPERTY("VertexInfluence") >> name >> viSize >> osgDB::BEGIN_BRACKET; + + osgAnimation::VertexInfluence vi; + vi.setName( name ); + vi.reserve( viSize ); + for ( unsigned int j=0; j> index >> weight; + vi.push_back( osgAnimation::VertexIndexWeight(index, weight) ); + } + (*map)[name] = vi; + is >> osgDB::END_BRACKET; + } + is >> osgDB::END_BRACKET; + + if ( !map->empty() ) geom.setInfluenceMap( map ); + return true; +} + +static bool writeInfluenceMap( osgDB::OutputStream& os, const osgAnimation::RigGeometry& geom ) +{ + const osgAnimation::VertexInfluenceMap* map = geom.getInfluenceMap(); + os << map->size() << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::VertexInfluenceMap::const_iterator itr=map->begin(); + itr!=map->end(); ++itr ) + { + std::string name = itr->first; + const osgAnimation::VertexInfluence& vi = itr->second; + if ( name.empty() ) name = "Empty"; + + os << osgDB::PROPERTY("VertexInfluence") << name << vi.size() + << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::VertexInfluence::const_iterator vitr=vi.begin(); + vitr != vi.end(); ++vitr ) + { + os << vitr->first << vitr->second << std::endl; + } + os << osgDB::END_BRACKET << std::endl; + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgAnimation_RigGeometry, + new osgAnimation::RigGeometry, + osgAnimation::RigGeometry, + "osg::Object osg::Drawable osg::Geometry osgAnimation::RigGeometry" ) +{ + ADD_USER_SERIALIZER( InfluenceMap ); // _vertexInfluenceMap + ADD_OBJECT_SERIALIZER( SourceGeometry, osg::Geometry, NULL ); // _geometry +} diff --git a/src/osgWrappers/serializers/osgAnimation/Skeleton.cpp b/src/osgWrappers/serializers/osgAnimation/Skeleton.cpp new file mode 100644 index 000000000..2dfd315ea --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/Skeleton.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_Skeleton, + new osgAnimation::Skeleton, + osgAnimation::Skeleton, + "osg::Object osg::Node osg::Group osg::Transform osg::MatrixTransform osgAnimation::Skeleton" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedMatrixElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedMatrixElement.cpp new file mode 100644 index 000000000..28014644b --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedMatrixElement.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedMatrixElement, + new osgAnimation::StackedMatrixElement, + osgAnimation::StackedMatrixElement, + "osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedMatrixElement" ) +{ + ADD_MATRIX_SERIALIZER( Matrix, osg::Matrix() ); // _matrix +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedQuaternionElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedQuaternionElement.cpp new file mode 100644 index 000000000..7f7272bd8 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedQuaternionElement.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedQuaternionElement, + new osgAnimation::StackedQuaternionElement, + osgAnimation::StackedQuaternionElement, + "osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedQuaternionElement" ) +{ + ADD_QUAT_SERIALIZER( Quaternion, osg::Quat() ); // _quaternion +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedRotateAxisElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedRotateAxisElement.cpp new file mode 100644 index 000000000..35e263cf4 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedRotateAxisElement.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedRotateAxisElement, + new osgAnimation::StackedRotateAxisElement, + osgAnimation::StackedRotateAxisElement, + "osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedRotateAxisElement" ) +{ + ADD_VEC3_SERIALIZER( Axis, osg::Vec3() ); // _axis + ADD_DOUBLE_SERIALIZER( Angle, 0.0 ); // _angle +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedScaleElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedScaleElement.cpp new file mode 100644 index 000000000..197332551 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedScaleElement.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedScaleElement, + new osgAnimation::StackedScaleElement, + osgAnimation::StackedScaleElement, + "osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedScaleElement" ) +{ + ADD_VEC3_SERIALIZER( Scale, osg::Vec3() ); // _scale +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedTransformElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedTransformElement.cpp new file mode 100644 index 000000000..01f28bc6e --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedTransformElement.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedTransformElement, + /*new osgAnimation::StackedTransformElement*/NULL, + osgAnimation::StackedTransformElement, + "osg::Object osgAnimation::StackedTransformElement" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/StackedTranslateElement.cpp b/src/osgWrappers/serializers/osgAnimation/StackedTranslateElement.cpp new file mode 100644 index 000000000..307abf92a --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/StackedTranslateElement.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_StackedTranslateElement, + new osgAnimation::StackedTranslateElement, + osgAnimation::StackedTranslateElement, + "osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedTranslateElement" ) +{ + ADD_VEC3_SERIALIZER( Translate, osg::Vec3() ); // _translate +} diff --git a/src/osgWrappers/serializers/osgAnimation/Timeline.cpp b/src/osgWrappers/serializers/osgAnimation/Timeline.cpp new file mode 100644 index 000000000..606f761b1 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/Timeline.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_Timeline, + new osgAnimation::Timeline, + osgAnimation::Timeline, + "osg::Object osgAnimation::Action osgAnimation::Timeline" ) +{ +} diff --git a/src/osgWrappers/serializers/osgAnimation/TimelineAnimationManager.cpp b/src/osgWrappers/serializers/osgAnimation/TimelineAnimationManager.cpp new file mode 100644 index 000000000..b46464d69 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/TimelineAnimationManager.cpp @@ -0,0 +1,17 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_TimelineAnimationManager, + new osgAnimation::TimelineAnimationManager, + osgAnimation::TimelineAnimationManager, + "osg::Object osg::NodeCallback osgAnimation::AnimationManagerBase osgAnimation::TimelineAnimationManager" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp new file mode 100644 index 000000000..5818a75f9 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp @@ -0,0 +1,17 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateBone, + new osgAnimation::UpdateBone, + osgAnimation::UpdateBone, + "osg::Object osg::NodeCallback osgAnimation::UpdateMatrixTransform osgAnimation::UpdateBone" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp new file mode 100644 index 000000000..0fe1ef359 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp @@ -0,0 +1,17 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMaterial, + new osgAnimation::UpdateMaterial, + osgAnimation::UpdateMaterial, + "osg::Object osgAnimation::UpdateMaterial" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp new file mode 100644 index 000000000..0b98cb8ef --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp @@ -0,0 +1,50 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +static bool checkStackedTransforms( const osgAnimation::UpdateMatrixTransform& obj ) +{ + return obj.getStackedTransforms().size()>0; +} + +static bool readStackedTransforms( osgDB::InputStream& is, osgAnimation::UpdateMatrixTransform& obj ) +{ + osgAnimation::StackedTransform& transform = obj.getStackedTransforms(); + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i( is.readObject() ); + if ( element ) transform.push_back( element ); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeStackedTransforms( osgDB::OutputStream& os, const osgAnimation::UpdateMatrixTransform& obj ) +{ + const osgAnimation::StackedTransform& transform = obj.getStackedTransforms(); + os << transform.size() << osgDB::BEGIN_BRACKET << std::endl; + for ( osgAnimation::StackedTransform::const_iterator itr=transform.begin(); + itr!=transform.end(); ++itr ) + { + os << itr->get(); + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMatrixTransform, + new osgAnimation::UpdateMatrixTransform, + osgAnimation::UpdateMatrixTransform, + "osg::Object osg::NodeCallback osgAnimation::UpdateMatrixTransform" ) +{ + ADD_USER_SERIALIZER( StackedTransforms ); // _transforms +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp new file mode 100644 index 000000000..a450848ae --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp @@ -0,0 +1,17 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMorph, + new osgAnimation::UpdateMorph, + osgAnimation::UpdateMorph, + "osg::Object osg::NodeCallback osgAnimation::UpdateMorph" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp new file mode 100644 index 000000000..5b910273a --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp @@ -0,0 +1,18 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER2( osgAnimation_UpdateSkeleton, + new osgAnimation::Skeleton::UpdateSkeleton, + osgAnimation::Skeleton::UpdateSkeleton, + "osgAnimation::UpdateSkeleton", + "osg::Object osg::NodeCallback osgAnimation::UpdateSkeleton" ) +{ +} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast