Hi Andreas,
I can confirm this is a bug in the osgSim::LightPointNode serializer
and have quickly repaired it as attached. As it is already late in
China and I'm really sleepy now :-) could you please help me test it
again and if it's usable this time,could you please help me submit it
to the osg-submissions?
Cheers,
Wang Rui
2011/6/29 Andreas Ekstrand <[email protected]>:
> Hi,
>
> I'm having problems with osgSim::LightPoint in the new osgt/osgb/osgx
> formats. After converting the attached lightpoint_test.flt to these formats
> with osgconv, loading them in osgviewer causes warnings and no data loaded
> for osgt/osgb and incomplete geometry for osgx (only the lightpoint, not the
> polygon).
>
> Looking at the osgt file created (also attached), the Sector and
> BlinkSequence objects are empty, which seems to cause the error. I don't
> know if it fails in the osgt writing or reading of osgt, or maybe in the
> reading of flt. Is a LightPoint without Sector or BlinkSequence considered
> non-valid? Is it okay to expect these in the osgt reading?
>
> Regards,
> Andreas
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
#include <osgSim/LightPointNode>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkLightPointList( const osgSim::LightPointNode& node )
{
return node.getNumLightPoints()>0;
}
static bool readLightPointList( osgDB::InputStream& is, osgSim::LightPointNode& node )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osgSim::LightPoint pt;
is >> osgDB::PROPERTY("LightPoint") >> osgDB::BEGIN_BRACKET;
is >> osgDB::PROPERTY("Position") >> pt._position;
is >> osgDB::PROPERTY("Color") >> pt._color;
int blendingMode = 0;
is >> osgDB::PROPERTY("Attributes") >> pt._on >> blendingMode >> pt._intensity >> pt._radius;
pt._blendingMode = (osgSim::LightPoint::BlendingMode)blendingMode;
bool hasObject = false; is >> osgDB::PROPERTY("Sector") >> hasObject;
if ( hasObject )
{
is >> osgDB::BEGIN_BRACKET;
pt._sector = dynamic_cast<osgSim::Sector*>( is.readObject() );
is >> osgDB::END_BRACKET;
}
hasObject = false; is >> osgDB::PROPERTY("BlinkSequence") >> hasObject;
if ( hasObject )
{
is >> osgDB::BEGIN_BRACKET;
pt._blinkSequence = dynamic_cast<osgSim::BlinkSequence*>( is.readObject() );
is >> osgDB::END_BRACKET;
}
is >> osgDB::END_BRACKET;
node.addLightPoint( pt );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeLightPointList( osgDB::OutputStream& os, const osgSim::LightPointNode& node )
{
unsigned int size = node.getNumLightPoints();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
const osgSim::LightPoint& pt = node.getLightPoint(i);
os << osgDB::PROPERTY("LightPoint") << osgDB::BEGIN_BRACKET << std::endl;
os << osgDB::PROPERTY("Position") << pt._position << std::endl;
os << osgDB::PROPERTY("Color") << pt._color << std::endl;
os << osgDB::PROPERTY("Attributes") << pt._on << (int)pt._blendingMode
<< pt._intensity << pt._radius << std::endl;
os << osgDB::PROPERTY("Sector") << (pt._sector!=NULL);
if ( pt._sector!=NULL )
{
os << osgDB::BEGIN_BRACKET << std::endl;
os.writeObject( pt._sector.get() );
os << osgDB::END_BRACKET << std::endl;
}
os << osgDB::PROPERTY("BlinkSequence") << (pt._blinkSequence!=NULL);
if ( pt._blinkSequence!=NULL )
{
os << osgDB::BEGIN_BRACKET << std::endl;
os.writeObject( pt._blinkSequence.get() );
os << osgDB::END_BRACKET << std::endl;
}
os << osgDB::END_BRACKET << std::endl;
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( osgSim_LightPointNode,
new osgSim::LightPointNode,
osgSim::LightPointNode,
"osg::Object osg::Node osgSim::LightPointNode" )
{
ADD_USER_SERIALIZER( LightPointList ); // _lightPointList
ADD_FLOAT_SERIALIZER( MinPixelSize, 0.0f ); // _minPixelSize
ADD_FLOAT_SERIALIZER( MaxPixelSize, 30.0f ); // _maxPixelSize
ADD_FLOAT_SERIALIZER( MaxVisibleDistance2, FLT_MAX ); // _maxVisibleDistance2
ADD_OBJECT_SERIALIZER( LightPointSystem, osgSim::LightPointSystem, NULL ); // _lightSystem
ADD_BOOL_SERIALIZER( PointSprite, false ); // _pointSprites
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org