routeTester

Introduction

This is a small example illustrating the use of routes in X3DToolKit. Routes are specified in the X3D scene graph but no dynamic behaviour is defined. We show how to use the X3DTK::X3DRoute class from a scene graph.

Some important functions and classes:

Main

We define a loader and a saver to memorize the changes. We get the routes of the scene and iterate them to display them in text mode and build an X3DTK::X3DRoute to send the values.

Code

Main.cpp

#include <X3DTK/kernel.h>
#include <X3DTK/X3D/scenegraph.h>
#include <X3DTK/X3D/scenesaver.h>
#include <iostream>

using namespace X3DTK;
using namespace std;

int main(int argc, char *argv[])
{
  if (argc <= 1)
  {
    cerr << "usage: routetester input" << endl;
    exit(0);
  }

  // Loader to load the default X3D Nodes
  X3D::Loader *loader = new X3D::Loader();
  X3D::Scene *s = loader->load(argv[1], false);
  X3D::SceneSaver *saver = new X3D::SceneSaver();

  // Getting the routes of the scene
  MFRoute routes = s->getRoutes();
  
  // Iterating the routes
  for (MFRoute::const_iterator it = routes.begin(); it != routes.end(); ++it)
  {
    cout << "route = " << (*it)->getFromNode() << ", " << (*it)->getFromField() << " - " << (*it)->getToNode() << ", " << (*it)->getToField() << endl;
    (*it)->send();
  }
  
  saver->saveAs(s, "myFile.x3d");  
        
  return 1;
}

Generated on Fri Jul 30 12:02:33 2004 for X3DToolKit by doxygen 1.3.6