Removed osg::GeoSet for core osg lib and osgPlugin.
Commented out OpenDX plugin as its still based on GeoSet. Added support for loading and converting GeoSet into the osgconv example.
This commit is contained in:
@@ -37,9 +37,9 @@ class CameraPacket {
|
||||
public:
|
||||
|
||||
CameraPacket():_masterKilled(false)
|
||||
{
|
||||
_byte_order = 0x12345678;
|
||||
}
|
||||
{
|
||||
_byte_order = 0x12345678;
|
||||
}
|
||||
|
||||
void setPacket(const osg::Matrix& matrix,const osg::FrameStamp* frameStamp)
|
||||
{
|
||||
@@ -56,24 +56,24 @@ class CameraPacket {
|
||||
matrix = _matrix * osg::Matrix::rotate(angle_offset,0.0f,1.0f,0.0f);
|
||||
}
|
||||
|
||||
void checkByteOrder( void )
|
||||
{
|
||||
if( _byte_order == 0x78563412 ) // We're backwards
|
||||
{
|
||||
swapBytes( _byte_order );
|
||||
swapBytes( _masterKilled );
|
||||
for( int i = 0; i < 16; i++ )
|
||||
swapBytes( _matrix.ptr()[i] );
|
||||
void checkByteOrder( void )
|
||||
{
|
||||
if( _byte_order == 0x78563412 ) // We're backwards
|
||||
{
|
||||
swapBytes( _byte_order );
|
||||
swapBytes( _masterKilled );
|
||||
for( int i = 0; i < 16; i++ )
|
||||
swapBytes( _matrix.ptr()[i] );
|
||||
|
||||
// umm.. we should byte swap _frameStamp too...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setMasterKilled(const bool flag) { _masterKilled = flag; }
|
||||
const bool getMasterKilled() const { return _masterKilled; }
|
||||
|
||||
unsigned long _byte_order;
|
||||
unsigned long _byte_order;
|
||||
bool _masterKilled;
|
||||
osg::Matrix _matrix;
|
||||
|
||||
@@ -170,11 +170,13 @@ int main( int argc, char **argv )
|
||||
// objects for managing the broadcasting and recieving of camera packets.
|
||||
Broadcaster bc;
|
||||
Receiver rc;
|
||||
|
||||
bc.setPort(socketNumber);
|
||||
rc.setPort(socketNumber);
|
||||
|
||||
while( !viewer.done() )
|
||||
bc.setPort(static_cast<short int>(socketNumber));
|
||||
rc.setPort(static_cast<short int>(socketNumber));
|
||||
|
||||
bool masterKilled = false;
|
||||
|
||||
while( !viewer.done() && !masterKilled )
|
||||
{
|
||||
// wait for all cull and draw threads to complete.
|
||||
viewer.sync();
|
||||
@@ -197,7 +199,7 @@ int main( int argc, char **argv )
|
||||
cp.setPacket(modelview,viewer.getFrameStamp());
|
||||
|
||||
bc.setBuffer(&cp, sizeof( CameraPacket ));
|
||||
bc.sync();
|
||||
bc.sync();
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -206,9 +208,10 @@ int main( int argc, char **argv )
|
||||
CameraPacket cp;
|
||||
|
||||
rc.setBuffer(&cp, sizeof( CameraPacket ));
|
||||
rc.sync();
|
||||
|
||||
cp.checkByteOrder();
|
||||
rc.sync();
|
||||
|
||||
cp.checkByteOrder();
|
||||
|
||||
osg::Matrix modelview;
|
||||
cp.getModelView(modelview,camera_offset);
|
||||
@@ -217,9 +220,9 @@ int main( int argc, char **argv )
|
||||
|
||||
if (cp.getMasterKilled())
|
||||
{
|
||||
std::cout << "recieved master killed"<<std::endl;
|
||||
std::cout << "received master killed"<<std::endl;
|
||||
// break out of while (!done) loop since we've now want to shut down.
|
||||
break;
|
||||
masterKilled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -229,10 +232,11 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
// fire off the cull and draw traversals of the scene.
|
||||
viewer.frame();
|
||||
if(!masterKilled)
|
||||
viewer.frame();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// wait for all cull and draw threads to complete before exit.
|
||||
viewer.sync();
|
||||
|
||||
@@ -245,7 +249,7 @@ int main( int argc, char **argv )
|
||||
cp.setMasterKilled(true);
|
||||
|
||||
bc.setBuffer(&cp, sizeof( CameraPacket ));
|
||||
bc.sync();
|
||||
bc.sync();
|
||||
|
||||
std::cout << "broadcasting death"<<std::endl;
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
GeoSet.cpp\
|
||||
IO_GeoSet.cpp\
|
||||
OrientationConverter.cpp\
|
||||
osgconv.cpp\
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
@@ -9,11 +10,48 @@
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include "OrientationConverter.h"
|
||||
#include "GeoSet.h"
|
||||
|
||||
typedef std::vector<std::string> FileNameList;
|
||||
|
||||
static bool do_convert = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Convert GeoSet To Geometry Visitor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** ConvertGeoSetsToGeometryVisitor all the old GeoSet Drawables to the new Geometry Drawables.*/
|
||||
class ConvertGeoSetsToGeometryVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
ConvertGeoSetsToGeometryVisitor():osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
|
||||
|
||||
virtual void apply(osg::Geode& geode)
|
||||
{
|
||||
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
||||
{
|
||||
osg::GeoSet* geoset = dynamic_cast<osg::GeoSet*>(geode.getDrawable(i));
|
||||
if (geoset)
|
||||
{
|
||||
osg::Geometry* geom = geoset->convertToGeometry();
|
||||
if (geom)
|
||||
{
|
||||
std::cout<<"Successfully converted GeoSet to Geometry"<<std::endl;
|
||||
geode.replaceDrawable(geoset,geom);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"*** Failed to convert GeoSet to Geometry"<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void apply(osg::Node& node) { traverse(node); }
|
||||
|
||||
};
|
||||
|
||||
static void usage( const char *prog, const char *msg )
|
||||
{
|
||||
@@ -231,6 +269,11 @@ int main( int argc, char **argv )
|
||||
|
||||
osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles(fileNames);
|
||||
|
||||
// convert the old style GeoSet to Geometry
|
||||
ConvertGeoSetsToGeometryVisitor cgtg;
|
||||
root->accept(cgtg);
|
||||
|
||||
|
||||
if( do_convert )
|
||||
root = oc.convert( root.get() );
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ button accelerates, the right mouse button decelerates, and the middle mouse
|
||||
button (or left and right simultaneously) stops dead.
|
||||
*/
|
||||
|
||||
class OSGGA_EXPORT GliderManipulator : public osgGA::MatrixManipulator
|
||||
class GliderManipulator : public osgGA::MatrixManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user