From Tom Jolly, fixes to the mapping of the billboard rotate mode.

This commit is contained in:
Robert Osfield
2005-05-31 05:46:41 +00:00
parent 44b8b0177c
commit 4d960e9ecd
2 changed files with 42 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -38,6 +38,20 @@
#include <Performer/pr/pfMaterial.h>
#include <Performer/pr/pfTexture.h>
// 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;i<billboard->getNumGSets();++i)
{
/* osg::GeoSet* osggset = */