From Paul Martz, "This change adds support for osg::Billboards to the OpenFlight exporter.
It might seem odd that the change actually removes the stub apply(Billboard&) method, but it turns out Billboards are easily supported in subordinate routines of the existing apply(Geode&) method with s dynamic_cast, so there's no need for a separate apply(Billboard&)."
This commit is contained in:
parent
e9589ebb49
commit
412717c151
@ -28,7 +28,6 @@
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/LightSource>
|
||||
@ -336,6 +335,10 @@ FltExportVisitor::apply( osg::LightSource& node )
|
||||
writePushTraverseWritePop( node );
|
||||
}
|
||||
|
||||
// Billboards also go through this code. The Geode is passed
|
||||
// to writeFace and writeMesh. If those methods successfully cast
|
||||
// the Geode to a Billboard, then they set the template mode
|
||||
// bit accordingly.
|
||||
void
|
||||
FltExportVisitor::apply( osg::Geode& node )
|
||||
{
|
||||
@ -436,21 +439,6 @@ FltExportVisitor::apply( osg::Geode& node )
|
||||
// traverse( (osg::Node&)node );
|
||||
}
|
||||
|
||||
void
|
||||
FltExportVisitor::apply( osg::Billboard& node )
|
||||
{
|
||||
_firstNode = false;
|
||||
ScopedStatePushPop guard( this, node.getStateSet() );
|
||||
|
||||
// TBD -- Not yet implemented, but HIGH priority.
|
||||
// Face record -- HIGH
|
||||
// Mesh record -- HIGH
|
||||
|
||||
writeMatrix( node.getUserData() );
|
||||
writeComment( node );
|
||||
writePushTraverseWritePop( node );
|
||||
}
|
||||
|
||||
void
|
||||
FltExportVisitor::apply( osg::Node& node )
|
||||
{
|
||||
|
@ -77,7 +77,6 @@ public:
|
||||
virtual void apply( osg::Transform& node );
|
||||
virtual void apply( osg::LightSource& node );
|
||||
virtual void apply( osg::Geode& node );
|
||||
virtual void apply( osg::Billboard& node );
|
||||
virtual void apply( osg::Node& node );
|
||||
virtual void apply( osg::ProxyNode& node );
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/Material>
|
||||
#include <osg/Texture2D>
|
||||
@ -249,10 +250,18 @@ FltExportVisitor::writeFace( const osg::Geode& geode, const osg::Geometry& geom,
|
||||
}
|
||||
}
|
||||
|
||||
// Check for blending. We're not a Billboard (TBD?)
|
||||
// so use either FIXED_NO_ALPHA_BLENDING or FIXED_ALPHA_BLENDING.
|
||||
// Set the appropriate template mode based
|
||||
// on blending or Billboarding.
|
||||
TemplateMode templateMode( FIXED_NO_ALPHA_BLENDING );
|
||||
if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON )
|
||||
const osg::Billboard* bb = dynamic_cast< const osg::Billboard* >( &geode );
|
||||
if (bb != NULL)
|
||||
{
|
||||
if( bb->getMode() == osg::Billboard::AXIAL_ROT )
|
||||
templateMode = AXIAL_ROTATE_WITH_ALPHA_BLENDING;
|
||||
else
|
||||
templateMode = POINT_ROTATE_WITH_ALPHA_BLENDING;
|
||||
}
|
||||
else if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON )
|
||||
{
|
||||
const osg::BlendFunc* bf = static_cast<const osg::BlendFunc*>(
|
||||
ss->getAttribute(osg::StateAttribute::BLENDFUNC) );
|
||||
@ -416,10 +425,18 @@ FltExportVisitor::writeMesh( const osg::Geode& geode, const osg::Geometry& geom
|
||||
}
|
||||
}
|
||||
|
||||
// Check for blending. We're not a Billboard (TBD?)
|
||||
// so use either FIXED_NO_ALPHA_BLENDING or FIXED_ALPHA_BLENDING.
|
||||
// Set the appropriate template mode based
|
||||
// on blending or Billboarding.
|
||||
TemplateMode templateMode( FIXED_NO_ALPHA_BLENDING );
|
||||
if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON )
|
||||
const osg::Billboard* bb = dynamic_cast< const osg::Billboard* >( &geode );
|
||||
if (bb != NULL)
|
||||
{
|
||||
if( bb->getMode() == osg::Billboard::AXIAL_ROT )
|
||||
templateMode = AXIAL_ROTATE_WITH_ALPHA_BLENDING;
|
||||
else
|
||||
templateMode = POINT_ROTATE_WITH_ALPHA_BLENDING;
|
||||
}
|
||||
else if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON )
|
||||
{
|
||||
const osg::BlendFunc* bf = static_cast<const osg::BlendFunc*>(
|
||||
ss->getAttribute(osg::StateAttribute::BLENDFUNC) );
|
||||
|
Loading…
Reference in New Issue
Block a user