Added serializers for osgGA

This commit is contained in:
Robert Osfield
2012-10-12 14:51:08 +00:00
parent ad926d7265
commit 1872137d88
13 changed files with 275 additions and 0 deletions

View File

@@ -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)

View File

@@ -0,0 +1,14 @@
#include <osgGA/AnimationPathManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_AnimationPathManipulator,
new osgGA::AnimationPathManipulator,
osgGA::AnimationPathManipulator,
"osg::Object osgGA::AnimationPathManipulator" )
{
}

View File

@@ -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)

View File

@@ -0,0 +1,14 @@
#include <osgGA/DriveManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_DriveManipulator,
new osgGA::DriveManipulator,
osgGA::DriveManipulator,
"osg::Object osgGA::DriveManipulator" )
{
}

View File

@@ -0,0 +1,14 @@
#include <osgGA/FlightManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_FlightManipulator,
new osgGA::FlightManipulator,
osgGA::FlightManipulator,
"osg::Object osgGA::FlightManipulator" )
{
}

View File

@@ -0,0 +1,65 @@
#include <osgGA/GUIEventAdapter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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);
}

View File

@@ -0,0 +1,75 @@
#include <osgGA/KeySwitchMatrixManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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<size; ++i )
{
int key; is >> key;
std::string name; is >> name;
osg::ref_ptr<osg::Object> obj = is.readObject();
osgGA::CameraManipulator* child = dynamic_cast<osgGA::CameraManipulator*>( 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
}

View File

@@ -0,0 +1,14 @@
#include <osgGA/MultiTouchTrackballManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_MultiTouchTrackballManipulator,
new osgGA::MultiTouchTrackballManipulator,
osgGA::MultiTouchTrackballManipulator,
"osg::Object osgGA::MultiTouchTrackballManipulator" )
{
}

View File

@@ -0,0 +1,18 @@
#include <osgGA/StateSetManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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');
}

View File

@@ -0,0 +1,14 @@
#include <osgGA/TerrainManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_TerrainManipulator,
new osgGA::TerrainManipulator,
osgGA::TerrainManipulator,
"osg::Object osgGA::TerrainManipulator" )
{
}

View File

@@ -0,0 +1,11 @@
#include <osgGA/GUIEventAdapter>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_TouchData,
new osgGA::GUIEventAdapter::TouchData,
osgGA::GUIEventAdapter::TouchData,
"osg::Object osgGA::TouchData" )
{
}

View File

@@ -0,0 +1,14 @@
#include <osgGA/TrackballManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_TrackballManipulator,
new osgGA::TrackballManipulator,
osgGA::TrackballManipulator,
"osg::Object osgGA::TrackballManipulator" )
{
}

View File

@@ -0,0 +1,14 @@
#include <osgGA/UFOManipulator>
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( osgGA_UFOManipulator,
new osgGA::UFOManipulator,
osgGA::UFOManipulator,
"osg::Object osgGA::UFOManipulator" )
{
}