From Joson Daly, fix for forward/backward/swing animation handling both 15.8 and

versions prior to 15.8, and...

" Here's another fix for OpenFlight.  The symptom was that ATTR files were
not being read correctly, and the TexEnv on a texture that should have
been set to DECAL was instead defaulting to MODULATE.  The cause is that
the ATTR reader cannot tell by itself what version it's reading (the
version information isn't present in the ATTR files), and instead relies
on the ReaderWriter::Options passed in to get the OpenFlight version.

My change clones the current ReaderWriter::Options and prepends the
appropriate FLT_VER option before the ReaderWriterATTR object is
called.  I also made the parsing of the FLT_VER string and value more
robust in the ReaderWriterATTR itself.  I think I commented things OK,
but let me know if you need me to explain anything."
This commit is contained in:
Robert Osfield
2005-04-14 07:55:45 +00:00
parent d6d764a729
commit 6b86d2d70d
2 changed files with 78 additions and 17 deletions

View File

@@ -42,6 +42,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include "AttrData.h"
@@ -757,17 +758,29 @@ class ReaderWriterATTR : public osgDB::ReaderWriter
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
// options
char buf[256];
int version=0;
int version;
const osgDB::ReaderWriter::Options* rwOptions=
osgDB::Registry::instance()->getOptions();
if (rwOptions)
// Check the options string for the OpenFlight file version
if (options)
{
sscanf(rwOptions->getOptionString().c_str(),"%s %d", buf, &version);
if (strcmp(buf, "FLT_VER")) version=0;
// Get the character index of the FLT_VER option in the option
// string
uint optionIndex = options->getOptionString().find("FLT_VER");
// Default to zero for the version if it's not found
if (optionIndex == std::string::npos)
version = 0;
else
{
// Copy the option string, starting with the F in FLT_VER
std::string fltVersionStr(options->getOptionString(),
optionIndex);
std::string optionText;
// Read the version from the string
std::istringstream ins(fltVersionStr);
ins >> optionText >> version;
}
}
Attr attr(version);
@@ -790,3 +803,4 @@ class ReaderWriterATTR : public osgDB::ReaderWriter
// now register with Registry to instantiate the above
// reader/writer.
osgDB::RegisterReaderWriterProxy<ReaderWriterATTR> g_readerWriter_ATTR_Proxy;