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."
This commit is contained in:
Robert Osfield
2010-04-28 20:16:44 +00:00
parent 22dfe6f8d1
commit 0adf26ec6e
28 changed files with 398 additions and 20 deletions

View File

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

View File

@@ -0,0 +1,13 @@
#include <osgManipulator/AntiSquish>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
}

View File

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

View File

@@ -0,0 +1,42 @@
#include <osgManipulator/Dragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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<size; ++i )
{
osgManipulator::Dragger* child = dynamic_cast<osgManipulator::Dragger*>( 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<size; ++i )
{
os << dragger.getDragger(i);
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgManipulator_CompositeDragger,
/*new osgManipulator::CompositeDragger*/NULL,
osgManipulator::CompositeDragger,
"osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger "
"osgManipulator::CompositeDragger" )
{
ADD_USER_SERIALIZER( Draggers ); // _draggerList
}

View File

@@ -0,0 +1,84 @@
#include <osgManipulator/Constraint>
#include <osgManipulator/Dragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
// 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<size; ++i )
{
std::string name; is >> name >> osgDB::BEGIN_BRACKET;
if ( name=="DraggerTransformCallback" )
{
osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>( 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<osgManipulator::DraggerTransformCallback*>( 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 );
}

View File

@@ -0,0 +1,14 @@
#include <osgManipulator/RotateCylinderDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
}

View File

@@ -0,0 +1,14 @@
#include <osgManipulator/RotateSphereDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
}

View File

@@ -0,0 +1,33 @@
#include <osgManipulator/Scale1DDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#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<osg::Node*>( 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 );
}

View File

@@ -0,0 +1,39 @@
#include <osgManipulator/Scale2DDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#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<osg::Node*>( 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() );
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/ScaleAxisDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TabBoxDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TabBoxTrackballDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TabPlaneDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TabPlaneTrackballDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TrackballDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,14 @@
#include <osgManipulator/Translate1DDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
}

View File

@@ -0,0 +1,14 @@
#include <osgManipulator/Translate2DDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TranslateAxisDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

@@ -0,0 +1,12 @@
#include <osgManipulator/TranslatePlaneDragger>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
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
{
}

View File

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