From Paul Martz, "The attached preserves OpenFlight Object record data as UserData in the osg::Group corresponding to the Object record.

The files are:
    include/osgSim/ObjectRecordData -- The new class. Derives from Object to support .osg IO.
    src/osgPlugins/OpenFlight/PrimaryRecords.cpp -- Reads data into that class.
    src/osgPlugins/osgSim/IO_ObjectRecordData.cpp -- .osg IO support."

From Robert Osfield, made the OpenFlight read object record data optional via the -O readObjectRecordData ReaderWriter option.
This commit is contained in:
Robert Osfield 2008-03-13 14:09:11 +00:00
parent 3a11483ba8
commit e19dbe8daa
5 changed files with 37 additions and 14 deletions

View File

@ -30,6 +30,7 @@ Document::Document() :
_useTextureAlphaForTransparancyBinning(true), _useTextureAlphaForTransparancyBinning(true),
_useBillboardCenter(false), _useBillboardCenter(false),
_doUnitsConversion(true), _doUnitsConversion(true),
_readObjectRecordData(false),
_desiredUnits(METERS), _desiredUnits(METERS),
_done(false), _done(false),
_level(0), _level(0),

View File

@ -185,8 +185,11 @@ class Document
void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; } void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; }
CoordUnits getDesiredUnits() const { return _desiredUnits; } CoordUnits getDesiredUnits() const { return _desiredUnits; }
bool getKeepExternalReferences() const { return _keepExternalReferences; }
void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; } void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; }
bool getKeepExternalReferences() const { return _keepExternalReferences; }
void setReadObjectRecordData(bool flag) { _readObjectRecordData = flag; }
bool getReadObjectRecordData() const { return _readObjectRecordData; }
protected: protected:
@ -199,6 +202,7 @@ class Document
bool _useTextureAlphaForTransparancyBinning; bool _useTextureAlphaForTransparancyBinning;
bool _useBillboardCenter; bool _useBillboardCenter;
bool _doUnitsConversion; bool _doUnitsConversion;
bool _readObjectRecordData;
CoordUnits _desiredUnits; CoordUnits _desiredUnits;
bool _keepExternalReferences; bool _keepExternalReferences;

View File

@ -30,6 +30,7 @@
#include <osgSim/DOFTransform> #include <osgSim/DOFTransform>
#include <osgSim/MultiSwitch> #include <osgSim/MultiSwitch>
#include <osgSim/GeographicLocation> #include <osgSim/GeographicLocation>
#include <osgSim/ObjectRecordData>
#include "Registry.h" #include "Registry.h"
#include "Document.h" #include "Document.h"
#include "RecordInputStream.h" #include "RecordInputStream.h"
@ -861,11 +862,27 @@ protected:
virtual void readRecord(RecordInputStream& in, Document& document) virtual void readRecord(RecordInputStream& in, Document& document)
{ {
std::string id = in.readString(8); std::string id = in.readString(8);
/*uint32 flags =*/ in.readUInt32();
_object = new osg::Group; _object = new osg::Group;
_object->setName(id); _object->setName(id);
if (document.getReadObjectRecordData())
{
osgSim::ObjectRecordData* ord = new osgSim::ObjectRecordData;
ord->_flags = in.readUInt32();
ord->_relativePriority = in.readInt16();
ord->_transparency = in.readUInt16();
ord->_effectID1 = in.readInt16();
ord->_effectID2 = in.readInt16();
ord->_significance = in.readInt16();
_object->setUserData( ord );
}
else
{
/*uint32 flags =*/ in.readUInt32();
}
// Postpone add-to-parent until we know a bit more. // Postpone add-to-parent until we know a bit more.
} }

View File

@ -203,6 +203,9 @@ class FLTReaderWriter : public ReaderWriter
document.setUseTextureAlphaForTransparancyBinning(options->getOptionString().find("noTextureAlphaForTransparancyBinning")==std::string::npos); document.setUseTextureAlphaForTransparancyBinning(options->getOptionString().find("noTextureAlphaForTransparancyBinning")==std::string::npos);
osg::notify(osg::DEBUG_INFO) << readerMsg << "noTextureAlphaForTransparancyBinning=" << !document.getUseTextureAlphaForTransparancyBinning() << std::endl; osg::notify(osg::DEBUG_INFO) << readerMsg << "noTextureAlphaForTransparancyBinning=" << !document.getUseTextureAlphaForTransparancyBinning() << std::endl;
document.setReadObjectRecordData(options->getOptionString().find("readObjectRecordData")==std::string::npos);
osg::notify(osg::DEBUG_INFO) << readerMsg << "readObjectRecordData=" << !document.getReadObjectRecordData() << std::endl;
document.setDoUnitsConversion((options->getOptionString().find("noUnitsConversion")==std::string::npos)); // default to true, unless noUnitsConversion is specified. document.setDoUnitsConversion((options->getOptionString().find("noUnitsConversion")==std::string::npos)); // default to true, unless noUnitsConversion is specified.
osg::notify(osg::DEBUG_INFO) << readerMsg << "noUnitsConversion=" << !document.getDoUnitsConversion() << std::endl; osg::notify(osg::DEBUG_INFO) << readerMsg << "noUnitsConversion=" << !document.getDoUnitsConversion() << std::endl;

View File

@ -1,6 +1,3 @@
#this file is automatically generated
SET(TARGET_SRC SET(TARGET_SRC
IO_ShapeAttribute.cpp IO_ShapeAttribute.cpp
IO_BlinkSequence.cpp IO_BlinkSequence.cpp
@ -11,6 +8,7 @@ IO_LightPointNode.cpp
IO_MultiSwitch.cpp IO_MultiSwitch.cpp
IO_Sector.cpp IO_Sector.cpp
IO_VisibilityGroup.cpp IO_VisibilityGroup.cpp
IO_ObjectRecordData.cpp
) )
SET(TARGET_H IO_LightPoint.h ) SET(TARGET_H IO_LightPoint.h )
SET(TARGET_ADDED_LIBRARIES osgSim ) SET(TARGET_ADDED_LIBRARIES osgSim )