From Brede Johansen, "I have added "billboardCenter" as a reader option to use the center of
a billboard as the pivot point."
This commit is contained in:
@@ -14,6 +14,7 @@ Document::Document() :
|
||||
_preserveObject(false),
|
||||
_defaultDOFAnimationState(false),
|
||||
_useTextureAlphaForTransparancyBinning(true),
|
||||
_useBillboardCenter(false),
|
||||
_doUnitsConversion(true),
|
||||
_desiredUnits(METERS),
|
||||
_done(false),
|
||||
@@ -38,12 +39,14 @@ Document::~Document()
|
||||
void Document::pushLevel()
|
||||
{
|
||||
_levelStack.push_back(_currentPrimaryRecord.get());
|
||||
_levelStack.back()->pushLevel(*this);
|
||||
_level++;
|
||||
}
|
||||
|
||||
|
||||
void Document::popLevel()
|
||||
{
|
||||
_levelStack.back()->popLevel(*this);
|
||||
_levelStack.pop_back();
|
||||
|
||||
if (!_levelStack.empty())
|
||||
|
||||
@@ -150,6 +150,8 @@ class Document
|
||||
bool getDefaultDOFAnimationState() const { return _defaultDOFAnimationState; }
|
||||
void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTransparancyBinning=flag; }
|
||||
bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTransparancyBinning; }
|
||||
void setUseBillboardCenter(bool flag) { _useBillboardCenter=flag; }
|
||||
bool getUseBillboardCenter() const { return _useBillboardCenter; }
|
||||
void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; }
|
||||
bool getDoUnitsConversion() const { return _doUnitsConversion; }
|
||||
void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; }
|
||||
@@ -166,6 +168,7 @@ class Document
|
||||
bool _preserveObject;
|
||||
bool _defaultDOFAnimationState;
|
||||
bool _useTextureAlphaForTransparancyBinning;
|
||||
bool _useBillboardCenter;
|
||||
bool _doUnitsConversion;
|
||||
CoordUnits _desiredUnits;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/Depth>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osgUtil/TransformAttributeFunctor>
|
||||
#include "Registry.h"
|
||||
#include "Document.h"
|
||||
#include "RecordInputStream.h"
|
||||
@@ -416,7 +417,7 @@ protected:
|
||||
return osg::PrimitiveSet::POLYGON;
|
||||
}
|
||||
|
||||
virtual ~Face()
|
||||
virtual void popLevel(Document& document)
|
||||
{
|
||||
if (_geode.valid())
|
||||
{
|
||||
@@ -464,6 +465,27 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getUseBillboardCenter())
|
||||
{
|
||||
// Set billboard rotation point to center of face.
|
||||
osg::Billboard* billboard = dynamic_cast<osg::Billboard*>(_geode.get());
|
||||
if (billboard)
|
||||
{
|
||||
for (unsigned int i=0; i<billboard->getNumDrawables(); ++i)
|
||||
{
|
||||
osg::BoundingBox bb = billboard->getDrawable(i)->getBound();
|
||||
billboard->setPosition(i,bb.center());
|
||||
|
||||
osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center()));
|
||||
billboard->getDrawable(i)->accept(tf);
|
||||
|
||||
billboard->getDrawable(i)->dirtyBound();
|
||||
}
|
||||
|
||||
billboard->dirtyBound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -171,11 +171,14 @@ class FLTReaderWriter : public ReaderWriter
|
||||
document.setDefaultDOFAnimationState((options->getOptionString().find("dofAnimation")!=std::string::npos));
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "dofAnimation=" << document.getDefaultDOFAnimationState() << std::endl;
|
||||
|
||||
document.setUseBillboardCenter((options->getOptionString().find("billboardCenter")!=std::string::npos));
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "billboardCenter=" << document.getUseBillboardCenter() << std::endl;
|
||||
|
||||
document.setUseTextureAlphaForTransparancyBinning(options->getOptionString().find("noTextureAlphaForTransparancyBinning")==std::string::npos);
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "noTextureAlphaForTransparancyBinning=" << document.getUseTextureAlphaForTransparancyBinning() << std::endl;
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "noTextureAlphaForTransparancyBinning=" << !document.getUseTextureAlphaForTransparancyBinning() << std::endl;
|
||||
|
||||
document.setDoUnitsConversion((options->getOptionString().find("noUnitsConversion")==std::string::npos)); // default to true, unless noUnitsConversion is specified.
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "noUnitsConversion=" << document.getDoUnitsConversion() << std::endl;
|
||||
osg::notify(osg::DEBUG_INFO) << readerMsg << "noUnitsConversion=" << !document.getDoUnitsConversion() << std::endl;
|
||||
|
||||
if (document.getDoUnitsConversion())
|
||||
{
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
PrimaryRecord();
|
||||
|
||||
virtual void read(RecordInputStream& in, Document& document);
|
||||
virtual void pushLevel(Document& /*document*/) {}
|
||||
virtual void popLevel(Document& /*document*/) {}
|
||||
|
||||
// Ancillary operations
|
||||
virtual void setID(const std::string& /*id*/) {}
|
||||
|
||||
Reference in New Issue
Block a user