Ignore:
Timestamp:
Feb 10, 2011, 11:49:39 AM (13 years ago)
Author:
Torben Dannhauer
Message:

TRacking nodes by XML config should work now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/src/object/visual_object.cpp

    r222 r226  
    308308}
    309309
     310osg::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
    310357void visual_object::setNewPositionAttitude( double lat_, double lon_, double alt_, double azimuthAngle_psi_, double pitchAngle_theta_, double bankAngle_phi_ )
    311358{
Note: See TracChangeset for help on using the changeset viewer.