Merged changes from Cobin Holtz for support of "noUnitsConversion" via
the ReaderWriter::Options string.
This commit is contained in:
@@ -25,6 +25,7 @@ FltFile::FltFile(
|
||||
MaterialPool* pMaterialPool)
|
||||
{
|
||||
_useTextureAlphaForTransparancyBinning = true;
|
||||
_doUnitsConversion = true;
|
||||
|
||||
if (pColorPool)
|
||||
{
|
||||
@@ -70,6 +71,7 @@ FltFile::FltFile(
|
||||
|
||||
// instances are always internally defined
|
||||
setInstancePool( new InstancePool );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +99,7 @@ osg::Group* FltFile::convert()
|
||||
{
|
||||
ConvertFromFLT visit;
|
||||
visit.setUseTextureAlphaForTransparancyBinning(getUseTextureAlphaForTransparancyBinning());
|
||||
visit.setDoUnitsConversion(getDoUnitsConversion());
|
||||
return visit.convert(getHeaderRecord());
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ class FltFile : public osg::Referenced
|
||||
|
||||
void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTransparancyBinning=flag; }
|
||||
bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTransparancyBinning; }
|
||||
void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; }
|
||||
bool getDoUnitsConversion() const { return _doUnitsConversion; }
|
||||
|
||||
int getFlightVersion() const;
|
||||
inline HeaderRecord* getHeaderRecord() { return _headerRecord.get(); }
|
||||
@@ -67,6 +69,7 @@ class FltFile : public osg::Referenced
|
||||
bool _useInternalTexturePalette;
|
||||
bool _useInternalMaterialPalette;
|
||||
bool _useTextureAlphaForTransparancyBinning;
|
||||
bool _doUnitsConversion;
|
||||
|
||||
std::string _directory;
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& fil
|
||||
{
|
||||
read->setUseTextureAlphaForTransparancyBinning(options->getOptionString().find("noTextureAlphaForTransparancyBinning")==std::string::npos);
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getUseTextureAlphaForTransparancyBinning()=" << read->getUseTextureAlphaForTransparancyBinning() << std::endl;
|
||||
read->setDoUnitsConversion((options->getOptionString().find("noUnitsConversion")==std::string::npos)); // default to true, unless noUnitsConversion is specified.o
|
||||
osg::notify(osg::DEBUG_INFO) << "FltFile.getDoUnitsConversion()=" << read->getDoUnitsConversion() << std::endl;
|
||||
}
|
||||
|
||||
osg::Node* node = read->readNode(fileName);
|
||||
|
||||
@@ -102,6 +102,7 @@ ConvertFromFLT::ConvertFromFLT() :
|
||||
_useTextureAlphaForTranspancyBinning = true;
|
||||
_bHdrRgbMode = false;
|
||||
_currentLocalVertexPool = 0;
|
||||
_doUnitsConversion = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -434,24 +435,31 @@ osg::Group* ConvertFromFLT::visitHeader(HeaderRecord* rec)
|
||||
osg::notify(osg::INFO) << "Version " << _diOpenFlightVersion << std::endl;
|
||||
|
||||
// Unit scale
|
||||
switch (pSHeader->swVertexCoordUnit)
|
||||
if ( _doUnitsConversion )
|
||||
{
|
||||
case HeaderRecord::METERS:
|
||||
_unitScale = 1.0;
|
||||
break;
|
||||
case HeaderRecord::KILOMETERS:
|
||||
_unitScale = 1000.0;
|
||||
break;
|
||||
case HeaderRecord::FEET:
|
||||
_unitScale = 0.3048;
|
||||
break;
|
||||
case HeaderRecord::INCHES:
|
||||
_unitScale = 0.02540;
|
||||
break;
|
||||
case HeaderRecord::NAUTICAL_MILES:
|
||||
_unitScale = 1852.0;
|
||||
break;
|
||||
default:
|
||||
switch (pSHeader->swVertexCoordUnit)
|
||||
{
|
||||
case HeaderRecord::METERS:
|
||||
_unitScale = 1.0;
|
||||
break;
|
||||
case HeaderRecord::KILOMETERS:
|
||||
_unitScale = 1000.0;
|
||||
break;
|
||||
case HeaderRecord::FEET:
|
||||
_unitScale = 0.3048;
|
||||
break;
|
||||
case HeaderRecord::INCHES:
|
||||
_unitScale = 0.02540;
|
||||
break;
|
||||
case HeaderRecord::NAUTICAL_MILES:
|
||||
_unitScale = 1852.0;
|
||||
break;
|
||||
default:
|
||||
_unitScale = 1.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_unitScale = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,8 @@ class ConvertFromFLT
|
||||
|
||||
void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTranspancyBinning=flag; }
|
||||
bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTranspancyBinning; }
|
||||
void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; }
|
||||
bool getDoUnitsConversion() const { return _doUnitsConversion; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -202,6 +204,7 @@ class ConvertFromFLT
|
||||
bool _bHdrRgbMode;
|
||||
osg::Vec4 _faceColor;
|
||||
bool _useTextureAlphaForTranspancyBinning;
|
||||
bool _doUnitsConversion;
|
||||
|
||||
osg::Group* _osgParent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user