- SGPropertyNode* cameraNode = renderingNode->getChild(i);
- if (strcmp(cameraNode->getName(), "camera") != 0)
- continue;
-
- // get a new copy of the traits struct
- osg::ref_ptr<osg::GraphicsContext::Traits> cameraTraits;
- cameraTraits = new osg::GraphicsContext::Traits(*traits);
- double shearx = cameraNode->getDoubleValue("shear-x", 0);
- double sheary = cameraNode->getDoubleValue("shear-y", 0);
- setTraitsFromProperties(cameraTraits.get(), cameraNode, wsi);
- // FIXME, currently this is too much of a problem to route
- // the resize events. When we do no longer need sdl and
- // such this can be simplified
- cameraTraits->supportsResize = false;
-
- // ok found a camera configuration, add a new slave if possible
- GraphicsContext* gc
- = GraphicsContext::createGraphicsContext(cameraTraits.get());
- if (gc) {
- gc->realize();
- Camera *camera = new Camera;
- camera->setGraphicsContext(gc);
- // If a viewport isn't set on the camera, then it's
- // hard to dig it out of the SceneView objects in the
- // viewer, and the coordinates of mouse events are
- // somewhat bizzare.
- camera->setViewport(new Viewport(0, 0, cameraTraits->width,
- cameraTraits->height));
- const char* cameraName = cameraNode->getStringValue("name");
- string cameraNameString = (cameraName ? string(cameraName)
- : makeName(defaultName, i));
- GraphicsWindow* window = wsa->registerWindow(gc,
- cameraNameString);
- Camera3D* cam3D = wsa->registerCamera3D(window, camera,
- cameraNameString);
- if (shearx == 0 && sheary == 0)
- cam3D->flags |= Camera3D::MASTER;
- viewer->addSlave(camera, Matrix::translate(-shearx, -sheary, 0),
- Matrix());
- } else {
- SG_LOG(SG_GENERAL, SG_WARN,
- "Couldn't create graphics context on "
- << cameraTraits->hostName << ":"
- << cameraTraits->displayNum
- << "." << cameraTraits->screenNum);
+ SGPropertyNode* propNode = renderingNode->getChild(i);
+ const char* propName = propNode->getName();
+ if (!strcmp(propName, "window") || !strcmp(propName, "camera")) {
+ SGPropertyNode* copiedNode
+ = cgroupNode->getNode(propName, propNode->getIndex(), true);
+ copyProperties(propNode, copiedNode);
+ }
+ }
+ vector<SGPropertyNode_ptr> cameras = cgroupNode->getChildren("camera");
+ SGPropertyNode* masterCamera = 0;
+ BOOST_FOREACH(SGPropertyNode_ptr& camera, cameras) {
+ if (camera->getDoubleValue("shear-x", 0.0) == 0.0
+ && camera->getDoubleValue("shear-y", 0.0) == 0.0) {
+ masterCamera = camera.ptr();
+ break;