From Charles Cole, "Attached are mods to the OpenFlight plug-in to help further implement
the specification. With these mods, blink sequences are now created for flashing light point nodes, either palletized (v.15.8 and later) or non-palletized (15.7 and earlier). Thanks to Brede for his implementation of the palletized light point nodes. There is still work to do on adding the capability to properly handle light point system nodes, but this does add some capability that did not previously exist. So, I wanted to at least submit this and I will hopefully provide the additional capability in the near future. I've tested the code modifications with Visual Studio 2005. I don't have the means to test any other operating system, but I would suspect that there shouldn't be any issue (famous last words). I used the test files that I uploaded to the users forum to test the changes. In addition to the added capability, I changed the light point node radius to the "actualPixelSize" value in the file. Previously, the radius was set to half the actual pixel size (see LightPointRecords.cpp). Not sure why this was the case. But, it was brought to my attention by a co-worker who created the OpenFlight files and was testing them with different viewers. If there's some history for setting the radius to half the size, then this change can be omitted."
This commit is contained in:
@@ -28,6 +28,7 @@ Document::Document() :
|
||||
_materialPoolParent(false),
|
||||
_lightSourcePoolParent(false),
|
||||
_lightPointAppearancePoolParent(false),
|
||||
_lightPointAnimationPoolParent(false),
|
||||
_shaderPoolParent(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -144,6 +144,11 @@ class Document
|
||||
LightPointAppearancePool* getOrCreateLightPointAppearancePool();
|
||||
bool getLightPointAppearancePoolParent() const { return _lightPointAppearancePoolParent; }
|
||||
|
||||
void setLightPointAnimationPool(LightPointAnimationPool* lpap, bool parent=false) { _lightPointAnimationPool = lpap; _lightPointAnimationPoolParent=parent; }
|
||||
LightPointAnimationPool* getLightPointAnimationPool() { return _lightPointAnimationPool.get(); }
|
||||
LightPointAnimationPool* getOrCreateLightPointAnimationPool();
|
||||
bool getLightPointAnimationPoolParent() const { return _lightPointAnimationPoolParent; }
|
||||
|
||||
void setShaderPool(ShaderPool* cp, bool parent=false) { _shaderPool = cp; _shaderPoolParent=parent; }
|
||||
ShaderPool* getShaderPool() { return _shaderPool.get(); }
|
||||
ShaderPool* getOrCreateShaderPool();
|
||||
@@ -202,12 +207,14 @@ class Document
|
||||
osg::ref_ptr<MaterialPool> _materialPool;
|
||||
osg::ref_ptr<LightSourcePool> _lightSourcePool;
|
||||
osg::ref_ptr<LightPointAppearancePool> _lightPointAppearancePool;
|
||||
osg::ref_ptr<LightPointAnimationPool> _lightPointAnimationPool;
|
||||
osg::ref_ptr<ShaderPool> _shaderPool;
|
||||
bool _colorPoolParent;
|
||||
bool _texturePoolParent;
|
||||
bool _materialPoolParent;
|
||||
bool _lightSourcePoolParent;
|
||||
bool _lightPointAppearancePoolParent;
|
||||
bool _lightPointAnimationPoolParent;
|
||||
bool _shaderPoolParent;
|
||||
|
||||
osg::ref_ptr<PrimaryRecord> _currentPrimaryRecord;
|
||||
@@ -252,6 +259,13 @@ inline LightPointAppearancePool* Document::getOrCreateLightPointAppearancePool()
|
||||
return _lightPointAppearancePool.get();
|
||||
}
|
||||
|
||||
inline LightPointAnimationPool* Document::getOrCreateLightPointAnimationPool()
|
||||
{
|
||||
if (!_lightPointAnimationPool.valid())
|
||||
_lightPointAnimationPool = new LightPointAnimationPool;
|
||||
return _lightPointAnimationPool.get();
|
||||
}
|
||||
|
||||
|
||||
inline ShaderPool* Document::getOrCreateShaderPool()
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
lp._blinkSequence = new osgSim::BlinkSequence();
|
||||
if (lp._blinkSequence.valid())
|
||||
{
|
||||
lp._blinkSequence->setDataVariance(osg::Object::DataVariance::DYNAMIC);
|
||||
lp._blinkSequence->setDataVariance(osg::Object::DYNAMIC);
|
||||
lp._blinkSequence->setPhaseShift(_animationPhaseDelay);
|
||||
lp._blinkSequence->addPulse(_animationPeriod - _animationPeriodEnable,
|
||||
osg::Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
|
||||
@@ -636,28 +636,46 @@ protected:
|
||||
|
||||
virtual ~LightPointAnimationPalette() {}
|
||||
|
||||
virtual void readRecord(RecordInputStream& in, Document& /*document*/)
|
||||
virtual void readRecord(RecordInputStream& in, Document& document)
|
||||
{
|
||||
if (document.getLightPointAnimationPoolParent())
|
||||
// Using parent's light point animation pool -- ignore this record.
|
||||
return;
|
||||
|
||||
osg::ref_ptr<LPAnimation> animation = new LPAnimation;
|
||||
|
||||
in.forward(4);
|
||||
std::string name = in.readString(256);
|
||||
/*int32 index =*/ in.readInt32(-1);
|
||||
/*float32 animationPeriod =*/ in.readFloat32();
|
||||
/*float32 animationPhaseDelay =*/ in.readFloat32();
|
||||
/*float32 animationEnabledPeriod =*/ in.readFloat32();
|
||||
/*osg::Vec3f axisOfRotation =*/ in.readVec3f();
|
||||
/*uint32 flags =*/ in.readUInt32();
|
||||
/*int32 animationType =*/ in.readInt32();
|
||||
/*int32 morseCodeTiming =*/ in.readInt32();
|
||||
/*int32 wordRate =*/ in.readInt32();
|
||||
/*int32 characterRate =*/ in.readInt32();
|
||||
std::string morseCodeString = in.readString(1024);
|
||||
animation->name = in.readString(256);
|
||||
animation->index = in.readInt32(-1);
|
||||
// Rotating or strobe
|
||||
animation->animationPeriod = in.readFloat32();
|
||||
animation->animationPhaseDelay = in.readFloat32();
|
||||
animation->animationEnabledPeriod = in.readFloat32();
|
||||
animation->axisOfRotation = in.readVec3f();
|
||||
animation->flags = in.readUInt32();
|
||||
animation->animationType = in.readInt32();
|
||||
|
||||
// Morse code
|
||||
animation->morseCodeTiming = in.readInt32();
|
||||
animation->wordRate = in.readInt32();
|
||||
animation->characterRate = in.readInt32();
|
||||
animation->morseCodeString = in.readString(1024);
|
||||
|
||||
// Flashing sequence
|
||||
int32 numberOfSequences = in.readInt32();
|
||||
for (int n=0; n<numberOfSequences; ++n)
|
||||
{
|
||||
/*uint32 sequenceState =*/ in.readUInt32();
|
||||
/*float32 sequenceDuration =*/ in.readFloat32();
|
||||
/*osg::Vec4f sequenceColor =*/ in.readColor32();
|
||||
LPAnimation::Pulse pulse;
|
||||
pulse.state = in.readUInt32();
|
||||
pulse.duration = in.readFloat32();
|
||||
pulse.color = in.readColor32();
|
||||
|
||||
animation->sequence.push_back(pulse);
|
||||
}
|
||||
|
||||
// Add to pool
|
||||
LightPointAnimationPool* lpaPool = document.getOrCreateLightPointAnimationPool();
|
||||
(*lpaPool)[animation->index] = animation.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -202,6 +202,77 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
struct LPAnimation : public osg::Referenced
|
||||
{
|
||||
enum AnimationType
|
||||
{
|
||||
FLASHING_SEQUENCE = 0,
|
||||
ROTATING = 1,
|
||||
STROBE = 2,
|
||||
MORSE_CODE = 3
|
||||
};
|
||||
|
||||
enum State
|
||||
{
|
||||
ON = 0,
|
||||
OFF = 1,
|
||||
COLOR_CHANGE = 2
|
||||
};
|
||||
|
||||
struct Pulse
|
||||
{
|
||||
uint32 state;
|
||||
float32 duration;
|
||||
osg::Vec4 color;
|
||||
};
|
||||
|
||||
typedef std::vector<Pulse> PulseArray;
|
||||
|
||||
std::string name; // animation name
|
||||
int32 index; // animation index
|
||||
float32 animationPeriod; // animation period, in seconds
|
||||
float32 animationPhaseDelay; // animation phase delay, in seconds from start of period
|
||||
float32 animationEnabledPeriod; // animation enabled period (time on), in seconds
|
||||
osg::Vec3f axisOfRotation; // axis of rotation for rotating animation (i, j, k)
|
||||
uint32 flags; // flags (bits, from left to right)
|
||||
// 0 = flashing
|
||||
// 1 = rotating
|
||||
// 2 = rotate counter clockwise
|
||||
// 3-31 = spare
|
||||
int32 animationType; // animation type
|
||||
// 0 = flashing sequence
|
||||
// 1 = rotating
|
||||
// 2 = strobe
|
||||
// 3 = morse code
|
||||
int32 morseCodeTiming; // morse code timing
|
||||
// 0 = standard timing
|
||||
// 1 = Farnsworth timing
|
||||
int32 wordRate; // word rate (for Farnsworth timing)
|
||||
int32 characterRate; // character rate (for Farnsworth timing)
|
||||
std::string morseCodeString; // morse code string
|
||||
PulseArray sequence;
|
||||
};
|
||||
|
||||
|
||||
class LightPointAnimationPool : public osg::Referenced , public std::map<int,osg::ref_ptr<LPAnimation> >
|
||||
{
|
||||
public:
|
||||
|
||||
LightPointAnimationPool() {}
|
||||
|
||||
LPAnimation* get(int index)
|
||||
{
|
||||
iterator itr = find(index);
|
||||
if (itr != end())
|
||||
return (*itr).second.get();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightPointAnimationPool() {}
|
||||
|
||||
};
|
||||
|
||||
class ShaderPool : public osg::Referenced , public std::map<int,osg::ref_ptr<osg::Program> >
|
||||
{
|
||||
@@ -250,6 +321,9 @@ public:
|
||||
void setLPAppearancePool(LightPointAppearancePool* pool) { _lpAppearancePool=pool; }
|
||||
LightPointAppearancePool* getLPAppearancePool() const { return _lpAppearancePool.get(); }
|
||||
|
||||
void setLPAnimationPool(LightPointAnimationPool* pool) { _lpAnimationPool=pool; }
|
||||
LightPointAnimationPool* getLPAnimationPool() const { return _lpAnimationPool.get(); }
|
||||
|
||||
void setShaderPool(ShaderPool* pool) { _shaderPool=pool; }
|
||||
ShaderPool* getShaderPool() const { return _shaderPool.get(); }
|
||||
|
||||
@@ -262,6 +336,7 @@ protected:
|
||||
osg::ref_ptr<TexturePool> _texturePool;
|
||||
osg::ref_ptr<LightSourcePool> _lightSourcePool;
|
||||
osg::ref_ptr<LightPointAppearancePool> _lpAppearancePool;
|
||||
osg::ref_ptr<LightPointAnimationPool> _lpAnimationPool;
|
||||
osg::ref_ptr<ShaderPool> _shaderPool;
|
||||
};
|
||||
|
||||
|
||||
@@ -222,6 +222,8 @@ class FLTReaderWriter : public ReaderWriter
|
||||
document.setLightSourcePool( pools->getLightSourcePool(), true );
|
||||
if (pools->getLPAppearancePool())
|
||||
document.setLightPointAppearancePool( pools->getLPAppearancePool(), true );
|
||||
if (pools->getLPAnimationPool())
|
||||
document.setLightPointAnimationPool( pools->getLPAnimationPool(), true );
|
||||
if (pools->getShaderPool())
|
||||
document.setShaderPool( pools->getShaderPool(), true );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user