From Wang Rui, "Attached is the osgAnimation wrappers for serialize IO operations. A
few headers and the osgAnimation sources are also modified to make everything goes well, including: A new REGISTER_OBJECT_WRAPPER2 macro to wrap classes like Skeleton::UpdateSkeleton. A bug fix in the Seralizer header which avoids setting default values to objects. Naming style fixes in osgAnimation headers and sources, also in the deprecated dotosg wrappers. A bug fix for the XML support, to write char values correctly. A small change in the osg::Geometry wrapper to ignore the InternalGeometry property, which is used by the MorphGeometry and should not be set by user applications. The avatar.osg, nathan.osg and robot.osg data files all work fine with serializers, with some 'unsupported wrapper' warnings when converting. I'm thinking of removing these warnings by disabling related property serializers (ComputeBoundingBoxCallback and Drawable::UpdateCallback), which are seldom recorded by users. By the way, I still wonder how would we handle the C4121 problem, discussed some days before. The /Zp compile option is set to 16 in the attached cmake script file. And is there a better solution now?"
This commit is contained in:
parent
6ec106b31a
commit
488eac94f7
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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;}
|
||||
|
@ -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:
|
||||
|
@ -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();}
|
||||
|
@ -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:
|
||||
|
@ -499,6 +499,7 @@ public:
|
||||
{
|
||||
is >> BEGIN_BRACKET;
|
||||
P* value = dynamic_cast<P*>( is.readObject() );
|
||||
if ( ParentType::_defaultValue!=value )
|
||||
(object.*_setter)( value );
|
||||
is >> END_BRACKET;
|
||||
}
|
||||
@ -567,6 +568,7 @@ public:
|
||||
{
|
||||
is >> BEGIN_BRACKET;
|
||||
P* value = dynamic_cast<P*>( is.readImage() );
|
||||
if ( ParentType::_defaultValue!=value )
|
||||
(object.*_setter)( value );
|
||||
is >> END_BRACKET;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
"",
|
||||
"");
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
14
src/osgWrappers/serializers/osgAnimation/Action.cpp
Normal file
14
src/osgWrappers/serializers/osgAnimation/Action.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <osgAnimation/Action>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
||||
}
|
11
src/osgWrappers/serializers/osgAnimation/ActionAnimation.cpp
Normal file
11
src/osgWrappers/serializers/osgAnimation/ActionAnimation.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/ActionAnimation>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_ActionAnimation,
|
||||
new osgAnimation::ActionAnimation,
|
||||
osgAnimation::ActionAnimation,
|
||||
"osg::Object osgAnimation::Action osgAnimation::ActionAnimation" )
|
||||
{
|
||||
}
|
11
src/osgWrappers/serializers/osgAnimation/ActionBlendIn.cpp
Normal file
11
src/osgWrappers/serializers/osgAnimation/ActionBlendIn.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/ActionBlendIn>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_ActionBlendIn,
|
||||
new osgAnimation::ActionBlendIn,
|
||||
osgAnimation::ActionBlendIn,
|
||||
"osg::Object osgAnimation::Action osgAnimation::ActionBlendIn" )
|
||||
{
|
||||
}
|
11
src/osgWrappers/serializers/osgAnimation/ActionBlendOut.cpp
Normal file
11
src/osgWrappers/serializers/osgAnimation/ActionBlendOut.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/ActionBlendOut>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_ActionBlendOut,
|
||||
new osgAnimation::ActionBlendOut,
|
||||
osgAnimation::ActionBlendOut,
|
||||
"osg::Object osgAnimation::Action osgAnimation::ActionBlendOut" )
|
||||
{
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/ActionStripAnimation>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_ActionStripAnimation,
|
||||
new osgAnimation::ActionStripAnimation,
|
||||
osgAnimation::ActionStripAnimation,
|
||||
"osg::Object osgAnimation::Action osgAnimation::ActionStripAnimation" )
|
||||
{
|
||||
}
|
252
src/osgWrappers/serializers/osgAnimation/Animation.cpp
Normal file
252
src/osgWrappers/serializers/osgAnimation/Animation.cpp
Normal file
@ -0,0 +1,252 @@
|
||||
#include <osgAnimation/Animation>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
// 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<osg/io_utils>
|
||||
template <typename ContainerType, typename ValueType>
|
||||
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<size; ++i )
|
||||
{
|
||||
double time = 0.0f;
|
||||
ValueType value;
|
||||
is >> time >> value;
|
||||
container->push_back( KeyType(time, value) );
|
||||
}
|
||||
is >> osgDB::END_BRACKET;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ContainerType, typename ValueType, typename InternalValueType>
|
||||
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<size; ++i )
|
||||
{
|
||||
double time = 0.0f;
|
||||
InternalValueType pos, ptIn, ptOut;
|
||||
is >> 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<CONTAINER, VALUE>( 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<CONTAINER, VALUE, INVALUE>( 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 <typename ContainerType>
|
||||
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; i<container->size(); ++i )
|
||||
{
|
||||
os << (*container)[i].getTime() << (*container)[i].getValue() << std::endl;
|
||||
}
|
||||
os << osgDB::END_BRACKET;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
template <typename ContainerType>
|
||||
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; i<container->size(); ++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<CHANNEL*>(ch); \
|
||||
if ( ch_##NAME ) { \
|
||||
os << osgDB::PROPERTY("Type") << std::string(#NAME) << osgDB::BEGIN_BRACKET << std::endl; \
|
||||
writeChannel( os, ch_##NAME ); \
|
||||
writeContainer<CONTAINER>( os, ch_##NAME ->getSamplerTyped()->getKeyframeContainerTyped() ); \
|
||||
os << osgDB::END_BRACKET << std::endl; \
|
||||
continue; \
|
||||
}
|
||||
|
||||
#define WRITE_CHANNEL_FUNC2( NAME, CHANNEL, CONTAINER ) \
|
||||
CHANNEL* ch_##NAME = dynamic_cast<CHANNEL*>(ch); \
|
||||
if ( ch_##NAME ) { \
|
||||
os << osgDB::PROPERTY("Type") << #NAME << osgDB::BEGIN_BRACKET << std::endl; \
|
||||
writeChannel( os, ch_##NAME ); \
|
||||
writeContainer2<CONTAINER>( 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<size; ++i )
|
||||
{
|
||||
std::string type;
|
||||
is >> 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
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/AnimationManagerBase>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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<size; ++i )
|
||||
{
|
||||
osgAnimation::Animation* ani = dynamic_cast<osgAnimation::Animation*>( 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
|
@ -0,0 +1,17 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/BasicAnimationManager>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
13
src/osgWrappers/serializers/osgAnimation/Bone.cpp
Normal file
13
src/osgWrappers/serializers/osgAnimation/Bone.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <osgAnimation/Bone>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
||||
}
|
7
src/osgWrappers/serializers/osgAnimation/CMakeLists.txt
Normal file
7
src/osgWrappers/serializers/osgAnimation/CMakeLists.txt
Normal file
@ -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)
|
51
src/osgWrappers/serializers/osgAnimation/MorphGeometry.cpp
Normal file
51
src/osgWrappers/serializers/osgAnimation/MorphGeometry.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <osgAnimation/MorphGeometry>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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<size; ++i )
|
||||
{
|
||||
float weight = 0.0f;
|
||||
is >> osgDB::PROPERTY("MorphTarget") >> weight;
|
||||
osg::Geometry* target = dynamic_cast<osg::Geometry*>( 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
|
||||
}
|
71
src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp
Normal file
71
src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <osgAnimation/RigGeometry>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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<size; ++i )
|
||||
{
|
||||
std::string name;
|
||||
unsigned int viSize = 0;
|
||||
is >> osgDB::PROPERTY("VertexInfluence") >> name >> viSize >> osgDB::BEGIN_BRACKET;
|
||||
|
||||
osgAnimation::VertexInfluence vi;
|
||||
vi.setName( name );
|
||||
vi.reserve( viSize );
|
||||
for ( unsigned int j=0; j<viSize; ++j )
|
||||
{
|
||||
int index = 0;
|
||||
float weight = 0.0f;
|
||||
is >> 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
|
||||
}
|
11
src/osgWrappers/serializers/osgAnimation/Skeleton.cpp
Normal file
11
src/osgWrappers/serializers/osgAnimation/Skeleton.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/Skeleton>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_Skeleton,
|
||||
new osgAnimation::Skeleton,
|
||||
osgAnimation::Skeleton,
|
||||
"osg::Object osg::Node osg::Group osg::Transform osg::MatrixTransform osgAnimation::Skeleton" )
|
||||
{
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#include <osgAnimation/StackedMatrixElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_StackedMatrixElement,
|
||||
new osgAnimation::StackedMatrixElement,
|
||||
osgAnimation::StackedMatrixElement,
|
||||
"osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedMatrixElement" )
|
||||
{
|
||||
ADD_MATRIX_SERIALIZER( Matrix, osg::Matrix() ); // _matrix
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#include <osgAnimation/StackedQuaternionElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_StackedQuaternionElement,
|
||||
new osgAnimation::StackedQuaternionElement,
|
||||
osgAnimation::StackedQuaternionElement,
|
||||
"osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedQuaternionElement" )
|
||||
{
|
||||
ADD_QUAT_SERIALIZER( Quaternion, osg::Quat() ); // _quaternion
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#include <osgAnimation/StackedRotateAxisElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#include <osgAnimation/StackedScaleElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_StackedScaleElement,
|
||||
new osgAnimation::StackedScaleElement,
|
||||
osgAnimation::StackedScaleElement,
|
||||
"osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedScaleElement" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Scale, osg::Vec3() ); // _scale
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/StackedTransformElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_StackedTransformElement,
|
||||
/*new osgAnimation::StackedTransformElement*/NULL,
|
||||
osgAnimation::StackedTransformElement,
|
||||
"osg::Object osgAnimation::StackedTransformElement" )
|
||||
{
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#include <osgAnimation/StackedTranslateElement>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_StackedTranslateElement,
|
||||
new osgAnimation::StackedTranslateElement,
|
||||
osgAnimation::StackedTranslateElement,
|
||||
"osg::Object osgAnimation::StackedTransformElement osgAnimation::StackedTranslateElement" )
|
||||
{
|
||||
ADD_VEC3_SERIALIZER( Translate, osg::Vec3() ); // _translate
|
||||
}
|
11
src/osgWrappers/serializers/osgAnimation/Timeline.cpp
Normal file
11
src/osgWrappers/serializers/osgAnimation/Timeline.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <osgAnimation/Timeline>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_Timeline,
|
||||
new osgAnimation::Timeline,
|
||||
osgAnimation::Timeline,
|
||||
"osg::Object osgAnimation::Action osgAnimation::Timeline" )
|
||||
{
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/TimelineAnimationManager>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
17
src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp
Normal file
17
src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/UpdateBone>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
17
src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp
Normal file
17
src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/UpdateMaterial>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMaterial,
|
||||
new osgAnimation::UpdateMaterial,
|
||||
osgAnimation::UpdateMaterial,
|
||||
"osg::Object osgAnimation::UpdateMaterial" )
|
||||
{
|
||||
}
|
||||
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST static_cast
|
@ -0,0 +1,50 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/UpdateMatrixTransform>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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<size; ++i )
|
||||
{
|
||||
osgAnimation::StackedTransformElement* element =
|
||||
dynamic_cast<osgAnimation::StackedTransformElement*>( 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
|
17
src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp
Normal file
17
src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/MorphGeometry>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMorph,
|
||||
new osgAnimation::UpdateMorph,
|
||||
osgAnimation::UpdateMorph,
|
||||
"osg::Object osg::NodeCallback osgAnimation::UpdateMorph" )
|
||||
{
|
||||
}
|
||||
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST static_cast
|
18
src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp
Normal file
18
src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osgAnimation/Skeleton>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user