From Paul Martz, "I've added support for indexed light points and the light
point appearance palette to the OpenFlight loader. Both are 15.8 features. I also added parsing/comments regarding other things that have changed for v15.8."
This commit is contained in:
@@ -165,6 +165,10 @@ SOURCE=..\..\..\src\osgPlugins\flt\LightPointRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointPaletteRecords.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourcePaletteRecord.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -353,6 +357,10 @@ SOURCE=..\..\..\src\osgPlugins\flt\LightPointRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightPointPaletteRecords.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\flt\LightSourcePaletteRecord.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -25,7 +25,8 @@ struct SExternalReference
|
||||
// 3 = Line Palette Override
|
||||
// 4 = Sound Palette Override
|
||||
// 5 = Light source Palette Override
|
||||
// 6-31 Spare
|
||||
// 6 = Light point Palette Override
|
||||
// 7-31 Spare
|
||||
// int16 iReserved; // Reserved
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@ struct SFace
|
||||
// 3 = Packed color
|
||||
// 4 = Terrain culture cutout (footprint)
|
||||
// 5 = Hidden (not drawn)
|
||||
// 6-31 Spare
|
||||
// 6 = Hidden (not drawn)
|
||||
// 7-31 Spare
|
||||
uint8 swLightMode; // Lightmode
|
||||
// = 0 use face color, not illuminated
|
||||
// = 1 use vertex color, not illuminated
|
||||
|
||||
@@ -74,7 +74,9 @@ FltFile::FltFile(
|
||||
|
||||
// instances are always internally defined
|
||||
setInstancePool( new InstancePool );
|
||||
|
||||
|
||||
// Light point appearances are always internally defined
|
||||
setLtPtAppearancePool( new LtPtAppearancePool );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,12 +35,14 @@ class FltFile : public osg::Referenced
|
||||
LightPool* getLightPool() { return _lightPool.get(); }
|
||||
MaterialPool* getMaterialPool() { return _materialPool.get(); }
|
||||
InstancePool* getInstancePool() { return _instancePool.get(); }
|
||||
LtPtAppearancePool* getLtPtAppearancePool() { return _ltPtAppearancePool.get(); }
|
||||
|
||||
void setColorPool(ColorPool* colorPool) { _colorPool = colorPool; }
|
||||
void setTexturePool(TexturePool* texturePool) { _texturePool = texturePool; }
|
||||
void setLightPool(LightPool* lightPool){ _lightPool = lightPool; }
|
||||
void setMaterialPool(MaterialPool* materialPool){ _materialPool = materialPool; }
|
||||
void setInstancePool(InstancePool* instancePool){ _instancePool = instancePool; }
|
||||
void setLtPtAppearancePool(LtPtAppearancePool* ltPtAppearancePool){ _ltPtAppearancePool = ltPtAppearancePool; }
|
||||
|
||||
inline bool useInternalColorPalette() const { return _useInternalColorPalette; }
|
||||
inline bool useInternalTexturePalette() const { return _useInternalTexturePalette; }
|
||||
@@ -91,6 +93,7 @@ class FltFile : public osg::Referenced
|
||||
osg::ref_ptr<LightPool> _lightPool;
|
||||
osg::ref_ptr<MaterialPool> _materialPool;
|
||||
osg::ref_ptr<InstancePool> _instancePool;
|
||||
osg::ref_ptr<LtPtAppearancePool> _ltPtAppearancePool;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ CXXFILES =\
|
||||
UnknownRecord.cpp\
|
||||
LightPointRecord.cpp\
|
||||
VertexPoolRecords.cpp\
|
||||
LightPointPaletteRecords.cpp\
|
||||
LightSourcePaletteRecord.cpp\
|
||||
flt.cpp\
|
||||
LightSourceRecord.cpp\
|
||||
|
||||
@@ -34,4 +34,11 @@ void GroupRecord::endian()
|
||||
ENDIAN( pSGroup->iSpecialId_1 );
|
||||
ENDIAN( pSGroup->iSpecialId_2 );
|
||||
ENDIAN( pSGroup->iSignificance );
|
||||
|
||||
if (getFltFile()->getFlightVersion() >= 1580 )
|
||||
{
|
||||
ENDIAN( pSGroup->iLoopCount );
|
||||
ENDIAN( pSGroup->fLoopDuration );
|
||||
ENDIAN( pSGroup->fLastFrameDuration );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,16 @@ struct SGroup
|
||||
// 3 = Bounding box follows
|
||||
// 4 = Freeze bounding box
|
||||
// 5 = Default parent
|
||||
// 6-31 Spare
|
||||
// 6 - Backward animation
|
||||
// 7-31 Spare
|
||||
int16 iSpecialId_1; // Special effects ID 1 - defined by real time
|
||||
int16 iSpecialId_2; // Special effects ID 2 - defined by real time
|
||||
int16 iSignificance; // Significance Flags
|
||||
uint8 swLayer; // Layer Number
|
||||
uint8 swReserved[5]; // Reserved
|
||||
int32 iLoopCount; // Animation loop count
|
||||
float32 fLoopDuration; // Animation loop duration
|
||||
float32 fLastFrameDuration; // Duration of last frame in animation
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -151,8 +151,6 @@ void HeaderRecord::endian()
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
// As of 2004/2/23, only adding 15.8 support to header parsing.
|
||||
// Delete this comment when full support for 15.8 (1580) is added.
|
||||
memcpy( &(pHeader->iUTMZone), src, 2 ); src += 2;
|
||||
src += 6; // Reserved
|
||||
}
|
||||
@@ -166,8 +164,6 @@ void HeaderRecord::endian()
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
// As of 2004/2/23, only adding 15.8 support to header parsing.
|
||||
// Delete this comment when full support for 15.8 (1580) is added.
|
||||
memcpy( &(pHeader->iNextLightPointSysID), src, 2 ); src += 2;
|
||||
src += 4; // Reserved
|
||||
memcpy( &(pHeader->dfEarthMajorAxis), src, 8 ); src += 8;
|
||||
@@ -226,8 +222,6 @@ void HeaderRecord::endian()
|
||||
|
||||
if ( pHeader->diFormatRevLev >= 1580 )
|
||||
{
|
||||
// As of 2004/2/23, only adding 15.8 support to header parsing.
|
||||
// Delete this comment when full support for 15.8 (1580) is added.
|
||||
ENDIAN( pHeader->iUTMZone );
|
||||
ENDIAN( pHeader->iNextLightPointSysID );
|
||||
ENDIAN( pHeader->dfEarthMajorAxis );
|
||||
|
||||
@@ -90,8 +90,6 @@ struct SHeader
|
||||
uint16 iNextMeshNodeID; // Next Mesh node ID number
|
||||
|
||||
// New with 15.8
|
||||
// As of 2004/2/23, only adding 15.8 support to header parsing.
|
||||
// Delete this comment when full support for 15.8 (1580) is added.
|
||||
int16 iUTMZone; // UTM zone 1-60, negative indicates southern hemisphere
|
||||
uint16 iNextLightPointSysID; // Light point system ID
|
||||
float64 dfEarthMajorAxis; // Custom ellipsoid Earth major axis
|
||||
|
||||
70
src/osgPlugins/flt/LightPointPaletteRecords.cpp
Normal file
70
src/osgPlugins/flt/LightPointPaletteRecords.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
#include "flt.h"
|
||||
#include "Registry.h"
|
||||
#include "LightPointPaletteRecords.h"
|
||||
|
||||
using namespace flt;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LightPointPaletteRecords
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LtPtAppearancePaletteRecord> g_LtPtAppearancePaletteProxy;
|
||||
|
||||
LtPtAppearancePaletteRecord::LtPtAppearancePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LtPtAppearancePaletteRecord::~LtPtAppearancePaletteRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
void LtPtAppearancePaletteRecord::endian()
|
||||
{
|
||||
SLightPointAppearancePalette* ltPtApp = (SLightPointAppearancePalette*)getData();
|
||||
|
||||
ENDIAN( ltPtApp->index );
|
||||
ENDIAN( ltPtApp->surfMatCode );
|
||||
ENDIAN( ltPtApp->featureID );
|
||||
ENDIAN( ltPtApp->backColor );
|
||||
ENDIAN( ltPtApp->displayMode );
|
||||
ENDIAN( ltPtApp->intensity );
|
||||
ENDIAN( ltPtApp->backIntensity );
|
||||
ENDIAN( ltPtApp->minDefocus );
|
||||
ENDIAN( ltPtApp->maxDefocus );
|
||||
ENDIAN( ltPtApp->fadeMode );
|
||||
ENDIAN( ltPtApp->fogPunch );
|
||||
ENDIAN( ltPtApp->dirMode );
|
||||
ENDIAN( ltPtApp->rangeMode );
|
||||
ENDIAN( ltPtApp->minPixelSize );
|
||||
ENDIAN( ltPtApp->maxPixelSize );
|
||||
ENDIAN( ltPtApp->actualSize );
|
||||
ENDIAN( ltPtApp->transFalloffPixelSize );
|
||||
ENDIAN( ltPtApp->transFalloffExp );
|
||||
ENDIAN( ltPtApp->transFalloffScalar );
|
||||
ENDIAN( ltPtApp->transFalloffClamp );
|
||||
ENDIAN( ltPtApp->fogScalar );
|
||||
ENDIAN( ltPtApp->fogIntensity );
|
||||
ENDIAN( ltPtApp->sizeDiffThreshold );
|
||||
ENDIAN( ltPtApp->directionality );
|
||||
ENDIAN( ltPtApp->horizLobeAngle );
|
||||
ENDIAN( ltPtApp->vertLobeAngle );
|
||||
ENDIAN( ltPtApp->lobeRollAngle );
|
||||
ENDIAN( ltPtApp->dirFalloffExp );
|
||||
ENDIAN( ltPtApp->dirAmbientIntensity );
|
||||
ENDIAN( ltPtApp->significance );
|
||||
ENDIAN( ltPtApp->flags );
|
||||
ENDIAN( ltPtApp->visRange );
|
||||
ENDIAN( ltPtApp->fadeRangeRatio );
|
||||
ENDIAN( ltPtApp->fadeInDurationSecs );
|
||||
ENDIAN( ltPtApp->adeOutDurationSecs );
|
||||
ENDIAN( ltPtApp->lodRangeRatio );
|
||||
ENDIAN( ltPtApp->lodScale );
|
||||
}
|
||||
|
||||
94
src/osgPlugins/flt/LightPointPaletteRecords.h
Normal file
94
src/osgPlugins/flt/LightPointPaletteRecords.h
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
#ifndef __FLT_LIGHT_POINT_PALETTE_RECORDS_H
|
||||
#define __FLT_LIGHT_POINT_PALETTE_RECORDS_H
|
||||
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "Record.h"
|
||||
#include "RecordVisitor.h"
|
||||
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
struct SLightPointAppearancePalette
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
int32 reserved_0;
|
||||
char name[256];
|
||||
int32 index;
|
||||
int16 surfMatCode;
|
||||
int16 featureID;
|
||||
uint32 backColor; // Back facing color for bidirectional light points
|
||||
int32 displayMode; // Display Mode: 0 -- Raster
|
||||
// 1 -- Calligraphic
|
||||
// 2 -- Either
|
||||
float32 intensity;
|
||||
float32 backIntensity;
|
||||
float32 minDefocus; // Min and max defocus values, 0.0 to 1.0,
|
||||
float32 maxDefocus; // for use with calligraphic lights
|
||||
int32 fadeMode; // Fading mode: 0 -- Enable perspective fading calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 fogPunch; // Fog punch mode: 0 -- Enable fog punch-through calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 dirMode; // Directional mode: 0 -- Enable directional calculations
|
||||
// 1 -- Disable calculations
|
||||
int32 rangeMode; // Range Mode: 0 -- Use depth (Z) buffer calculations
|
||||
// 1 -- Use slant range calculations
|
||||
float32 minPixelSize;
|
||||
float32 maxPixelSize;
|
||||
float32 actualSize; // Actual light size in DB units
|
||||
float32 transFalloffPixelSize;
|
||||
float32 transFalloffExp;
|
||||
float32 transFalloffScalar;
|
||||
float32 transFalloffClamp;
|
||||
float32 fogScalar;
|
||||
float32 fogIntensity;
|
||||
float32 sizeDiffThreshold;
|
||||
int32 directionality; // Directionality: 0 -- Omnidirectional
|
||||
// 1 -- Unidirectional
|
||||
// 2 -- Bidirectional
|
||||
float32 horizLobeAngle;
|
||||
float32 vertLobeAngle;
|
||||
float32 lobeRollAngle;
|
||||
float32 dirFalloffExp;
|
||||
float32 dirAmbientIntensity;
|
||||
float32 significance;
|
||||
int32 flags; // Flag bits: 0 -- Reserved
|
||||
// 1 -- Don't use back color
|
||||
// 2 -- Reserved
|
||||
// ... several others ...
|
||||
// 18-31 -- Spare
|
||||
float32 visRange;
|
||||
float32 fadeRangeRatio;
|
||||
float32 fadeInDurationSecs;
|
||||
float32 adeOutDurationSecs;
|
||||
float32 lodRangeRatio;
|
||||
float32 lodScale;
|
||||
};
|
||||
|
||||
|
||||
class LtPtAppearancePaletteRecord : public AncillaryRecord
|
||||
{
|
||||
public:
|
||||
|
||||
LtPtAppearancePaletteRecord();
|
||||
|
||||
virtual Record* clone() const { return new LtPtAppearancePaletteRecord(); }
|
||||
virtual const char* className() const { return "LtPtAppearancePaletteRecord"; }
|
||||
virtual int classOpcode() const { return LIGHT_PT_APPEARANCE_PALETTE_OP; }
|
||||
virtual size_t sizeofData() const { return sizeof(SLightPointAppearancePalette); }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LtPtAppearancePaletteRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
|
||||
#endif
|
||||
@@ -64,3 +64,33 @@ void LightPointRecord::endian()
|
||||
ENDIAN( pSLightPoint->sfFlags );
|
||||
pSLightPoint->animRot.endian();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Indexed LightPointRecord
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterRecordProxy<LightPointIndexRecord> g_LightPointIndexdProxy;
|
||||
|
||||
LightPointIndexRecord::LightPointIndexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// virtual
|
||||
LightPointIndexRecord::~LightPointIndexRecord()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LightPointIndexRecord::endian()
|
||||
{
|
||||
SLightPointIndex *pSLightPointIndex = (SLightPointIndex*)getData();
|
||||
|
||||
ENDIAN( pSLightPointIndex->iAppearanceIndex );
|
||||
ENDIAN( pSLightPointIndex->iAnimationIndex );
|
||||
ENDIAN( pSLightPointIndex->iDrawOrder );
|
||||
}
|
||||
|
||||
@@ -106,8 +106,6 @@ struct SLightPoint
|
||||
float32x3 animRot; // Axis of rotation for rotating animation
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LightPointRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
@@ -129,6 +127,38 @@ class LightPointRecord : public PrimNodeRecord
|
||||
|
||||
|
||||
|
||||
struct SLightPointIndex
|
||||
{
|
||||
SRecHeader RecHeader;
|
||||
char szIdent[8]; // 7 char ASCII ID; 0 terminates
|
||||
int32 iAppearanceIndex; // Index into lt pt appearance palette
|
||||
int32 iAnimationIndex; // Index into lt pt animation palette
|
||||
int32 iDrawOrder; // Calligraphic draw order
|
||||
int32 iReserved_0; // Reserved
|
||||
};
|
||||
|
||||
class LightPointIndexRecord : public PrimNodeRecord
|
||||
{
|
||||
public:
|
||||
LightPointIndexRecord();
|
||||
|
||||
virtual Record* clone() const { return new LightPointIndexRecord(); }
|
||||
virtual const char* className() const { return "LightPointIndexRecord"; }
|
||||
virtual int classOpcode() const { return INDEXED_LIGHT_PT_OP; }
|
||||
virtual void accept(RecordVisitor& rv) { rv.apply(*this); }
|
||||
// virtual void traverse(RecordVisitor& rv);
|
||||
|
||||
virtual SLightPointIndex* getData() const { return (SLightPointIndex*)_pData; }
|
||||
|
||||
protected:
|
||||
virtual ~LightPointIndexRecord();
|
||||
|
||||
virtual void endian();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,11 @@ void LodRecord::endian()
|
||||
ENDIAN( pSLod->diFlags );
|
||||
pSLod->Center.endian();
|
||||
ENDIAN( pSLod->dfTransitionRange );
|
||||
|
||||
if (getFltFile()->getFlightVersion() >= 1580 )
|
||||
{
|
||||
ENDIAN( pSLod->dfSignificantSize );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct SLevelOfDetail
|
||||
// 3-31 Spare
|
||||
float64x3 Center; // Center coordinate (x,y,z) of LOD block
|
||||
float64 dfTransitionRange; // Transition Range for Morphing
|
||||
float64 dfSignificantSize; // Multigen-Paradigm-internal for 15.8
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -285,3 +285,25 @@ void InstancePool::addInstance(int nIndex, osg::Group* instance)
|
||||
_instanceMap[nIndex] = instance;
|
||||
}
|
||||
|
||||
|
||||
LtPtAppearancePool::PoolLtPtAppearance* LtPtAppearancePool::get(int nIndex)
|
||||
{
|
||||
if (nIndex < 0)
|
||||
return NULL;
|
||||
|
||||
AppearanceMap::iterator fitr = _appearanceMap.find(nIndex);
|
||||
if (fitr != _appearanceMap.end())
|
||||
return (*fitr).second.get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void LtPtAppearancePool::add(int nIndex, PoolLtPtAppearance* appearance)
|
||||
{
|
||||
_appearanceMap[nIndex] = appearance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -154,6 +154,36 @@ class InstancePool : public osg::Referenced
|
||||
InstanceMap _instanceMap;
|
||||
};
|
||||
|
||||
|
||||
class LtPtAppearancePool : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
struct PoolLtPtAppearance : public osg::Referenced
|
||||
{
|
||||
unsigned int _iBackColorIdx;
|
||||
float _bIntensity;
|
||||
float _sfMinPixelSize;
|
||||
float _sfMaxPixelSize;
|
||||
float _sfActualSize;
|
||||
int _iDirectionality;
|
||||
float _sfHLobeAngle;
|
||||
float _sfVLobeAngle;
|
||||
};
|
||||
|
||||
LtPtAppearancePool()
|
||||
{}
|
||||
|
||||
PoolLtPtAppearance* get(int nIndex);
|
||||
void add(int nIndex, PoolLtPtAppearance* appearance);
|
||||
|
||||
protected:
|
||||
~LtPtAppearancePool() {}
|
||||
|
||||
private:
|
||||
typedef std::map<int, osg::ref_ptr<PoolLtPtAppearance> > AppearanceMap;
|
||||
AppearanceMap _appearanceMap;
|
||||
};
|
||||
|
||||
}; // end namespace flt
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@ class VertexListRecord;
|
||||
class MorphVertexListRecord;
|
||||
class LightSourceRecord;
|
||||
class LightPointRecord;
|
||||
class LightPointIndexRecord;
|
||||
class SwitchRecord;
|
||||
class ExtensionRecord;
|
||||
class ExternalRecord;
|
||||
@@ -129,6 +130,7 @@ class RecordVisitor
|
||||
virtual void apply(MorphVertexListRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightSourceRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightPointRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(LightPointIndexRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(SwitchRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(ExtensionRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
virtual void apply(ExternalRecord& rec) { apply((PrimNodeRecord&)rec); }
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <osgSim/MultiSwitch>
|
||||
#include <osgSim/DOFTransform>
|
||||
#include <osgSim/LightPointNode>
|
||||
#include <osgSim/Sector>
|
||||
#include <osgSim/BlinkSequence>
|
||||
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
@@ -52,6 +54,7 @@
|
||||
#include "MaterialPaletteRecord.h"
|
||||
#include "OldMaterialPaletteRecord.h"
|
||||
#include "TexturePaletteRecord.h"
|
||||
#include "LightPointPaletteRecords.h"
|
||||
#include "VertexPoolRecords.h"
|
||||
#include "OldVertexRecords.h"
|
||||
#include "GroupRecord.h"
|
||||
@@ -230,6 +233,10 @@ osg::Group* ConvertFromFLT::visitAncillary(osg::Group& osgParent, osg::Group& os
|
||||
visitTexturePalette(osgPrimary, (TexturePaletteRecord*)child);
|
||||
break;
|
||||
|
||||
case LIGHT_PT_APPEARANCE_PALETTE_OP:
|
||||
visitLtPtAppearancePalette(osgPrimary, (LtPtAppearancePaletteRecord*)child);
|
||||
break;
|
||||
|
||||
case VERTEX_PALETTE_OP:
|
||||
visitVertexPalette(osgPrimary, (VertexPaletteRecord*)child);
|
||||
break;
|
||||
@@ -305,6 +312,9 @@ osg::Group* ConvertFromFLT::visitPrimaryNode(osg::Group& osgParent, PrimNodeReco
|
||||
visitLightPoint(osgParent, (LightPointRecord*)child);
|
||||
#endif
|
||||
break;
|
||||
case INDEXED_LIGHT_PT_OP:
|
||||
visitLightPointIndex(osgParent, (LightPointIndexRecord*)child);
|
||||
break;
|
||||
case GROUP_OP:
|
||||
osgPrim = visitGroup(osgParent, (GroupRecord*)child);
|
||||
break;
|
||||
@@ -732,6 +742,29 @@ void ConvertFromFLT::visitTexturePalette(osg::Group& , TexturePaletteRecord* rec
|
||||
CERR<<"pTexturePool->addTextureName("<<nIndex<<", "<<textureName<<")"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
void ConvertFromFLT::visitLtPtAppearancePalette(osg::Group& osgParent, LtPtAppearancePaletteRecord* rec)
|
||||
{
|
||||
SLightPointAppearancePalette* ltPtApp = (SLightPointAppearancePalette*)rec->getData();
|
||||
LtPtAppearancePool* pool = rec->getFltFile()->getLtPtAppearancePool();
|
||||
assert( pool );
|
||||
if (ltPtApp && pool)
|
||||
{
|
||||
LtPtAppearancePool::PoolLtPtAppearance* entry = new LtPtAppearancePool::PoolLtPtAppearance;
|
||||
|
||||
entry->_iBackColorIdx = ltPtApp->backColor;
|
||||
entry->_bIntensity = ltPtApp->intensity;
|
||||
entry->_sfMinPixelSize = ltPtApp->minPixelSize;
|
||||
entry->_sfMaxPixelSize = ltPtApp->maxPixelSize;
|
||||
entry->_sfActualSize = ltPtApp->actualSize;
|
||||
entry->_iDirectionality = ltPtApp->directionality;
|
||||
entry->_sfHLobeAngle = ltPtApp->horizLobeAngle;
|
||||
entry->_sfVLobeAngle = ltPtApp->vertLobeAngle;
|
||||
|
||||
pool->add(ltPtApp->index, entry);
|
||||
}
|
||||
}
|
||||
|
||||
/*osgParent*/
|
||||
void ConvertFromFLT::visitVertexPalette(osg::Group& , VertexPaletteRecord* rec)
|
||||
{
|
||||
@@ -2189,6 +2222,130 @@ void ConvertFromFLT::visitLightPoint(osg::Group& osgParent, LightPointRecord* re
|
||||
}
|
||||
|
||||
|
||||
// OpenFlight 15.8 (1580)
|
||||
// Light point records contain indices into appearance and animation palettes.
|
||||
// Need to look up the palette entries to determine how the light points
|
||||
// look (and behave).
|
||||
void ConvertFromFLT::visitLightPointIndex(osg::Group& osgParent, LightPointIndexRecord* rec)
|
||||
{
|
||||
SLightPointIndex *ltPtIdx = (SLightPointIndex*)rec->getData();
|
||||
LtPtAppearancePool* appPool = rec->getFltFile()->getLtPtAppearancePool();
|
||||
LtPtAppearancePool::PoolLtPtAppearance* ltPtApp = appPool->get( ltPtIdx->iAppearanceIndex );
|
||||
if (!ltPtApp)
|
||||
// Appearance index out of range
|
||||
return;
|
||||
|
||||
// TBD also get ltPtAnim record.
|
||||
// LightPointAnimation not currently implemented
|
||||
|
||||
GeoSetBuilder pBuilder;
|
||||
DynGeoSet* dgset = pBuilder.getDynGeoSet();
|
||||
dgset->setPrimType(osg::PrimitiveSet::POINTS);
|
||||
dgset->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
dgset->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
|
||||
osgSim::LightPointNode *lpNode = new osgSim::LightPointNode();
|
||||
|
||||
for (int i=0; i < rec->getNumChildren(); i++)
|
||||
{
|
||||
Record* child = rec->getChild(i);
|
||||
if( child->classOpcode() == COMMENT_OP) visitComment(*lpNode, (CommentRecord*)child);
|
||||
}
|
||||
|
||||
lpNode->setMinPixelSize( ltPtApp->_sfMinPixelSize );
|
||||
lpNode->setMaxPixelSize( ltPtApp->_sfMaxPixelSize );
|
||||
|
||||
addVertices(&pBuilder, rec);
|
||||
|
||||
const DynGeoSet::CoordList& coords = dgset->getCoordList();
|
||||
const DynGeoSet::ColorList& colors = dgset->getColorList();
|
||||
const DynGeoSet::NormalList& norms = dgset->getNormalList();
|
||||
|
||||
bool directional = false;
|
||||
int numInternalLightPoints = 0; // Number of osgSim::LightPoint objects to add per OpenFlight light point vertex
|
||||
switch (ltPtApp->_iDirectionality)
|
||||
{
|
||||
case 0: // Omnidirectional;
|
||||
directional = false;
|
||||
numInternalLightPoints = 1;
|
||||
break;
|
||||
case 1: // Unidirectional;
|
||||
directional = true;
|
||||
numInternalLightPoints = 1;
|
||||
break;
|
||||
case 2: // Bidirectional;
|
||||
directional = true;
|
||||
numInternalLightPoints = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
float lobeVert=0.f, lobeHorz=0.f;
|
||||
if ( directional)
|
||||
{
|
||||
lobeVert = osg::DegreesToRadians( ltPtApp->_sfVLobeAngle );
|
||||
lobeHorz = osg::DegreesToRadians( ltPtApp->_sfHLobeAngle );
|
||||
}
|
||||
float pointRadius = ltPtApp->_sfActualSize * _unitScale;
|
||||
|
||||
for (unsigned int nl = 0; nl < coords.size(); nl++)
|
||||
{
|
||||
// Could add 1 or 2 internal light points, 2 for bidirectional
|
||||
for (int i=0; i<numInternalLightPoints; i++)
|
||||
{
|
||||
osg::Vec4 color( 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if ( (i==0) && (nl < colors.size()) )
|
||||
color = colors[nl];
|
||||
else if (i==1)
|
||||
{
|
||||
// Get back color
|
||||
ColorPool* pColorPool = rec->getFltFile()->getColorPool();
|
||||
color = pColorPool->getColor( ltPtApp->_iBackColorIdx );
|
||||
}
|
||||
|
||||
osgSim::LightPoint lp( true, coords[nl], color, 1.0f, pointRadius);
|
||||
|
||||
if (directional)
|
||||
{
|
||||
// calc elevation angles
|
||||
osg::Vec3 normal( 1.0f, 0.0f, 0.0f);
|
||||
if (nl < norms.size())
|
||||
normal = norms[nl];
|
||||
if (i==1)
|
||||
// Negate the normal for the back facing internal light point
|
||||
normal = -normal;
|
||||
|
||||
float elevAngle = osg::PI_2 - acos( normal.z() );
|
||||
if (normal.z() < 0.0f)
|
||||
elevAngle = -elevAngle;
|
||||
float minElevation = elevAngle - lobeVert/2.0f;
|
||||
float maxElevation = elevAngle + lobeVert/2.0f;
|
||||
|
||||
// calc azimuth angles
|
||||
osg::Vec2 pNormal( normal.x(), normal.y() );
|
||||
float lng = pNormal.normalize();
|
||||
float azimAngle = 0.0f;
|
||||
if( lng > 0.0000001)
|
||||
{
|
||||
azimAngle = acos( pNormal.y() );
|
||||
if (pNormal.x() < 0.0f)
|
||||
azimAngle = -azimAngle;
|
||||
}
|
||||
|
||||
float minAzimuth = azimAngle - lobeHorz/2.0f;
|
||||
float maxAzimuth = azimAngle + lobeHorz/2.0f;
|
||||
|
||||
float fadeRange = 0.0f;
|
||||
lp._sector = new osgSim::AzimElevationSector( minAzimuth, maxAzimuth, minElevation, maxElevation, fadeRange);
|
||||
}
|
||||
|
||||
lpNode->addLightPoint(lp);
|
||||
}
|
||||
}
|
||||
|
||||
osgParent.addChild(lpNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConvertFromFLT::visitMesh ( osg::Group &parent, GeoSetBuilder *pBuilder, MeshRecord *rec )
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ class ColorPaletteRecord;
|
||||
class MaterialPaletteRecord;
|
||||
class OldMaterialPaletteRecord;
|
||||
class TexturePaletteRecord;
|
||||
class LtPtAppearancePaletteRecord;
|
||||
class VertexPaletteRecord;
|
||||
class VertexRecord;
|
||||
class NormalVertexRecord;
|
||||
@@ -48,6 +49,7 @@ class MatrixRecord;
|
||||
class GeneralMatrixRecord;
|
||||
class ExternalRecord;
|
||||
class LightPointRecord;
|
||||
class LightPointIndexRecord;
|
||||
class VertexListRecord;
|
||||
class LocalVertexPoolRecord;
|
||||
class LongIDRecord;
|
||||
@@ -133,6 +135,7 @@ class ConvertFromFLT
|
||||
void visitMaterialPalette(osg::Group& osgParent, MaterialPaletteRecord* rec);
|
||||
void visitOldMaterialPalette(osg::Group& osgParent, OldMaterialPaletteRecord* rec);
|
||||
void visitTexturePalette(osg::Group& osgParent, TexturePaletteRecord* rec);
|
||||
void visitLtPtAppearancePalette(osg::Group& osgParent, LtPtAppearancePaletteRecord* rec);
|
||||
void visitVertexPalette(osg::Group& osgParent, VertexPaletteRecord* rec);
|
||||
void visitVertex(osg::Group& osgParent, VertexRecord* rec);
|
||||
void visitNormalVertex(osg::Group& osgParent, NormalVertexRecord* rec);
|
||||
@@ -158,7 +161,8 @@ class ConvertFromFLT
|
||||
void visitMesh(osg::Group& osgParent,GeoSetBuilder* pParent, MeshRecord* rec);
|
||||
void visitMeshPrimitive(osg::Group& osgParent, MeshPrimitiveRecord* rec);
|
||||
void visitLightPoint(GeoSetBuilder* pBuilder, LightPointRecord* rec);
|
||||
void visitLightPoint(osg::Group& osgParent, LightPointRecord* rec);
|
||||
void visitLightPoint(osg::Group& osgParent, LightPointRecord* rec);
|
||||
void visitLightPointIndex(osg::Group& osgParent, LightPointIndexRecord* rec);
|
||||
int visitVertexList(GeoSetBuilder* pParent, VertexListRecord* rec);
|
||||
int visitLocalVertexPool(GeoSetBuilder* pBuilder, LocalVertexPoolRecord* rec);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#ifndef __FLT_OPCODE_H
|
||||
#define __FLT_OPCODE_H
|
||||
|
||||
#define OF_VERSION 1520 //OpenFlight version
|
||||
#define OF_VERSION 1580 //OpenFlight version
|
||||
|
||||
#define UNKNOWN_OP 0
|
||||
|
||||
@@ -80,9 +80,9 @@
|
||||
#define POP_ATTRIBUTE_OP 123 // ignored
|
||||
#define CURVE_OP 126 // ignored
|
||||
#define ROAD_CONSTRUCTION_OP 127
|
||||
#define LIGHT_PT_APPEARANCE_PALETTE_OP 128 // ignored
|
||||
#define LIGHT_PT_APPEARANCE_PALETTE_OP 128
|
||||
#define LIGHT_PT_ANIMATION_PALETTE_OP 129 // ignored
|
||||
#define INDEXED_LIGHT_PT_OP 130 // ignored
|
||||
#define INDEXED_LIGHT_PT_OP 130
|
||||
#define LIGHT_PT_SYSTEM_OP 131 // ignored
|
||||
#define INDEXED_STRING_OP 132 // ignored
|
||||
|
||||
|
||||
Reference in New Issue
Block a user