diff --git a/examples/osganimationskinning/osganimationskinning.cpp b/examples/osganimationskinning/osganimationskinning.cpp index d5cb697f3..277b6c779 100644 --- a/examples/osganimationskinning/osganimationskinning.cpp +++ b/examples/osganimationskinning/osganimationskinning.cpp @@ -252,9 +252,6 @@ int main (int argc, char* argv[]) initVertexMap(root.get(), right0.get(), right1.get(), geom, src.get()); - geom->buildVertexSet(); - geom->buildTransformer(skelroot.get()); - // let's run ! viewer.setSceneData( scene ); viewer.realize(); diff --git a/include/osgAnimation/RigGeometry b/include/osgAnimation/RigGeometry index 1885d49f8..d939d81c2 100644 --- a/include/osgAnimation/RigGeometry +++ b/include/osgAnimation/RigGeometry @@ -27,6 +27,47 @@ namespace osgAnimation { public: + RigGeometry(); + RigGeometry(const osg::Geometry& b); + RigGeometry(const RigGeometry& b, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); + + META_Object(osgAnimation, RigGeometry); + + void setInfluenceMap(osgAnimation::VertexInfluenceMap* vertexInfluenceMap) { _vertexInfluenceMap = vertexInfluenceMap; } + const osgAnimation::VertexInfluenceMap* getInfluenceMap() const { return _vertexInfluenceMap.get();} + osgAnimation::VertexInfluenceMap* getInfluenceMap() { return _vertexInfluenceMap.get();} + + const Skeleton* getSkeleton() const; + Skeleton* getSkeleton(); + + void setNeedToComputeMatrix(bool state) { _needToComputeMatrix = state;} + bool getNeedToComputeMatrix() const { return _needToComputeMatrix;} + + void buildVertexSet(); + void buildTransformer(Skeleton* root); + void computeMatrixFromRootSkeleton(); + + virtual void transformSoftwareMethod(); + const osgAnimation::VertexInfluenceSet& getVertexInfluenceSet() const { return _vertexInfluenceSet;} + + const std::vector& getPositionSource() const { return _positionSource;} + const std::vector& getNormalSource() const { return _normalSource;} + + protected: + + std::vector _positionSource; + std::vector _normalSource; + + osgAnimation::VertexInfluenceSet _vertexInfluenceSet; + osg::ref_ptr _vertexInfluenceMap; + osgAnimation::TransformVertexFunctor _transformVertexes; + + osg::Matrix _matrixFromSkeletonToGeometry; + osg::Matrix _invMatrixFromSkeletonToGeometry; + osg::observer_ptr _root; + bool _needToComputeMatrix; + + struct FindNearestParentSkeleton : public osg::NodeVisitor { osg::ref_ptr _root; @@ -73,7 +114,7 @@ namespace osgAnimation /** BuildVertexTransformerVisitor is used to setup RigGeometry drawable * throw a subgraph. */ - struct BuildVertexTransformerVisitor : public osg::NodeVisitor + struct BuildVertexTransformerVisitor : public osg::NodeVisitor { osg::ref_ptr _root; BuildVertexTransformerVisitor(Skeleton* root): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _root = root;} @@ -94,46 +135,7 @@ namespace osgAnimation } }; - - RigGeometry(); - RigGeometry(const osg::Geometry& b); - RigGeometry(const RigGeometry& b, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); - - virtual osg::Object* cloneType() const { return new RigGeometry(); } - virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new RigGeometry(*this,copyop); } - virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } - virtual const char* libraryName() const { return "osgAnimation"; } - virtual const char* className() const { return "RigGeometry"; } - - - void setInfluenceMap(osgAnimation::VertexInfluenceMap* vertexInfluenceMap) { _vertexInfluenceMap = vertexInfluenceMap; } - const osgAnimation::VertexInfluenceMap* getInfluenceMap() const { return _vertexInfluenceMap.get();} - osgAnimation::VertexInfluenceMap* getInfluenceMap() { return _vertexInfluenceMap.get();} - void buildVertexSet(); - void buildTransformer(Skeleton* root); - void computeMatrixFromRootSkeleton(); - - void setNeedToComputeMatrix(bool state) { _needToComputeMatrix = state;} - bool getNeedToComputeMatrix() const { return _needToComputeMatrix;} - - const Skeleton* getSkeleton() const; - Skeleton* getSkeleton(); - virtual void transformSoftwareMethod(); - const osgAnimation::VertexInfluenceSet& getVertexInfluenceSet() const { return _vertexInfluenceSet;} - - std::vector _positionSource; - std::vector _normalSource; - - osgAnimation::VertexInfluenceSet _vertexInfluenceSet; - osg::ref_ptr _vertexInfluenceMap; - osgAnimation::TransformVertexFunctor _transformVertexes; - - osg::Matrix _matrixFromSkeletonToGeometry; - osg::Matrix _invMatrixFromSkeletonToGeometry; - osg::observer_ptr _root; - bool _needToComputeMatrix; - - }; + }; } diff --git a/include/osgAnimation/Timeline b/include/osgAnimation/Timeline index 33de8136f..51ed1fb3c 100644 --- a/include/osgAnimation/Timeline +++ b/include/osgAnimation/Timeline @@ -27,11 +27,11 @@ namespace osgAnimation { - class Action : public virtual osg::Object + class Action : public osg::Object { public: - class Callback : public virtual osg::Object + class Callback : public osg::Object { public: Callback(){} @@ -162,7 +162,7 @@ namespace osgAnimation }; - class Timeline : public virtual osg::Object + class Timeline : public osg::Object { protected: typedef std::pair > FrameAction; diff --git a/src/osgWrappers/osgAnimation/RigGeometry.cpp b/src/osgWrappers/osgAnimation/RigGeometry.cpp index a128c255c..f043eb5fe 100644 --- a/src/osgWrappers/osgAnimation/RigGeometry.cpp +++ b/src/osgWrappers/osgAnimation/RigGeometry.cpp @@ -11,12 +11,9 @@ #include #include -#include -#include #include -#include #include -#include +#include #include #include #include @@ -84,6 +81,26 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry) __osgAnimation_VertexInfluenceMap_P1__getInfluenceMap, "", ""); + I_Method0(const osgAnimation::Skeleton *, getSkeleton, + Properties::NON_VIRTUAL, + __C5_Skeleton_P1__getSkeleton, + "", + ""); + I_Method0(osgAnimation::Skeleton *, getSkeleton, + Properties::NON_VIRTUAL, + __Skeleton_P1__getSkeleton, + "", + ""); + I_Method1(void, setNeedToComputeMatrix, IN, bool, state, + Properties::NON_VIRTUAL, + __void__setNeedToComputeMatrix__bool, + "", + ""); + I_Method0(bool, getNeedToComputeMatrix, + Properties::NON_VIRTUAL, + __bool__getNeedToComputeMatrix, + "", + ""); I_Method0(void, buildVertexSet, Properties::NON_VIRTUAL, __void__buildVertexSet, @@ -99,26 +116,6 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry) __void__computeMatrixFromRootSkeleton, "", ""); - I_Method1(void, setNeedToComputeMatrix, IN, bool, state, - Properties::NON_VIRTUAL, - __void__setNeedToComputeMatrix__bool, - "", - ""); - I_Method0(bool, getNeedToComputeMatrix, - Properties::NON_VIRTUAL, - __bool__getNeedToComputeMatrix, - "", - ""); - I_Method0(const osgAnimation::Skeleton *, getSkeleton, - Properties::NON_VIRTUAL, - __C5_Skeleton_P1__getSkeleton, - "", - ""); - I_Method0(osgAnimation::Skeleton *, getSkeleton, - Properties::NON_VIRTUAL, - __Skeleton_P1__getSkeleton, - "", - ""); I_Method0(void, transformSoftwareMethod, Properties::VIRTUAL, __void__transformSoftwareMethod, @@ -129,79 +126,33 @@ BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry) __C5_osgAnimation_VertexInfluenceSet_R1__getVertexInfluenceSet, "", ""); + I_Method0(const std::vector< osg::Vec3 > &, getPositionSource, + Properties::NON_VIRTUAL, + __C5_std_vectorT1_osg_Vec3__R1__getPositionSource, + "", + ""); + I_Method0(const std::vector< osg::Vec3 > &, getNormalSource, + Properties::NON_VIRTUAL, + __C5_std_vectorT1_osg_Vec3__R1__getNormalSource, + "", + ""); I_SimpleProperty(osgAnimation::VertexInfluenceMap *, InfluenceMap, __osgAnimation_VertexInfluenceMap_P1__getInfluenceMap, __void__setInfluenceMap__osgAnimation_VertexInfluenceMap_P1); I_SimpleProperty(bool, NeedToComputeMatrix, __bool__getNeedToComputeMatrix, __void__setNeedToComputeMatrix__bool); + I_SimpleProperty(const std::vector< osg::Vec3 > &, NormalSource, + __C5_std_vectorT1_osg_Vec3__R1__getNormalSource, + 0); + I_SimpleProperty(const std::vector< osg::Vec3 > &, PositionSource, + __C5_std_vectorT1_osg_Vec3__R1__getPositionSource, + 0); I_SimpleProperty(osgAnimation::Skeleton *, Skeleton, __Skeleton_P1__getSkeleton, 0); I_SimpleProperty(const osgAnimation::VertexInfluenceSet &, VertexInfluenceSet, __C5_osgAnimation_VertexInfluenceSet_R1__getVertexInfluenceSet, 0); - I_PublicMemberProperty(std::vector< osg::Vec3 >, _positionSource); - I_PublicMemberProperty(std::vector< osg::Vec3 >, _normalSource); - I_PublicMemberProperty(osgAnimation::VertexInfluenceSet, _vertexInfluenceSet); - I_PublicMemberProperty(osg::ref_ptr< osgAnimation::VertexInfluenceMap >, _vertexInfluenceMap); - I_PublicMemberProperty(osgAnimation::TransformVertexFunctor, _transformVertexes); - I_PublicMemberProperty(osg::Matrix, _matrixFromSkeletonToGeometry); - I_PublicMemberProperty(osg::Matrix, _invMatrixFromSkeletonToGeometry); - I_PublicMemberProperty(osg::observer_ptr< osgAnimation::Skeleton >, _root); - I_PublicMemberProperty(bool, _needToComputeMatrix); -END_REFLECTOR - -BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry::BuildVertexTransformerVisitor) - I_DeclaringFile("osgAnimation/RigGeometry"); - I_BaseType(osg::NodeVisitor); - I_Constructor1(IN, osgAnimation::Skeleton *, root, - Properties::NON_EXPLICIT, - ____BuildVertexTransformerVisitor__Skeleton_P1, - "", - ""); - I_Method0(const char *, libraryName, - Properties::VIRTUAL, - __C5_char_P1__libraryName, - "return the library name/namespapce of the visitor's. ", - "Should be defined by derived classes. "); - I_Method0(const char *, className, - Properties::VIRTUAL, - __C5_char_P1__className, - "return the name of the visitor's class type. ", - "Should be defined by derived classes. "); - I_Method1(void, apply, IN, osg::Geode &, node, - Properties::VIRTUAL, - __void__apply__osg_Geode_R1, - "", - ""); - I_PublicMemberProperty(osg::ref_ptr< osgAnimation::Skeleton >, _root); -END_REFLECTOR - -BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry::FindNearestParentSkeleton) - I_DeclaringFile("osgAnimation/RigGeometry"); - I_BaseType(osg::NodeVisitor); - I_Constructor0(____FindNearestParentSkeleton, - "", - ""); - I_Method1(void, apply, IN, osg::Transform &, node, - Properties::VIRTUAL, - __void__apply__osg_Transform_R1, - "", - ""); - I_PublicMemberProperty(osg::ref_ptr< osgAnimation::Skeleton >, _root); -END_REFLECTOR - -BEGIN_OBJECT_REFLECTOR(osgAnimation::RigGeometry::UpdateVertex) - I_DeclaringFile("osgAnimation/RigGeometry"); - I_BaseType(osg::Drawable::UpdateCallback); - I_Constructor0(____UpdateVertex, - "", - ""); - I_Method2(void, update, IN, osg::NodeVisitor *, x, IN, osg::Drawable *, drw, - Properties::VIRTUAL, - __void__update__osg_NodeVisitor_P1__osg_Drawable_P1, - "do customized update code. ", - ""); END_REFLECTOR diff --git a/src/osgWrappers/osgAnimation/Timeline.cpp b/src/osgWrappers/osgAnimation/Timeline.cpp index 40e3bdf6a..4f3393bf8 100644 --- a/src/osgWrappers/osgAnimation/Timeline.cpp +++ b/src/osgWrappers/osgAnimation/Timeline.cpp @@ -28,7 +28,7 @@ TYPE_NAME_ALIAS(std::map< unsigned int COMMA osg::ref_ptr< osgAnimation::Action BEGIN_OBJECT_REFLECTOR(osgAnimation::Action) I_DeclaringFile("osgAnimation/Timeline"); - I_VirtualBaseType(osg::Object); + I_BaseType(osg::Object); I_Method0(osg::Object *, cloneType, Properties::VIRTUAL, __osg_Object_P1__cloneType, @@ -138,7 +138,7 @@ END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osgAnimation::Action::Callback) I_DeclaringFile("osgAnimation/Timeline"); - I_VirtualBaseType(osg::Object); + I_BaseType(osg::Object); I_Constructor0(____Callback, "", ""); @@ -322,7 +322,7 @@ END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osgAnimation::Timeline) I_DeclaringFile("osgAnimation/Timeline"); - I_VirtualBaseType(osg::Object); + I_BaseType(osg::Object); I_Method0(osg::Object *, cloneType, Properties::VIRTUAL, __osg_Object_P1__cloneType,