rem: beginEditCP(mg1.core()); mg1->setMaterial(green); endEditCP(mg1.core());
add: CPEditor mg1c(mg1.core()); mg1->setMaterial(green);
context: int main (int argc, char **argv){    // GLUT init    osgInit(argc, argv);    glutInit(&argc, argv);    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);    UInt32 id = glutCreateWindow("OpenSG");    glutKeyboardFunc(key);    glutReshapeFunc(resize);    glutDisplayFunc(display);    glutMouseFunc(mouse);    glutMotionFunc(motion);        glutIdleFunc(display);    // create the tree    GroupNodePtr root = GroupNodePtr::create();        {    MaterialGroupNodePtr mg1 = MaterialGroupNodePtr::create();    beginEditCP(root.node());        root.node()->addChild(mg1);    endEditCP(root.node());        SimpleMaterialPtr green = SimpleMaterial::create();        CPEditAll(green);    green->setDiffuse(Color3f(0,1,0));    beginEditCP(mg1.core());        mg1->setMaterial(green);    endEditCP(mg1.core());        MaterialGroupNodePtr mg2 = MaterialGroupNodePtr::create();    beginEditCP(mg1.node());        mg1.node()->addChild(mg2);    endEditCP(mg1.node());    SimpleMaterialPtr red = SimpleMaterial::create();        CPEditAll(red);    red->setDiffuse(Color3f(1,0,0));    beginEditCP(mg2.core());        mg2->setMaterial(red);    endEditCP(mg2.core());    GeometryNodePtr torus;    torus = makeTorusGeo(.5, 2, 16, 16);    beginEditCP(mg2.node());        mg2.node()->addChild(torus);    endEditCP(mg2.node());    }        //     // The action    win = GLUTWindow::create();    win->setId(id);    win->init();    mgr = new SimpleSceneManager;    // tell the manager what to manage    mgr->setWindow(win);    mgr->setRoot  (root);    // show the whole scene    mgr->showAll();    glutMainLoop();        return 0;}