Difference between revisions of "NaviTrack Tutorial:Integrating:Application structure"

From NAMIC Wiki
Jump to: navigation, search
Line 23: Line 23:
 
   
 
   
 
     if (mtm) {
 
     if (mtm) {
       mtm->setTracker(pos, quat);
+
       // call member function of MyTutorial Module to handle events in NaviTrack
 +
       
 +
        ....
 +
       
 
     }
 
     }
 
   
 
   
Line 34: Line 37:
  
 
All you need to implement NaviTrack into your application is to make a main eternal loop and call context.loopOnce() function for each cycle. In context.loopOnce(), all events in NaviTrack data stream are pushed and pulled once.
 
All you need to implement NaviTrack into your application is to make a main eternal loop and call context.loopOnce() function for each cycle. In context.loopOnce(), all events in NaviTrack data stream are pushed and pulled once.
 +
 +
Followings are the rolles of other functions shown in above code.
 +
 +
===addSPLModules()===
 +
This funciton registers NaviTrack modules which are not in the original version of OpenTracker.
 +
 +
===context.parseConfiguration()===
 +
This function parses NaviTrack configuration XML file.
 +
 +
===context.getModule()===
 +
This function is used to get a pointer to a specific module.

Revision as of 00:47, 25 May 2007

Home < NaviTrack Tutorial:Integrating:Application structure

Basic Structure of your application

int main(int argc, char **argv)
{

  // initialization code here

   ....

  // context loop

  addSPLModules();

  Context context(1);
  context.parseConfiguration(xmlfilename);
  context.start();

  MyTutorialModule* mtm = (MyTutorialModule*) context.getModule("MyTutorialConfig");

  while (stopflag == 0) {

    stopflag = context.loopOnce();

    if (mtm) {
      // call member function of MyTutorial Module to handle events in NaviTrack
       
        ....
       
    }

    usleep(interval)
  }

  context.close();

}

All you need to implement NaviTrack into your application is to make a main eternal loop and call context.loopOnce() function for each cycle. In context.loopOnce(), all events in NaviTrack data stream are pushed and pulled once.

Followings are the rolles of other functions shown in above code.

addSPLModules()

This funciton registers NaviTrack modules which are not in the original version of OpenTracker.

context.parseConfiguration()

This function parses NaviTrack configuration XML file.

context.getModule()

This function is used to get a pointer to a specific module.