Changeset 226 for osgVisual


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

TRacking nodes by XML config should work now

Location:
osgVisual/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/include/object/visual_object.h

    r223 r226  
    7777        #include <leakDetection.h>
    7878public:
     79        //META_Object(osgVisual,visual_object);
     80
    7981        /**
    8082         * \brief Constuctor: Adds this object to the scenegraph,
     
    9395
    9496        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_);
    95106
    96107
  • osgVisual/trunk/include/util/visual_util.h

    r221 r226  
    3434#include <osgUtil/LineSegmentIntersector>
    3535
     36
     37
    3638#ifdef FUNFUNCTIONS_ENABLED
    3739#ifdef WIN32
  • osgVisual/trunk/src/core/visual_core.cpp

    r225 r226  
    288288                                if(cur_node->type == XML_ELEMENT_NODE && name == "trackmodel")
    289289                                {
    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                                       
    293300                                }
    294301                        }
     
    543550void visual_core::trackNode( int trackingID )
    544551{
    545         osg::Node tmp = util::findNodeByTrackingID(trackingID);
     552        osg::ref_ptr<osg::Node> tmp = visual_object::findNodeByTrackingID(trackingID, rootNode);
    546553        if(tmp.valid())
    547554                trackNode(tmp);
  • 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{
  • osgVisual/trunk/src/util/visual_util.cpp

    r221 r226  
    237237   }
    238238   else
    239    {
    240       return NULL; // leaf node, no match
    241    }
     239           return NULL; // leaf node, no match
    242240}
    243241
Note: See TracChangeset for help on using the changeset viewer.