From 4d960e9ecddfaf26da7d46b70ae20ab2755393d1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 31 May 2005 05:46:41 +0000 Subject: [PATCH] From Tom Jolly, fixes to the mapping of the billboard rotate mode. --- src/osgPlugins/flt/flt2osg.cpp | 15 ++++++++++++ src/osgPlugins/pfb/ConvertFromPerformer.cpp | 27 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/osgPlugins/flt/flt2osg.cpp b/src/osgPlugins/flt/flt2osg.cpp index 8f334db17..4d80689e1 100644 --- a/src/osgPlugins/flt/flt2osg.cpp +++ b/src/osgPlugins/flt/flt2osg.cpp @@ -290,6 +290,7 @@ osg::Group* ConvertFromFLT::visitPrimaryNode(osg::Group& osgParent, PrimNodeReco osg::Group* osgPrim = NULL; GeoSetBuilder geoSetBuilder; GeoSetBuilder billboardBuilder; + GeoSetBuilder billboardBuilderPoint; // Visit for(int i=0; i < rec->getNumChildren(); i++) @@ -306,6 +307,8 @@ osg::Group* ConvertFromFLT::visitPrimaryNode(osg::Group& osgParent, PrimNodeReco if( ((MeshRecord*)child)->getData()->swTemplateTrans == 2) //Axis type rotate visitMesh(osgParent, &billboardBuilder, (MeshRecord*)child); + else if( ((MeshRecord*)child)->getData()->swTemplateTrans == 4) //Point type rotate + visitMesh(osgParent, &billboardBuilderPoint, (MeshRecord*)child); else visitMesh(osgParent, &geoSetBuilder, (MeshRecord*)child); break; @@ -315,6 +318,8 @@ osg::Group* ConvertFromFLT::visitPrimaryNode(osg::Group& osgParent, PrimNodeReco FaceRecord* fr = (FaceRecord*)child; if( fr->getData()->swTemplateTrans == 2) //Axis type rotate visitFace(&billboardBuilder, osgParent, fr); + else if( fr->getData()->swTemplateTrans == 4) //Point type rotate + visitFace(&billboardBuilderPoint, osgParent, fr); else visitFace(&geoSetBuilder, osgParent, fr); } @@ -397,6 +402,16 @@ osg::Group* ConvertFromFLT::visitPrimaryNode(osg::Group& osgParent, PrimNodeReco osgParent.addChild( billboard ); } + if( !billboardBuilderPoint.empty() ) + { + osg::Billboard* billboard = new osg::Billboard; + billboard->setMode( osg::Billboard::POINT_ROT_WORLD ); + billboardBuilderPoint.createOsgGeoSets(billboard ); + + if (billboard->getNumDrawables() > 0) + osgParent.addChild( billboard ); + } + return osgPrim; } diff --git a/src/osgPlugins/pfb/ConvertFromPerformer.cpp b/src/osgPlugins/pfb/ConvertFromPerformer.cpp index e62f56c04..fd1bcbae1 100644 --- a/src/osgPlugins/pfb/ConvertFromPerformer.cpp +++ b/src/osgPlugins/pfb/ConvertFromPerformer.cpp @@ -38,6 +38,20 @@ #include #include +// Need to undefine these because Performer defines them and it causes a +// compiler error in ConvertFromPerformer::visitBillboard. +#ifdef AXIAL_ROT +#undef AXIAL_ROT +#endif + +#ifdef POINT_ROT_EYE +#undef POINT_ROT_EYE +#endif + +#ifdef POINT_ROT_WORLD +#undef POINT_ROT_WORLD +#endif + extern "C" { @@ -437,6 +451,19 @@ osg::Node* ConvertFromPerformer::visitBillboard(osg::Group* osgParent,pfBillboar billboard->getAxis(axis); osgBillboard->setAxis(osg::Vec3(axis[0],axis[1],axis[2])); + switch( billboard->getMode( PFBB_ROT ) ) + { + case PFBB_AXIAL_ROT: + osgBillboard->setMode( osg::Billboard::AXIAL_ROT ); + break; + case PFBB_POINT_ROT_EYE: + osgBillboard->setMode( osg::Billboard::POINT_ROT_EYE ); + break; + case PFBB_POINT_ROT_WORLD: + osgBillboard->setMode( osg::Billboard::POINT_ROT_WORLD ); + break; + } + for(int i=0;igetNumGSets();++i) { /* osg::GeoSet* osggset = */