osgarchive is a utility program that creates and reads database archives. These archives can then be used at runtime with standard OSG applications such as osgviewer.
Quick step by step guide on using osgarchive.
Creating a new archive
To create an archive you have to specify the archive filename, including extension, via the -a <filename> switch, and the insert 3d database and imagery files into the archive vie the -i <filename> [ <filename> ..] syntax such as:
osgarchive -a archive.osga -i cow.osg glider.osg
You may also insert the contents of whole directories using the same syntanx.
osgarchive -a archive.osga -i mydirectory
The .osga format also has support for a master file, which is set to the first file inserted into the archive.
Listing files contained in the archive
To list all the files contained specify the archive, then use the -l switch:
osgarchive -a archive.osga -l
This will print out the list of files contained within the archive.
Extracting files from an archive
To extract files from the archive specify the archive, then use the -e <filename> [<filename>...] syntanx:
osgarchive -a archive.osga -e cow.osg
Using archives in other OpenSceneGraph applications
Archive files can be read just like normal OSG files, with the file extraction happening transparently with osgDB. To load the archive's master file simple load the archive itself:
Or to load a specific file within the archive:
osg::ref_ptr<osg::Node> masterNode = osgDB::readNodeFile("archive.osga"); osg::ref_ptr<osg::Node> gliderNode = osgDB::readNodeFile("archive.osga/glider.osg");
Generating archives for paged databases from osgdem
The osgdem utility program also has support for generating .osga archives, simply by specify -a <filename> its possible to put all osgdem generated tiles into a single archive file.
File formats that are support by archiving
The OpenSceneGraph mechanism for archive support uses istream and ostreams for streaming data in and out of the archive, and not all 3d database and image file formats supported by the OpenSceneGraph also support istream and ostreams. Follows are is a list of formats that are currently supported:
- .osg OpenSceneGraph native ascii format
- .ive OpenSceneGraph native binary format
- .dds DirectDrawSurface image file format
- .jp2 JPEG2000 imagery file format