(Sorry, couldn't figure out how to be specific but concise with the title)

I created a class (called Test) that derived from PositionAttitudeTransform 
which would control the position of a shape (so a geode) in the scene. I wanted 
to then update it by setting that class as the geode's user data, and then 
having it update via a callback (which is irrelevant to the problem (as far as 
I can see)).

However, when I add an instance of Test as geode's user data a stack overflow 
occurs when the viewer calls realize(). No stack overflow if I don't. I see 
that addChild() is virtual, but I don't know if that would cause problems - I'm 
still rather a novice to OSG and C++. Can anyone explain the problem?

Here's the code for Test:


Code:

#include <osg/PositionAttitudeTransform>

class Test : public osg::PositionAttitudeTransform
{
public:
        Test(osg::ref_ptr<osg::Node> geode) { addChild(geode); }
        ~Test() { }

};




And here's main:


Code:

int main(int argc, const char** argv)
{
        osg::ref_ptr<osg::Group> root = new osg::Group();

        // Create viewer
        osgViewer::Viewer viewer;
        viewer.setSceneData(root);

        osg::ref_ptr<osg::Geode> geode = new osg::Geode();

        Test* t = new Test(geode);

        root->addChild(t);
        geode->setUserData(t);

        // Create camera
        viewer.setCameraManipulator(new osgGA::TrackballManipulator());

        // Run scene
        viewer.setUpViewInWindow(0, 0, 800, 600);
        viewer.realize();

        while (!viewer.done())
        {
                // Step the graphics display
                viewer.frame();
        }

        return 0;
}




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=45999#45999





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to