osg should have something that can do this, probably with a callback. https://groups.google.com/forum/#!topic/osg-users/Sv1WCX4zFXc