From 0adf26ec6e9d4d40e36926aa8a8155d3fe8c7180 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 Apr 2010 20:16:44 +0000 Subject: [PATCH] From Wang Rui, "The osgManipulator serializers are ready now. I need to modify the META_OSGMANIPULATOR_Object macro to ensure these classes could work with their wrappers, and a few naming styles should be changed as well. Fortunately everything seems to compile fine under Windows and my new Ubuntu system. And I finally find the problem of the serializers/osgTerrain/Terrain.cpp, it just missed an "osg::Group" before "osg::CoordinateSystemNode" indicator. With the small fix attached now VPB could generate terrain with osgt/osgb formats." --- include/osgManipulator/AntiSquish | 4 +- include/osgManipulator/Export | 1 + include/osgManipulator/RotateCylinderDragger | 4 +- include/osgManipulator/RotateSphereDragger | 4 +- include/osgManipulator/Scale1DDragger | 8 +- include/osgManipulator/Scale2DDragger | 16 ++-- include/osgManipulator/Translate1DDragger | 4 +- include/osgManipulator/Translate2DDragger | 4 +- src/osgWrappers/serializers/CMakeLists.txt | 1 + .../serializers/osgManipulator/AntiSquish.cpp | 13 +++ .../serializers/osgManipulator/CMakeLists.txt | 7 ++ .../osgManipulator/CompositeDragger.cpp | 42 ++++++++++ .../serializers/osgManipulator/Dragger.cpp | 84 +++++++++++++++++++ .../osgManipulator/RotateCylinderDragger.cpp | 14 ++++ .../osgManipulator/RotateSphereDragger.cpp | 14 ++++ .../osgManipulator/Scale1DDragger.cpp | 33 ++++++++ .../osgManipulator/Scale2DDragger.cpp | 39 +++++++++ .../osgManipulator/ScaleAxisDragger.cpp | 12 +++ .../osgManipulator/TabBoxDragger.cpp | 12 +++ .../osgManipulator/TabBoxTrackballDragger.cpp | 12 +++ .../osgManipulator/TabPlaneDragger.cpp | 12 +++ .../TabPlaneTrackballDragger.cpp | 12 +++ .../osgManipulator/TrackballDragger.cpp | 12 +++ .../osgManipulator/Translate1DDragger.cpp | 14 ++++ .../osgManipulator/Translate2DDragger.cpp | 14 ++++ .../osgManipulator/TranslateAxisDragger.cpp | 12 +++ .../osgManipulator/TranslatePlaneDragger.cpp | 12 +++ .../serializers/osgTerrain/Terrain.cpp | 2 +- 28 files changed, 398 insertions(+), 20 deletions(-) create mode 100644 src/osgWrappers/serializers/osgManipulator/AntiSquish.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/CMakeLists.txt create mode 100644 src/osgWrappers/serializers/osgManipulator/CompositeDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/Dragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/RotateCylinderDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/RotateSphereDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/Scale1DDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/Scale2DDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/ScaleAxisDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TabBoxDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TabBoxTrackballDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TabPlaneDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TabPlaneTrackballDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TrackballDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/Translate1DDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/Translate2DDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TranslateAxisDragger.cpp create mode 100644 src/osgWrappers/serializers/osgManipulator/TranslatePlaneDragger.cpp diff --git a/include/osgManipulator/AntiSquish b/include/osgManipulator/AntiSquish index 1f965ea2b..802c0aeba 100644 --- a/include/osgManipulator/AntiSquish +++ b/include/osgManipulator/AntiSquish @@ -51,7 +51,7 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform _dirty = true; } - const osg::Vec3d& getPivot() { return _pivot; } + const osg::Vec3d& getPivot() const { return _pivot; } void setPosition(const osg::Vec3d& pos) { @@ -60,7 +60,7 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform _dirty = true; } - const osg::Vec3d& getPosition() { return _position; } + const osg::Vec3d& getPosition() const { return _position; } virtual ~AntiSquish(); diff --git a/include/osgManipulator/Export b/include/osgManipulator/Export index 84ff231c0..822828696 100644 --- a/include/osgManipulator/Export +++ b/include/osgManipulator/Export @@ -28,6 +28,7 @@ #endif #define META_OSGMANIPULATOR_Object(library,name) \ +virtual osg::Object* cloneType() const { return new name (); } \ virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } \ virtual const char* libraryName() const { return #library; }\ virtual const char* className() const { return #name; } diff --git a/include/osgManipulator/RotateCylinderDragger b/include/osgManipulator/RotateCylinderDragger index 61c49d3ca..318fbfb88 100644 --- a/include/osgManipulator/RotateCylinderDragger +++ b/include/osgManipulator/RotateCylinderDragger @@ -41,7 +41,7 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** * Set/Get pick color for dragger. Pick color is color of the dragger @@ -49,7 +49,7 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger * been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } protected: diff --git a/include/osgManipulator/RotateSphereDragger b/include/osgManipulator/RotateSphereDragger index 84243a63f..8efe3131d 100644 --- a/include/osgManipulator/RotateSphereDragger +++ b/include/osgManipulator/RotateSphereDragger @@ -41,7 +41,7 @@ class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** * Set/Get pick color for dragger. Pick color is color of the dragger @@ -49,7 +49,7 @@ class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger * been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } protected: diff --git a/include/osgManipulator/Scale1DDragger b/include/osgManipulator/Scale1DDragger index e4fac897d..828cfa6c0 100644 --- a/include/osgManipulator/Scale1DDragger +++ b/include/osgManipulator/Scale1DDragger @@ -51,7 +51,7 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** * Set/Get pick color for dragger. Pick color is color of the dragger @@ -59,19 +59,21 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger * been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } /** Set/Get left and right handle nodes for dragger. */ inline void setLeftHandleNode (osg::Node& node) { _leftHandleNode = &node; } inline void setRightHandleNode(osg::Node& node) { _rightHandleNode = &node; } inline osg::Node* getLeftHandleNode() { return _leftHandleNode.get(); } + inline const osg::Node* getLeftHandleNode() const { return _leftHandleNode.get(); } inline osg::Node* getRightHandleNode() { return _rightHandleNode.get(); } + inline const osg::Node* getRightHandleNode() const { return _rightHandleNode.get(); } /** Set left/right handle position. */ inline void setLeftHandlePosition(double pos) { _projector->getLineStart() = osg::Vec3d(pos,0.0,0.0); } inline double getLeftHandlePosition() const { return _projector->getLineStart()[0]; } inline void setRightHandlePosition(double pos) { _projector->getLineEnd() = osg::Vec3d(pos,0.0,0.0); } - inline double getRightHandlePosition() { return _projector->getLineEnd()[0]; } + inline double getRightHandlePosition() const { return _projector->getLineEnd()[0]; } protected: diff --git a/include/osgManipulator/Scale2DDragger b/include/osgManipulator/Scale2DDragger index 2ebb17c57..e97f1ee73 100644 --- a/include/osgManipulator/Scale2DDragger +++ b/include/osgManipulator/Scale2DDragger @@ -51,7 +51,7 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** * Set/Get pick color for dragger. Pick color is color of the dragger @@ -59,27 +59,31 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger * been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } /** Set/Get the handle nodes for dragger. */ inline void setTopLeftHandleNode (osg::Node& node) { _topLeftHandleNode = &node; } inline osg::Node* getTopLeftHandleNode() { return _topLeftHandleNode.get(); } + inline const osg::Node* getTopLeftHandleNode() const { return _topLeftHandleNode.get(); } inline void setBottomLeftHandleNode (osg::Node& node) { _bottomLeftHandleNode = &node; } inline osg::Node* getBottomLeftHandleNode() { return _bottomLeftHandleNode.get(); } + inline const osg::Node* getBottomLeftHandleNode() const { return _bottomLeftHandleNode.get(); } inline void setTopRightHandleNode(osg::Node& node) { _topRightHandleNode = &node; } inline osg::Node* getTopRightHandleNode() { return _topRightHandleNode.get(); } + inline const osg::Node* getTopRightHandleNode() const { return _topRightHandleNode.get(); } inline void setBottomRightHandleNode(osg::Node& node) { _bottomRightHandleNode = &node; } inline osg::Node* getBottomRightHandleNode() { return _bottomRightHandleNode.get(); } + inline const osg::Node* getBottomRightHandleNode() const { return _bottomRightHandleNode.get(); } /** Set/Get the handle nodes postion for dragger. */ inline void setTopLeftHandlePosition(const osg::Vec2d& pos) { _topLeftHandlePosition = pos; } - const osg::Vec2d& getTopLeftHandlePosition() { return _topLeftHandlePosition; } + const osg::Vec2d& getTopLeftHandlePosition() const { return _topLeftHandlePosition; } inline void setBottomLeftHandlePosition(const osg::Vec2d& pos) { _bottomLeftHandlePosition = pos; } - const osg::Vec2d& getBottomLeftHandlePosition() { return _bottomLeftHandlePosition; } + const osg::Vec2d& getBottomLeftHandlePosition() const { return _bottomLeftHandlePosition; } inline void setTopRightHandlePosition(const osg::Vec2d& pos) { _topRightHandlePosition = pos; } - const osg::Vec2d& getTopRightHandlePosition() { return _topRightHandlePosition; } + const osg::Vec2d& getTopRightHandlePosition() const { return _topRightHandlePosition; } inline void setBottomRightHandlePosition(const osg::Vec2d& pos){ _bottomRightHandlePosition = pos; } - const osg::Vec2d& getBottomRightHandlePosition() { return _bottomRightHandlePosition; } + const osg::Vec2d& getBottomRightHandlePosition() const { return _bottomRightHandlePosition; } protected: diff --git a/include/osgManipulator/Translate1DDragger b/include/osgManipulator/Translate1DDragger index dbacd4ab0..eefa70c3a 100644 --- a/include/osgManipulator/Translate1DDragger +++ b/include/osgManipulator/Translate1DDragger @@ -42,12 +42,12 @@ class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** Set/Get pick color for dragger. Pick color is color of the dragger when picked. It gives a visual feedback to show that the dragger has been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } inline void setCheckForNodeInNodePath(bool onOff) { _checkForNodeInNodePath = onOff; } diff --git a/include/osgManipulator/Translate2DDragger b/include/osgManipulator/Translate2DDragger index 5a70454ce..9cb5cb6d9 100644 --- a/include/osgManipulator/Translate2DDragger +++ b/include/osgManipulator/Translate2DDragger @@ -43,12 +43,12 @@ class OSGMANIPULATOR_EXPORT Translate2DDragger : public Dragger /** Set/Get color for dragger. */ inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); } - inline const osg::Vec4 getColor() const { return _color; } + inline const osg::Vec4& getColor() const { return _color; } /** Set/Get pick color for dragger. Pick color is color of the dragger when picked. It gives a visual feedback to show that the dragger has been picked. */ inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } - inline const osg::Vec4 getPickColor() const { return _pickColor; } + inline const osg::Vec4& getPickColor() const { return _pickColor; } protected: diff --git a/src/osgWrappers/serializers/CMakeLists.txt b/src/osgWrappers/serializers/CMakeLists.txt index 0324a286d..64859f297 100644 --- a/src/osgWrappers/serializers/CMakeLists.txt +++ b/src/osgWrappers/serializers/CMakeLists.txt @@ -40,6 +40,7 @@ SET(TARGET_COMMON_LIBRARIES ADD_SUBDIRECTORY(osg) ADD_SUBDIRECTORY(osgAnimation) ADD_SUBDIRECTORY(osgFX) +ADD_SUBDIRECTORY(osgManipulator) ADD_SUBDIRECTORY(osgParticle) ADD_SUBDIRECTORY(osgShadow) ADD_SUBDIRECTORY(osgTerrain) diff --git a/src/osgWrappers/serializers/osgManipulator/AntiSquish.cpp b/src/osgWrappers/serializers/osgManipulator/AntiSquish.cpp new file mode 100644 index 000000000..aeb05e539 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/AntiSquish.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_AntiSquish, + new osgManipulator::AntiSquish, + osgManipulator::AntiSquish, + "osg::Object osg::Node osg::Group osg::Transform osg::MatrixTransform osgManipulator::AntiSquish" ) +{ + ADD_VEC3D_SERIALIZER( Pivot, osg::Vec3d() ); // _pivot + ADD_VEC3D_SERIALIZER( Position, osg::Vec3d() ); // _position +} diff --git a/src/osgWrappers/serializers/osgManipulator/CMakeLists.txt b/src/osgWrappers/serializers/osgManipulator/CMakeLists.txt new file mode 100644 index 000000000..b278fbb02 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB TARGET_SRC *.cpp) +FILE(GLOB TARGET_H *.h) + +SET(TARGET_ADDED_LIBRARIES osgManipulator ) + +#### end var setup ### +SETUP_PLUGIN(osgmanipulator) diff --git a/src/osgWrappers/serializers/osgManipulator/CompositeDragger.cpp b/src/osgWrappers/serializers/osgManipulator/CompositeDragger.cpp new file mode 100644 index 000000000..6699d8a51 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/CompositeDragger.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +static bool checkDraggers( const osgManipulator::CompositeDragger& dragger ) +{ + return dragger.getNumDraggers()>0; +} + +static bool readDraggers( osgDB::InputStream& is, osgManipulator::CompositeDragger& dragger ) +{ + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i( is.readObject() ); + if ( child ) dragger.addDragger( child ); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeDraggers( osgDB::OutputStream& os, const osgManipulator::CompositeDragger& dragger ) +{ + unsigned int size = dragger.getNumDraggers(); + os << size << osgDB::BEGIN_BRACKET << std::endl; + for ( unsigned int i=0; i +#include +#include +#include +#include + +// TransformUpdating +static bool checkTransformUpdating( const osgManipulator::Dragger& dragger ) +{ + return dragger.getDraggerCallbacks().size()>0; +} + +static bool readTransformUpdating( osgDB::InputStream& is, osgManipulator::Dragger& dragger ) +{ + unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> name >> osgDB::BEGIN_BRACKET; + if ( name=="DraggerTransformCallback" ) + { + osg::MatrixTransform* transform = dynamic_cast( is.readObject() ); + if ( transform ) dragger.addTransformUpdating( transform ); + } + is >> osgDB::END_BRACKET; + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeTransformUpdating( osgDB::OutputStream& os, const osgManipulator::Dragger& dragger ) +{ + const osgManipulator::Dragger::DraggerCallbacks& callbacks = dragger.getDraggerCallbacks(); + os.writeSize( callbacks.size() ); os << osgDB::BEGIN_BRACKET << std::endl; + for ( osgManipulator::Dragger::DraggerCallbacks::const_iterator itr=callbacks.begin(); + itr!=callbacks.end(); ++itr ) + { + osgManipulator::DraggerTransformCallback* dtcb = + dynamic_cast( itr->get() ); + if ( dtcb ) + { + os << std::string("DraggerTransformCallback") << osgDB::BEGIN_BRACKET << std::endl; + os << dtcb->getTransform(); + } + else + { + os << std::string("DraggerCallback") << osgDB::BEGIN_BRACKET << std::endl; + } + os << osgDB::END_BRACKET << std::endl; + } + os << osgDB::END_BRACKET << std::endl; + return true; +} + +// DefaultGeometry: FIXME - add a setUseDefaultGeometry(bool) here? +static bool checkDefaultGeometry( const osgManipulator::Dragger& dragger ) +{ return true; } + +static bool readDefaultGeometry( osgDB::InputStream& is, osgManipulator::Dragger& dragger ) +{ + bool useDefGeometry = false; is >> useDefGeometry; + dragger.setupDefaultGeometry(); + return true; +} + +static bool writeDefaultGeometry( osgDB::OutputStream& os, const osgManipulator::Dragger& dragger ) +{ + os << true << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgManipulator_Dragger, + /*new osgManipulator::Dragger*/NULL, + osgManipulator::Dragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger" ) +{ + // Dragger should not record children seperately, so ignore the osg::Group class wrapper + + ADD_BOOL_SERIALIZER( HandleEvents, false ); // _handleEvents + ADD_BOOL_SERIALIZER( DraggerActive, false ); // _draggerActive + ADD_UINT_SERIALIZER( ActivationModKeyMask, 0 ); // _activationModKeyMask + ADD_INT_SERIALIZER( ActivationKeyEvent, 0 ); // _activationKeyEvent + ADD_USER_SERIALIZER( TransformUpdating ); // _draggerCallbacks + ADD_USER_SERIALIZER( DefaultGeometry ); +} diff --git a/src/osgWrappers/serializers/osgManipulator/RotateCylinderDragger.cpp b/src/osgWrappers/serializers/osgManipulator/RotateCylinderDragger.cpp new file mode 100644 index 000000000..872ed56ff --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/RotateCylinderDragger.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_RotateCylinderDragger, + new osgManipulator::RotateCylinderDragger, + osgManipulator::RotateCylinderDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::RotateCylinderDragger" ) +{ + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor +} diff --git a/src/osgWrappers/serializers/osgManipulator/RotateSphereDragger.cpp b/src/osgWrappers/serializers/osgManipulator/RotateSphereDragger.cpp new file mode 100644 index 000000000..221bc4439 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/RotateSphereDragger.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_RotateSphereDragger, + new osgManipulator::RotateSphereDragger, + osgManipulator::RotateSphereDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::RotateSphereDragger" ) +{ + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor +} diff --git a/src/osgWrappers/serializers/osgManipulator/Scale1DDragger.cpp b/src/osgWrappers/serializers/osgManipulator/Scale1DDragger.cpp new file mode 100644 index 000000000..e78aa5c92 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/Scale1DDragger.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +#define HANDLENODE_FUNC( PROP ) \ + static bool check##PROP( const osgManipulator::Scale1DDragger& dragger ) \ + { return dragger.get##PROP()!=NULL; } \ + static bool read##PROP( osgDB::InputStream& is, osgManipulator::Scale1DDragger& dragger ) { \ + osg::Node* node = dynamic_cast( is.readObject() ); \ + if ( node ) dragger.set##PROP( *node ); return true; \ + } \ + static bool write##PROP( osgDB::OutputStream& os, const osgManipulator::Scale1DDragger& dragger ) { \ + os << dragger.get##PROP(); return true; \ + } + +HANDLENODE_FUNC( LeftHandleNode ) +HANDLENODE_FUNC( RightHandleNode ) + +REGISTER_OBJECT_WRAPPER( osgManipulator_Scale1DDragger, + new osgManipulator::Scale1DDragger, + osgManipulator::Scale1DDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::Scale1DDragger" ) +{ + ADD_DOUBLE_SERIALIZER( MinScale, 0.0 );// _minScale + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor + ADD_USER_SERIALIZER( LeftHandleNode ); // _leftHandleNode + ADD_USER_SERIALIZER( RightHandleNode ); // _rightHandleNode + ADD_DOUBLE_SERIALIZER( LeftHandlePosition, 0.0 ); + ADD_DOUBLE_SERIALIZER( RightHandlePosition, 0.0 ); +} diff --git a/src/osgWrappers/serializers/osgManipulator/Scale2DDragger.cpp b/src/osgWrappers/serializers/osgManipulator/Scale2DDragger.cpp new file mode 100644 index 000000000..7a1e14c39 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/Scale2DDragger.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +#define HANDLENODE_FUNC( PROP ) \ + static bool check##PROP( const osgManipulator::Scale2DDragger& dragger ) \ + { return dragger.get##PROP()!=NULL; } \ + static bool read##PROP( osgDB::InputStream& is, osgManipulator::Scale2DDragger& dragger ) { \ + osg::Node* node = dynamic_cast( is.readObject() ); \ + if ( node ) dragger.set##PROP( *node ); return true; \ + } \ + static bool write##PROP( osgDB::OutputStream& os, const osgManipulator::Scale2DDragger& dragger ) { \ + os << dragger.get##PROP(); return true; \ + } + +HANDLENODE_FUNC( TopLeftHandleNode ) +HANDLENODE_FUNC( BottomLeftHandleNode ) +HANDLENODE_FUNC( TopRightHandleNode ) +HANDLENODE_FUNC( BottomRightHandleNode ) + +REGISTER_OBJECT_WRAPPER( osgManipulator_Scale2DDragger, + new osgManipulator::Scale2DDragger, + osgManipulator::Scale2DDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::Scale2DDragger" ) +{ + ADD_VEC2D_SERIALIZER( MinScale, osg::Vec2d() );// _minScale + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor + ADD_USER_SERIALIZER( TopLeftHandleNode ); // _topLeftHandleNode + ADD_USER_SERIALIZER( BottomLeftHandleNode ); // _bottomLeftHandleNode + ADD_USER_SERIALIZER( TopRightHandleNode ); // _topRightHandleNode + ADD_USER_SERIALIZER( BottomRightHandleNode ); // _bottomRightHandleNode + ADD_VEC2D_SERIALIZER( TopLeftHandlePosition, osg::Vec2d() ); + ADD_VEC2D_SERIALIZER( BottomLeftHandlePosition, osg::Vec2d() ); + ADD_VEC2D_SERIALIZER( TopRightHandlePosition, osg::Vec2d() ); + ADD_VEC2D_SERIALIZER( BottomRightHandlePosition, osg::Vec2d() ); +} diff --git a/src/osgWrappers/serializers/osgManipulator/ScaleAxisDragger.cpp b/src/osgWrappers/serializers/osgManipulator/ScaleAxisDragger.cpp new file mode 100644 index 000000000..2ade70a53 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/ScaleAxisDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_ScaleAxisDragger, + new osgManipulator::ScaleAxisDragger, + osgManipulator::ScaleAxisDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::ScaleAxisDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TabBoxDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TabBoxDragger.cpp new file mode 100644 index 000000000..4a590cda6 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TabBoxDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TabBoxDragger, + new osgManipulator::TabBoxDragger, + osgManipulator::TabBoxDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TabBoxDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TabBoxTrackballDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TabBoxTrackballDragger.cpp new file mode 100644 index 000000000..c462f0338 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TabBoxTrackballDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TabBoxTrackballDragger, + new osgManipulator::TabBoxTrackballDragger, + osgManipulator::TabBoxTrackballDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TabBoxTrackballDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TabPlaneDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TabPlaneDragger.cpp new file mode 100644 index 000000000..1a1e9f424 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TabPlaneDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TabPlaneDragger, + new osgManipulator::TabPlaneDragger, + osgManipulator::TabPlaneDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TabPlaneDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TabPlaneTrackballDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TabPlaneTrackballDragger.cpp new file mode 100644 index 000000000..8ce24529e --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TabPlaneTrackballDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TabPlaneTrackballDragger, + new osgManipulator::TabPlaneTrackballDragger, + osgManipulator::TabPlaneTrackballDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TabPlaneTrackballDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TrackballDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TrackballDragger.cpp new file mode 100644 index 000000000..e8a5e7dd0 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TrackballDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TrackballDragger, + new osgManipulator::TrackballDragger, + osgManipulator::TrackballDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TrackballDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/Translate1DDragger.cpp b/src/osgWrappers/serializers/osgManipulator/Translate1DDragger.cpp new file mode 100644 index 000000000..21fd7bc61 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/Translate1DDragger.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_Translate1DDragger, + new osgManipulator::Translate1DDragger, + osgManipulator::Translate1DDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::Translate1DDragger" ) +{ + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor +} diff --git a/src/osgWrappers/serializers/osgManipulator/Translate2DDragger.cpp b/src/osgWrappers/serializers/osgManipulator/Translate2DDragger.cpp new file mode 100644 index 000000000..fba06595d --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/Translate2DDragger.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_Translate2DDragger, + new osgManipulator::Translate2DDragger, + osgManipulator::Translate2DDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::Translate2DDragger" ) +{ + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color + ADD_VEC4_SERIALIZER( PickColor, osg::Vec4() ); // _pickColor +} diff --git a/src/osgWrappers/serializers/osgManipulator/TranslateAxisDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TranslateAxisDragger.cpp new file mode 100644 index 000000000..1dc1e9508 --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TranslateAxisDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TranslateAxisDragger, + new osgManipulator::TranslateAxisDragger, + osgManipulator::TranslateAxisDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TranslateAxisDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgManipulator/TranslatePlaneDragger.cpp b/src/osgWrappers/serializers/osgManipulator/TranslatePlaneDragger.cpp new file mode 100644 index 000000000..54528560d --- /dev/null +++ b/src/osgWrappers/serializers/osgManipulator/TranslatePlaneDragger.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgManipulator_TranslatePlaneDragger, + new osgManipulator::TranslatePlaneDragger, + osgManipulator::TranslatePlaneDragger, + "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger " + "osgManipulator::TranslatePlaneDragger" ) // No need to contain CompositeDragger here +{ +} diff --git a/src/osgWrappers/serializers/osgTerrain/Terrain.cpp b/src/osgWrappers/serializers/osgTerrain/Terrain.cpp index 8dbfb9d92..735311eb7 100644 --- a/src/osgWrappers/serializers/osgTerrain/Terrain.cpp +++ b/src/osgWrappers/serializers/osgTerrain/Terrain.cpp @@ -6,7 +6,7 @@ REGISTER_OBJECT_WRAPPER( osgTerrain_Terrain, new osgTerrain::Terrain, osgTerrain::Terrain, - "osg::Object osg::Node osg::CoordinateSystemNode osgTerrain::Terrain" ) + "osg::Object osg::Node osg::Group osg::CoordinateSystemNode osgTerrain::Terrain" ) { ADD_FLOAT_SERIALIZER( SampleRatio, 1.0f ); // _sampleRatio ADD_FLOAT_SERIALIZER( VerticalScale, 1.0f ); // _verticalScale