Changeset 8301

Show
Ignore:
Timestamp:
05/10/08 19:25:42
Author:
robert
Message:

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&)."

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/FltExportVisitor.cpp

    r8286 r8301  
    2929#include <osgDB/FileUtils> 
    3030#include <osgDB/WriteFile> 
    31 #include <osg/Billboard> 
    3231#include <osg/Geode> 
    3332#include <osg/Geometry> 
     
    337336} 
    338337 
     338// Billboards also go through this code. The Geode is passed 
     339// to writeFace and writeMesh. If those methods successfully cast 
     340// the Geode to a Billboard, then they set the template mode 
     341// bit accordingly. 
    339342void 
    340343FltExportVisitor::apply( osg::Geode& node ) 
     
    438441 
    439442void 
    440 FltExportVisitor::apply( osg::Billboard& node ) 
    441 { 
    442     _firstNode = false; 
    443     ScopedStatePushPop guard( this, node.getStateSet() ); 
    444  
    445     // TBD -- Not yet implemented, but HIGH priority. 
    446     //   Face record -- HIGH 
    447     //   Mesh record -- HIGH 
    448  
    449     writeMatrix( node.getUserData() ); 
    450     writeComment( node ); 
    451     writePushTraverseWritePop( node ); 
    452 } 
    453  
    454 void 
    455443FltExportVisitor::apply( osg::Node& node ) 
    456444{ 
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/FltExportVisitor.h

    r8286 r8301  
    7878    virtual void apply( osg::LightSource& node ); 
    7979    virtual void apply( osg::Geode& node ); 
    80     virtual void apply( osg::Billboard& node ); 
    8180    virtual void apply( osg::Node& node ); 
    8281    virtual void apply( osg::ProxyNode& node ); 
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/expGeometryRecords.cpp

    r8286 r8301  
    2525#include <osg/Geometry> 
    2626#include <osg/Geode> 
     27#include <osg/Billboard> 
    2728#include <osg/io_utils> 
    2829#include <osg/Material> 
     
    250251    } 
    251252 
    252     // Check for blending. We're not a Billboard (TBD?) 
    253     //   so use either FIXED_NO_ALPHA_BLENDING or FIXED_ALPHA_BLENDING
     253    // Set the appropriate template mode based 
     254    // on blending or Billboarding
    254255    TemplateMode templateMode( FIXED_NO_ALPHA_BLENDING ); 
    255     if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON ) 
     256    const osg::Billboard* bb = dynamic_cast< const osg::Billboard* >( &geode ); 
     257    if (bb != NULL) 
     258    { 
     259        if( bb->getMode() == osg::Billboard::AXIAL_ROT ) 
     260            templateMode = AXIAL_ROTATE_WITH_ALPHA_BLENDING; 
     261        else 
     262            templateMode = POINT_ROTATE_WITH_ALPHA_BLENDING; 
     263    } 
     264    else if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON ) 
    256265    { 
    257266        const osg::BlendFunc* bf = static_cast<const osg::BlendFunc*>( 
     
    417426    } 
    418427 
    419     // Check for blending. We're not a Billboard (TBD?) 
    420     //   so use either FIXED_NO_ALPHA_BLENDING or FIXED_ALPHA_BLENDING
     428    // Set the appropriate template mode based 
     429    // on blending or Billboarding
    421430    TemplateMode templateMode( FIXED_NO_ALPHA_BLENDING ); 
    422     if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON ) 
     431    const osg::Billboard* bb = dynamic_cast< const osg::Billboard* >( &geode ); 
     432    if (bb != NULL) 
     433    { 
     434        if( bb->getMode() == osg::Billboard::AXIAL_ROT ) 
     435            templateMode = AXIAL_ROTATE_WITH_ALPHA_BLENDING; 
     436        else 
     437            templateMode = POINT_ROTATE_WITH_ALPHA_BLENDING; 
     438    } 
     439    else if ( ss->getMode( GL_BLEND ) & osg::StateAttribute::ON ) 
    423440    { 
    424441        const osg::BlendFunc* bf = static_cast<const osg::BlendFunc*>(