From Paul Martz, changes to better support OpenFlight 15.8
This commit is contained in:
parent
459b350eb9
commit
cb213d0ff4
@ -42,11 +42,12 @@ class GroupRecord : public PrimNodeRecord
|
||||
public:
|
||||
|
||||
enum FlagBit {
|
||||
FORWARD_ANIM = 0x40000000,
|
||||
SWING_ANIM = 0x20000000,
|
||||
BOUND_BOX_FOLLOW = 0x10000000,
|
||||
FREEZE_BOUND_BOX = 0x08000000,
|
||||
DEFAULT_PARENT = 0x04000000
|
||||
FORWARD_ANIM = 0x40000000,
|
||||
SWING_ANIM = 0x20000000,
|
||||
BOUND_BOX_FOLLOW = 0x10000000,
|
||||
FREEZE_BOUND_BOX = 0x08000000,
|
||||
DEFAULT_PARENT = 0x04000000,
|
||||
BACKWARD_ANIM = 0x02000000
|
||||
};
|
||||
|
||||
GroupRecord();
|
||||
|
@ -57,7 +57,9 @@ struct SPutTextureMapping
|
||||
// 1 = Origin point
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
int32 Reserved; // should always be set to 1
|
||||
int32 uvDisplayType; // v15.8 (1580) UV display type
|
||||
// 1 = XY
|
||||
// 2 = UV
|
||||
};
|
||||
|
||||
|
||||
@ -92,9 +94,14 @@ struct SPointPutTextureMapping
|
||||
// 2 = Alignment point
|
||||
// 3 = Shear point
|
||||
// 4 = Perspective point
|
||||
int32 Reserved; // should always be set to 1
|
||||
int32 uvDisplayType; // v15.8 (1580) UV display type
|
||||
// 1 = XY
|
||||
// 2 = UV
|
||||
float32 sfScale; // Depth scale factor
|
||||
int32 reserved_0; // New for 15.8
|
||||
float64 dfMat[4][4]; // Transformation matrix for the 4 point projection plane
|
||||
float32 sfURep; // U repetition
|
||||
float32 sfVRep; // V repetition
|
||||
};
|
||||
|
||||
|
||||
|
@ -814,27 +814,38 @@ osg::Group* ConvertFromFLT::visitBSP(osg::Group& osgParent, BSPRecord* rec)
|
||||
|
||||
osg::Group* ConvertFromFLT::visitGroup(osg::Group& osgParent, GroupRecord* rec)
|
||||
{
|
||||
const int fltVer = rec->getFltFile()->getFlightVersion();
|
||||
|
||||
SGroup* currentGroup = (SGroup*) rec->getData();
|
||||
|
||||
// OpenFlight 15.7 has two animation flags, forward and swing
|
||||
bool forwardAnim = (currentGroup->dwFlags & GroupRecord::FORWARD_ANIM)!=0;
|
||||
bool swingAnim = (currentGroup->dwFlags & GroupRecord::SWING_ANIM)!=0;
|
||||
const bool forwardAnim = (currentGroup->dwFlags & GroupRecord::FORWARD_ANIM)!=0;
|
||||
// OpenFlight 15.8 adds backwards animations
|
||||
const bool backwardAnim = ( (fltVer >= 1580) &&
|
||||
((currentGroup->dwFlags & GroupRecord::BACKWARD_ANIM) != 0) );
|
||||
// Regardless of forwards or backwards, animation could have swing bit set
|
||||
const osg::Sequence::LoopMode loopMode = ( (currentGroup->dwFlags & GroupRecord::SWING_ANIM) == 0 ) ?
|
||||
osg::Sequence::LOOP : osg::Sequence::SWING;
|
||||
|
||||
if( forwardAnim || swingAnim )
|
||||
if( forwardAnim || backwardAnim)
|
||||
{
|
||||
osg::Sequence* animSeq = new osg::Sequence;
|
||||
|
||||
visitAncillary(osgParent, *animSeq, rec)->addChild( animSeq );
|
||||
visitPrimaryNode(*animSeq, rec);
|
||||
|
||||
animSeq->setDuration(0.0,1000000);
|
||||
const int numReps = (fltVer >= 1580) ?
|
||||
currentGroup->iLoopCount : 1000000;
|
||||
const float frameDuration = (fltVer >= 1580) ?
|
||||
currentGroup->fLoopDuration / (float)animSeq->getNumChildren() : 0.f;
|
||||
animSeq->setDuration( frameDuration, numReps );
|
||||
|
||||
if ( forwardAnim )
|
||||
animSeq->setInterval(osg::Sequence::LOOP, 0, -1);
|
||||
else
|
||||
animSeq->setInterval(osg::Sequence::SWING, 0, -1);
|
||||
|
||||
animSeq->setInterval( loopMode, 0, -1 );
|
||||
else // Backwards animation
|
||||
animSeq->setInterval( loopMode, -1, 0 );
|
||||
|
||||
animSeq->setMode( osg::Sequence::START );
|
||||
|
||||
// Only set the name from the normal record ID if the visitAncillary()
|
||||
// call didn't find a Long ID record on this group
|
||||
if (animSeq->getName().length() == 0)
|
||||
@ -2347,7 +2358,6 @@ void ConvertFromFLT::visitLightPointIndex(osg::Group& osgParent, LightPointIndex
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConvertFromFLT::visitMesh ( osg::Group &parent, GeoSetBuilder *pBuilder, MeshRecord *rec )
|
||||
{
|
||||
DynGeoSet* dgset = pBuilder->getDynGeoSet();
|
||||
|
Loading…
Reference in New Issue
Block a user