diff --git a/src/osgWrappers/serializers/CMakeLists.txt b/src/osgWrappers/serializers/CMakeLists.txt index 941529386..11fccdd75 100644 --- a/src/osgWrappers/serializers/CMakeLists.txt +++ b/src/osgWrappers/serializers/CMakeLists.txt @@ -44,6 +44,7 @@ ADD_SUBDIRECTORY(osgManipulator) ADD_SUBDIRECTORY(osgParticle) ADD_SUBDIRECTORY(osgSim) ADD_SUBDIRECTORY(osgShadow) +ADD_SUBDIRECTORY(osgGA) ADD_SUBDIRECTORY(osgTerrain) ADD_SUBDIRECTORY(osgText) ADD_SUBDIRECTORY(osgVolume) diff --git a/src/osgWrappers/serializers/osgGA/AnimationPathManipulator.cpp b/src/osgWrappers/serializers/osgGA/AnimationPathManipulator.cpp new file mode 100644 index 000000000..be4bf93d5 --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/AnimationPathManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_AnimationPathManipulator, + new osgGA::AnimationPathManipulator, + osgGA::AnimationPathManipulator, + "osg::Object osgGA::AnimationPathManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/CMakeLists.txt b/src/osgWrappers/serializers/osgGA/CMakeLists.txt new file mode 100644 index 000000000..ac118865d --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB TARGET_SRC *.cpp) +FILE(GLOB TARGET_H *.h) + +SET(TARGET_ADDED_LIBRARIES osgGA ) + +#### end var setup ### +SETUP_PLUGIN(osgga) diff --git a/src/osgWrappers/serializers/osgGA/DriveManipulator.cpp b/src/osgWrappers/serializers/osgGA/DriveManipulator.cpp new file mode 100644 index 000000000..2700988cb --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/DriveManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_DriveManipulator, + new osgGA::DriveManipulator, + osgGA::DriveManipulator, + "osg::Object osgGA::DriveManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/FlightManipulator.cpp b/src/osgWrappers/serializers/osgGA/FlightManipulator.cpp new file mode 100644 index 000000000..94493a49c --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/FlightManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_FlightManipulator, + new osgGA::FlightManipulator, + osgGA::FlightManipulator, + "osg::Object osgGA::FlightManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/GUIEventAdapter.cpp b/src/osgWrappers/serializers/osgGA/GUIEventAdapter.cpp new file mode 100644 index 000000000..dfe61b042 --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/GUIEventAdapter.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_GUIEventAdapter, + new osgGA::GUIEventAdapter, + osgGA::GUIEventAdapter, + "osg::Object osgGA::GUIEventAdapter" ) +{ + ADD_DOUBLE_SERIALIZER( Time, 0.0 ); + + BEGIN_ENUM_SERIALIZER( EventType, NONE ); + ADD_ENUM_VALUE( NONE ); + ADD_ENUM_VALUE( PUSH ); + ADD_ENUM_VALUE( RELEASE ); + ADD_ENUM_VALUE( DOUBLECLICK ); + ADD_ENUM_VALUE( DRAG ); + ADD_ENUM_VALUE( MOVE ); + ADD_ENUM_VALUE( KEYDOWN ); + ADD_ENUM_VALUE( KEYUP ); + ADD_ENUM_VALUE( FRAME ); + ADD_ENUM_VALUE( RESIZE ); + ADD_ENUM_VALUE( SCROLL ); + ADD_ENUM_VALUE( PEN_PRESSURE ); + ADD_ENUM_VALUE( PEN_ORIENTATION ); + ADD_ENUM_VALUE( PEN_PROXIMITY_ENTER ); + ADD_ENUM_VALUE( PEN_PROXIMITY_LEAVE ); + ADD_ENUM_VALUE( CLOSE_WINDOW ); + ADD_ENUM_VALUE( QUIT_APPLICATION ); + ADD_ENUM_VALUE( USER ); + END_ENUM_SERIALIZER(); + + ADD_INT_SERIALIZER( Key, 0 ); + ADD_INT_SERIALIZER( UnmodifiedKey, 0 ); + ADD_INT_SERIALIZER( ModKeyMask, 0 ) ; + + BEGIN_ENUM_SERIALIZER( MouseYOrientation, Y_INCREASING_DOWNWARDS ); + ADD_ENUM_VALUE( Y_INCREASING_UPWARDS ); + ADD_ENUM_VALUE( Y_INCREASING_DOWNWARDS ); + END_ENUM_SERIALIZER(); + + ADD_FLOAT_SERIALIZER( Xmin, -1.0f ); + ADD_FLOAT_SERIALIZER( Xmax, 1.0f ); + ADD_FLOAT_SERIALIZER( Ymin, -1.0f ); + ADD_FLOAT_SERIALIZER( Ymax, 1.0f ); + + ADD_FLOAT_SERIALIZER( X, 0.0f ); + ADD_FLOAT_SERIALIZER( Y, 0.0f ); + ADD_INT_SERIALIZER( Button, 0 ); + ADD_INT_SERIALIZER( ButtonMask, 0 ); + + BEGIN_ENUM_SERIALIZER( ScrollingMotion, SCROLL_NONE); + ADD_ENUM_VALUE( SCROLL_NONE ); + ADD_ENUM_VALUE( SCROLL_LEFT ); + ADD_ENUM_VALUE( SCROLL_RIGHT ); + ADD_ENUM_VALUE( SCROLL_UP ); + ADD_ENUM_VALUE( SCROLL_DOWN ); + ADD_ENUM_VALUE( SCROLL_2D ); + END_ENUM_SERIALIZER(); + + ADD_FLOAT_SERIALIZER( ScrollingDeltaX, 0.0f); + ADD_FLOAT_SERIALIZER( ScrollingDeltaY, 0.0f); + +} diff --git a/src/osgWrappers/serializers/osgGA/KeySwitchMatrixManipulator.cpp b/src/osgWrappers/serializers/osgGA/KeySwitchMatrixManipulator.cpp new file mode 100644 index 000000000..b86ad491e --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/KeySwitchMatrixManipulator.cpp @@ -0,0 +1,75 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +static bool checkKeyManipMap( const osgGA::KeySwitchMatrixManipulator& kwmm ) +{ + return !kwmm.getKeyManipMap().empty(); +} + +static bool readKeyManipMap( osgDB::InputStream& is, osgGA::KeySwitchMatrixManipulator& kwmm ) +{ + int activeCameraManipulatorIndex = -1; is>>activeCameraManipulatorIndex; + unsigned int size = 0; is >> size >> is.BEGIN_BRACKET; + for ( unsigned int i=0; i> key; + std::string name; is >> name; + + osg::ref_ptr obj = is.readObject(); + osgGA::CameraManipulator* child = dynamic_cast( obj.get() ); + if ( child ) kwmm.addMatrixManipulator( key, name, child ); + } + + if (activeCameraManipulatorIndex>=0) kwmm.selectMatrixManipulator(activeCameraManipulatorIndex); + + return true; +} + +static bool writeKeyManipMap( osgDB::OutputStream& os, const osgGA::KeySwitchMatrixManipulator& kwmm ) +{ + const osgGA::KeySwitchMatrixManipulator::KeyManipMap& kmm = kwmm.getKeyManipMap(); + unsigned int size = kmm.size(); + + // find out what num the acive camera manipulator is + const osgGA::CameraManipulator* cm = kwmm.getCurrentMatrixManipulator(); + int index = 0; + int activeCameraManipulatorIndex = -1; + for ( osgGA::KeySwitchMatrixManipulator::KeyManipMap::const_iterator itr = kmm.begin(); + itr != kmm.end(); + ++itr, ++index) + { + if (itr->second.second==cm) + { + activeCameraManipulatorIndex = index; + break; + } + } + + os << activeCameraManipulatorIndex; + os << size << os.BEGIN_BRACKET << std::endl; + + for ( osgGA::KeySwitchMatrixManipulator::KeyManipMap::const_iterator itr = kmm.begin(); + itr != kmm.end(); + ++itr) + { + os << itr->first; + os << itr->second.first; + os.writeObject(itr->second.second.get()); + } + os << os.END_BRACKET << std::endl; + + return true; +} + +REGISTER_OBJECT_WRAPPER( osgGA_KeySwitchMatrixManipulator, + new osgGA::KeySwitchMatrixManipulator, + osgGA::KeySwitchMatrixManipulator, + "osg::Object osgGA::KeySwitchMatrixManipulator" ) +{ + ADD_USER_SERIALIZER( KeyManipMap ); // _children +} diff --git a/src/osgWrappers/serializers/osgGA/MultiTouchTrackballManipulator.cpp b/src/osgWrappers/serializers/osgGA/MultiTouchTrackballManipulator.cpp new file mode 100644 index 000000000..59e1a61fa --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/MultiTouchTrackballManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_MultiTouchTrackballManipulator, + new osgGA::MultiTouchTrackballManipulator, + osgGA::MultiTouchTrackballManipulator, + "osg::Object osgGA::MultiTouchTrackballManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/StateSetManipulator.cpp b/src/osgWrappers/serializers/osgGA/StateSetManipulator.cpp new file mode 100644 index 000000000..c084fa063 --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/StateSetManipulator.cpp @@ -0,0 +1,18 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_StateSetManipulator, + new osgGA::StateSetManipulator, + osgGA::StateSetManipulator, + "osg::Object osgGA::StateSetManipulator" ) +{ + ADD_INT_SERIALIZER(KeyEventToggleBackfaceCulling, 'b'); + ADD_INT_SERIALIZER(KeyEventToggleLighting, 'l'); + ADD_INT_SERIALIZER(KeyEventToggleTexturing, 't'); + ADD_INT_SERIALIZER(KeyEventCyclePolygonMode, 'w'); +} diff --git a/src/osgWrappers/serializers/osgGA/TerrainManipulator.cpp b/src/osgWrappers/serializers/osgGA/TerrainManipulator.cpp new file mode 100644 index 000000000..0a9cdfab6 --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/TerrainManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_TerrainManipulator, + new osgGA::TerrainManipulator, + osgGA::TerrainManipulator, + "osg::Object osgGA::TerrainManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/TouchData.cpp b/src/osgWrappers/serializers/osgGA/TouchData.cpp new file mode 100644 index 000000000..0092429bf --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/TouchData.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_TouchData, + new osgGA::GUIEventAdapter::TouchData, + osgGA::GUIEventAdapter::TouchData, + "osg::Object osgGA::TouchData" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/TrackballManipulator.cpp b/src/osgWrappers/serializers/osgGA/TrackballManipulator.cpp new file mode 100644 index 000000000..299b92656 --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/TrackballManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_TrackballManipulator, + new osgGA::TrackballManipulator, + osgGA::TrackballManipulator, + "osg::Object osgGA::TrackballManipulator" ) +{ +} diff --git a/src/osgWrappers/serializers/osgGA/UFOManipulator.cpp b/src/osgWrappers/serializers/osgGA/UFOManipulator.cpp new file mode 100644 index 000000000..95abbe68c --- /dev/null +++ b/src/osgWrappers/serializers/osgGA/UFOManipulator.cpp @@ -0,0 +1,14 @@ +#include + +#define OBJECT_CAST dynamic_cast + +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgGA_UFOManipulator, + new osgGA::UFOManipulator, + osgGA::UFOManipulator, + "osg::Object osgGA::UFOManipulator" ) +{ +}