Changeset 226
- Timestamp:
- Feb 10, 2011, 11:49:39 AM (14 years ago)
- Location:
- osgVisual/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/include/object/visual_object.h
r223 r226 77 77 #include <leakDetection.h> 78 78 public: 79 //META_Object(osgVisual,visual_object); 80 79 81 /** 80 82 * \brief Constuctor: Adds this object to the scenegraph, … … 93 95 94 96 static visual_object* createNodeFromXMLConfig(osg::CoordinateSystemNode* sceneRoot_, xmlNode* a_node); 97 98 /** 99 * \brief This functions searches in the scene graph for a node with a tracking ID 100 * 101 * @param trackingID : Id to search for. 102 * @param currNode_ : Scene graph to search in. 103 * @return : Pointer to the first found node, otherwise NULL. 104 */ 105 static osg::Node* findNodeByTrackingID(int trackingID, osg::Node* currNode_); 95 106 96 107 -
osgVisual/trunk/include/util/visual_util.h
r221 r226 34 34 #include <osgUtil/LineSegmentIntersector> 35 35 36 37 36 38 #ifdef FUNFUNCTIONS_ENABLED 37 39 #ifdef WIN32 -
osgVisual/trunk/src/core/visual_core.cpp
r225 r226 288 288 if(cur_node->type == XML_ELEMENT_NODE && name == "trackmodel") 289 289 { 290 // Extract model to track 291 292 trackNode( testObj4 ); 290 // Extract track-ID and track the model 291 xmlAttr *attr = cur_node->properties; 292 while ( attr ) 293 { 294 std::string attr_name=reinterpret_cast<const char*>(attr->name); 295 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 296 if( attr_name == "id" ) trackNode( util::strToInt(attr_value) ); 297 attr = attr->next; 298 } 299 293 300 } 294 301 } … … 543 550 void visual_core::trackNode( int trackingID ) 544 551 { 545 osg:: Node tmp = util::findNodeByTrackingID(trackingID);552 osg::ref_ptr<osg::Node> tmp = visual_object::findNodeByTrackingID(trackingID, rootNode); 546 553 if(tmp.valid()) 547 554 trackNode(tmp); -
osgVisual/trunk/src/object/visual_object.cpp
r222 r226 308 308 } 309 309 310 osg::Node* visual_object::findNodeByTrackingID(int trackingID, osg::Node* currNode_) 311 { 312 osg::Group* currGroup; 313 osg::Node* foundNode; 314 315 // check to see if we have a valid (non-NULL) node. 316 // if we do have a null node, return NULL. 317 if ( !currNode_) 318 { 319 return NULL; 320 } 321 322 // We have a valid node, check to see if this is the node we 323 // are looking for. If so, return the current node. 324 if (currNode_->className() == "visual_object") 325 { 326 //Check if it is the right tracking Id 327 osgVisual::visual_object* tmp = dynamic_cast<osgVisual::visual_object*>(currNode_); 328 if(tmp && tmp->getTrackingId()==trackingID) 329 return currNode_; 330 } 331 332 // We have a valid node, but not the one we are looking for. 333 // Check to see if it has children (non-leaf node). If the node 334 // has children, check each of the child nodes by recursive call. 335 // If one of the recursive calls returns a non-null value we have 336 // found the correct node, so return this node. 337 // If we check all of the children and have not found the node, 338 // return NULL 339 currGroup = currNode_->asGroup(); // returns NULL if not a group. 340 if ( currGroup ) 341 { 342 for (unsigned int i = 0 ; i < currGroup->getNumChildren(); i ++) 343 { 344 foundNode = findNodeByTrackingID( trackingID, currGroup->getChild(i)); 345 if (foundNode) 346 { 347 std::cout << "Node gefunden in Ebene: " << i << std::endl; 348 return foundNode; // found a match! 349 } 350 } 351 return NULL; // We have checked each child node - no match found. 352 } 353 else 354 return NULL; // leaf node, no match 355 } 356 310 357 void visual_object::setNewPositionAttitude( double lat_, double lon_, double alt_, double azimuthAngle_psi_, double pitchAngle_theta_, double bankAngle_phi_ ) 311 358 { -
osgVisual/trunk/src/util/visual_util.cpp
r221 r226 237 237 } 238 238 else 239 { 240 return NULL; // leaf node, no match 241 } 239 return NULL; // leaf node, no match 242 240 } 243 241
Note: See TracChangeset
for help on using the changeset viewer.