int ConfigManager::attemptReconfiguration() { int elements_processed(0); // Needs to return this value // Copy the contents of the incoming config element list to the pending // list. Config element handlers may have added new elements to the // incoming list. mergeIncomingToPending(); if ( shouldCheckPending() ) { vprDEBUG_OutputGuard(vprDBG_ALL, vprDBG_STATE_LVL, std::string("ConfigManager::attemptReconfiguration: Examining pending list.\n"), std::string("ConfigManager::attemptReconfiguration: Done Examining pending list.\n")); lockPending(); for (unsigned int i = 0 ; i < mElementHandlers.size() ; i++) { elements_processed += mElementHandlers[i]->configProcessPending(); } unlockPending(); } /* if ( elements_processed > 0 ) { mConfigCommunicator->configChanged(); } */ return elements_processed; }
void D3dDrawManager::drawAllPipes() { vprDEBUG_OutputGuard(vrjDBG_DRAW_MGR, vprDBG_HVERB_LVL, "vrj::GLDrawManager::drawAllPipes()\n", "vrj::GLDrawManager::drawAllPipes() done.\n"); checkForNewWindows(); for (unsigned int i = 0; i < mOpenWins.size(); i++) { D3dWindow* win = mOpenWins[i]; win->checkEvents(); renderWindow(win); swapWindowBuffers(win); } }
void OpenSGNavGrab::initScene() { vprDEBUG_OutputGuard(vprDBG_ALL, vprDBG_CRITICAL_LVL, "OpenSGNavGrab::initScene() called.\n", "OpenSGNavGrab::initScene() exiting.\n"); // Set up the node highlighting state. initHighlight(); mModelRoot = OSG::Node::create(); mModelGroup = OSG::Group::create(); #if OSG_MAJOR_VERSION < 2 CPEdit(mModelRoot, OSG::Node::CoreFieldMask); #endif mModelRoot->setCore(mModelGroup); // Load the model to use. if ( mFilesToLoad.empty() ) { vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "[OpenSGNavGrab::initScene()] No model specified; creating box." << std::endl << vprDEBUG_FLUSH; // Box geometry: 2.5x2.5x2.5 (units are in feet) // Center point: (0,0,0) OSG::NodeRefPtr geom_node(OSG::makeBox(2.5f, 2.5f, 2.5f, 1, 1, 1)); // Move it so that it would butt up against a wall five feet in front // of the user and another wall five feet to the left of the user. // If the application units were meters, this placement would be very // different. OSG::Matrix init_geom_pos; init_geom_pos.setTransform(OSG::Vec3f(-3.75f, 1.25f, -3.75f)); mObjects.push_back(makeGrabbable(geom_node, init_geom_pos)); } else { OSG::Vec3f distance_vec; OSG::Pnt3f::RealReturnType max_dist(0.0f); std::vector<OSG::NodeRefPtr> nodes; // Load all the models that the user told us to load. typedef std::vector<std::string>::iterator iter_type; for ( iter_type i = mFilesToLoad.begin(); i != mFilesToLoad.end(); ++i ) { vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) << "[OpenSGNavGrab::initScene()] Loading '" << *i << "' ..." << std::endl << vprDEBUG_FLUSH; const OSG::Char8* file = (*i).c_str(); OSG::NodeRefPtr geom_node( #if OSG_MAJOR_VERSION < 2 OSG::SceneFileHandler::the().read(file) #else OSG::SceneFileHandler::the()->read(file) #endif ); nodes.push_back(geom_node); // Needed to get the volume set up after creating the geometry. geom_node->updateVolume(); OSG::DynamicVolume volume = geom_node->getVolume(); OSG::Pnt3f min, max; volume.getBounds(min, max); // Calculate the distance between min and max. The largest distance // will be used for spacing out the objects. OSG::Pnt3f::RealReturnType dist(max.dist(min)); // Keep track of the maximum-sized bounding volume. if ( dist > max_dist ) { max_dist = dist; distance_vec = max - min; } } std::cout << "distance_vec: " << distance_vec << std::endl; // If we have loaded any models, we will position them along the X-axis. // The extents of the line of models is based on the bounding volume of // the largest model and the number of models. The line of models is // centered on the origin. Hence, half the models will be have a // negative X translation value, and half will have a positive X // translation value. if ( ! nodes.empty() ) { const std::vector<OSG::NodeRefPtr>::size_type num_objs(nodes.size()); const OSG::Real32 interval_dist(distance_vec[0]); // Set the left extreme of the line of models. The full extent of // the model range is interval_dist * num_objs. To center things // on the origin, we divide that value by 2. Since x_offset will // be used for the new center point of the model (see below), we // shift the starting point (interval_dist / 2) units so that some // model will end up centered on the origin. OSG::Real32 x_offset = -(interval_dist * OSG::Real32(num_objs) - interval_dist) / 2.0f; typedef std::vector<OSG::NodeRefPtr>::iterator iter_type; for ( iter_type i = nodes.begin(); i != nodes.end(); ++i, x_offset += interval_dist ) { // Get the center point of the current node and change its X // component to be the current x_offset value. const OSG::DynamicVolume& volume = (*i)->getVolume(); OSG::Pnt3f center; volume.getCenter(center); center[0] = x_offset; // The transformation matrix xform_mat will be the "home" position // for the model. OSG::Matrix xform_mat; xform_mat.setTranslate(center); mObjects.push_back(makeGrabbable(*i, xform_mat)); } } } // --- Light setup --- // // - Add directional light for scene // - Create a beacon for it and connect to that beacon mLightNode = OSG::Node::create(); mLightBeacon = OSG::Node::create(); OSG::DirectionalLightPtr light_core = OSG::DirectionalLight::create(); OSG::TransformPtr light_beacon_core = OSG::Transform::create(); // Set up light beacon OSG::Matrix light_pos; light_pos.setTransform(OSG::Vec3f(2.0f, 5.0f, 4.0f)); #if OSG_MAJOR_VERSION < 2 CPEdit(light_beacon_core, OSG::Transform::MatrixFieldMask); CPEdit(mLightBeacon, OSG::Node::CoreFieldMask); CPEdit(mLightNode, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); CPEditAll(light_core); #endif light_beacon_core->setMatrix(light_pos); mLightBeacon->setCore(light_beacon_core); // Set up light node mLightNode->setCore(light_core); mLightNode->addChild(mLightBeacon); light_core->setAmbient(0.9, 0.8, 0.8, 1); light_core->setDiffuse(0.6, 0.6, 0.6, 1); light_core->setSpecular(1, 1, 1, 1); light_core->setDirection(0, 0, 1); light_core->setBeacon(mLightNode); // --- Set up scene -- // // add the loaded scene to the light node, so that it is lit by the light mLightNode->addChild(mModelRoot); // create the root part of the scene mSceneRoot = OSG::Node::create(); mSceneTransform = OSG::Transform::create(); #if OSG_MAJOR_VERSION < 2 CPEdit(mSceneRoot, OSG::Node::CoreFieldMask | OSG::Node::ChildrenFieldMask); #endif // Set up the root node mSceneRoot->setCore(mSceneTransform); mSceneRoot->addChild(mLightNode); }