From Wang Rui, "I've initially added the XML support of the new native osg format,
using osgDB::XmlParser. The extension for XML-formatted scenes is .osgx, corresponding to .osgb for binary and .osgt for ascii. It could either be rendered in osgviewer or edited by common web browsers and xml editors because of a range of changes to fit the XML syntax. For example, the recorded class names are slight modified, from 'osg::Geode' to 'osg--Geode'. To quickly get an XML file: # ./osgconv cow.osg cow.osgx The StreamOperator header, InputStreram and OutputStream classes are modified to be more portable for triple ascii/binary/XML formats. I also fixed a bug in readImage()/writeImage() to share image objects if needed. The ReaderWriterOSG2 class now supports all three formats and reading/writing scene objects (not nodes or images), thanks to Torben's advice before. "
This commit is contained in:
@@ -61,7 +61,8 @@ public:
|
||||
{
|
||||
READ_UNKNOWN = 0,
|
||||
READ_SCENE,
|
||||
READ_IMAGE
|
||||
READ_IMAGE,
|
||||
READ_OBJECT
|
||||
};
|
||||
|
||||
InputStream( const osgDB::Options* options );
|
||||
@@ -123,9 +124,9 @@ public:
|
||||
{ ptr = static_cast<T*>(readObject()); return *this; }
|
||||
|
||||
// Convenient methods for reading
|
||||
bool matchString( const std::string& str );
|
||||
void advanceToCurrentEndBracket();
|
||||
void readWrappedString( std::string& str );
|
||||
bool matchString( const std::string& str ) { return _in->matchString(str); }
|
||||
void advanceToCurrentEndBracket() { _in->advanceToCurrentEndBracket(); }
|
||||
void readWrappedString( std::string& str ) { _in->readWrappedString(str); checkStream(); }
|
||||
void readCharArray( char* s, unsigned int size ) { _in->readCharArray(s, size); }
|
||||
|
||||
// readSize() use unsigned int for all sizes.
|
||||
|
||||
@@ -60,7 +60,8 @@ public:
|
||||
{
|
||||
WRITE_UNKNOWN = 0,
|
||||
WRITE_SCENE,
|
||||
WRITE_IMAGE
|
||||
WRITE_IMAGE,
|
||||
WRITE_OBJECT
|
||||
};
|
||||
|
||||
enum WriteImageHint
|
||||
@@ -133,7 +134,7 @@ public:
|
||||
{ writeObject(ptr.get()); return *this; }
|
||||
|
||||
// Convenient methods for writing
|
||||
void writeWrappedString( const std::string& str );
|
||||
void writeWrappedString( const std::string& str ) { _out->writeWrappedString(str); }
|
||||
void writeCharArray( const char* s, unsigned int size ) { _out->writeCharArray(s, size); }
|
||||
|
||||
// method for converting all data structure sizes to unsigned int to ensure architecture portability.
|
||||
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
virtual void writeProperty( const ObjectProperty& prop ) = 0;
|
||||
virtual void writeMark( const ObjectMark& mark ) = 0;
|
||||
virtual void writeCharArray( const char* s, unsigned int size ) = 0;
|
||||
virtual void writeWrappedString( const std::string& str ) = 0;
|
||||
|
||||
virtual void flush() { _out->flush(); }
|
||||
|
||||
protected:
|
||||
std::ostream* _out;
|
||||
@@ -79,6 +82,10 @@ public:
|
||||
virtual void readProperty( ObjectProperty& prop ) = 0;
|
||||
virtual void readMark( ObjectMark& mark ) = 0;
|
||||
virtual void readCharArray( char* s, unsigned int size ) = 0;
|
||||
virtual void readWrappedString( std::string& str ) = 0;
|
||||
|
||||
virtual bool matchString( const std::string& str ) { return false; }
|
||||
virtual void advanceToCurrentEndBracket() {}
|
||||
|
||||
protected:
|
||||
std::istream* _in;
|
||||
|
||||
Reference in New Issue
Block a user