Ok, I got this to work on my own and I can now create 10000 of these
objects by means of aggregation without using any dynamic allocation.
They key is to subclass from any osg objects you need and to declare
your destructor public.
Was there any particular reason most osg object destructors were
declared virtual protected in the first place? I get the virtual, but
not the protected.
/* child class of osg::AutoTransform with a non-protected destructor,
so we can do object aggregation. Also we inherit from an osg Geode
and osg Text object. */
class MyAutoTransform : public osg::AutoTransform, public osg::Geode,
public osgText::Text
{
public:
MyAutoTransform() : osg::AutoTransform(), osg::Geode(), osgText::Text()
{
// setup child-parent relations
osg::Geode::addDrawable( (osgText::Text*) this );
osg::AutoTransform::addChild( (osg::Geode*) this );
// AutoTransform properties
setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
setAutoScaleToScreen(true);
// text properties
osgText::Text::setAlignment(osgText::Text::CENTER_BOTTOM);
osgText::Text::setDataVariance(osg::Object::DYNAMIC);
}
// IMPORTANT: this destructor must be public
~MyAutoTransform()
{
}
};
class AggregatingParentClass
{
/*...*/
public:
MyAutoTransform m_lots_of_objects[10000];
};
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org