Ejemplo n.º 1
0
int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("A red cone."); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoSeparator *root = new SoSeparator;
	SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
	SoMaterial *myMaterial = new SoMaterial;
	root->ref();
	root->addChild(myCamera);
	root->addChild(new SoDirectionalLight);
	myMaterial->diffuseColor.setValue(1.0, 1.0, 0.0); // Red
	root->addChild(myMaterial);

	root->addChild(new SoCone);
	// Create a renderArea in which to see our scene graph.
	// The render area will appear within the main window.
	SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
	// Make myCamera see everything.
	myCamera->viewAll(root, myRenderArea->getViewportRegion());
	// Put our scene in myRenderArea, change the title
	myRenderArea->setSceneGraph(root);
	myRenderArea->setTitle("A red cone");
	myRenderArea->show();
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	delete myRenderArea;
	root->unref();
	return 0;
}
Ejemplo n.º 2
0
int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("Water molecule"); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoGroup *waterMolecule = new SoGroup; // water molecule
	SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
	SoGroup *oxygen = new SoGroup; // oxygen atom
	SoMaterial *redPlastic = new SoMaterial;
	SoSphere *sphere1 = new SoSphere;
	SoGroup *hydrogen1 = new SoGroup; // hydrogen atoms
	SoGroup *hydrogen2 = new SoGroup;
	SoTransform *hydrogenXform1 = new SoTransform;
	SoTransform *hydrogenXform2 = new SoTransform;
	SoMaterial *whitePlastic = new SoMaterial;
	SoSphere *sphere2 = new SoSphere;
	SoSphere *sphere3 = new SoSphere;
	// Set all field values for the oxygen atom
	redPlastic->ambientColor.setValue(1.0, 0.0, 0.0);
	redPlastic->diffuseColor.setValue(1.0, 0.0, 0.0);
	redPlastic->specularColor.setValue(0.5, 0.5, 0.5);
	redPlastic->shininess = 0.5;
	// Set all field values for the hydrogen atoms
	hydrogenXform1->scaleFactor.setValue(0.75, 0.75, 0.75);
	hydrogenXform1->translation.setValue(0.1, 1.2, 1.0);
	hydrogenXform2->translation.setValue(0.0, -3.2, 0.0);
	whitePlastic->ambientColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->diffuseColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->specularColor.setValue(0.5, 0.5, 0.5);
	whitePlastic->shininess = 0.5;
	// Create a hierarchy
	waterMolecule->ref();
	waterMolecule->addChild(oxygen);
	waterMolecule->addChild(hydrogen1);
	waterMolecule->addChild(hydrogen2);
	oxygen->addChild(redPlastic);
	oxygen->addChild(sphere1);
	hydrogen1->addChild(hydrogenXform1);
	hydrogen1->addChild(whitePlastic);
	hydrogen1->addChild(sphere2);
	hydrogen2->addChild(hydrogenXform2);
	hydrogen2->addChild(sphere3);
	SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
	// Make myCamera see everything.
	myCamera->viewAll(waterMolecule, myRenderArea->getViewportRegion());
	// Put our scene in myRenderArea, change the title
	myRenderArea->setSceneGraph(waterMolecule);
	myRenderArea->setTitle("Water molecule");
	myRenderArea->show();
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	delete myRenderArea;
	waterMolecule->unref();
	return 0;
}
Ejemplo n.º 3
0
int
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
        int nCmdShow)
{
#else // UNIX

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

#endif

  // initialize Coin and glut libraries
  SoDB::init();

#ifdef _WIN32
  int argc = 1;
  char * argv[] = { "glutiv.exe", (char *) NULL };
  glutInit(&argc, argv);
#else
  glutInit(&argc, argv);
#endif

  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

  SoSeparator * root;
  root = new SoSeparator;
  root->ref();
  SoPerspectiveCamera * camera = new SoPerspectiveCamera;
  root->addChild(camera);
  root->addChild(new SoDirectionalLight);
  root->addChild(createScenegraph());

  scenemanager = new SoSceneManager;
  scenemanager->setRenderCallback(redraw_cb, (void *)1);
  scenemanager->setBackgroundColor(SbColor(0.2f, 0.2f, 0.2f));
  scenemanager->activate();
  camera->viewAll(root, scenemanager->getViewportRegion());
  scenemanager->setSceneGraph(root);
  
  glutInitWindowSize(512, 400);
  SbString title("Offscreen Rendering");
  glutwin = glutCreateWindow(title.getString());
  glutDisplayFunc(expose_cb);
  glutReshapeFunc(reshape_cb);
 
  // start main loop processing (with an idle callback)

  glutIdleFunc(idle_cb);
  glutMainLoop();

  root->unref();
  delete scenemanager;
  return 0;
}
Ejemplo n.º 4
0
int
main(int , char **argv)
{
    // Initialize Inventor. This returns a main window to use.
    // If unsuccessful, exit.
    QWidget* myWindow = SoQt::init(argv[0]); // pass the app name
    if (myWindow == NULL) exit(1);

    // Make a scene containing a red cone
    SoSeparator *root = new SoSeparator;
    SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
    SoMaterial *myMaterial = new SoMaterial;
    root->ref();
    root->addChild(myCamera);
    root->addChild(new SoDirectionalLight);
    myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);   // Red
    root->addChild(myMaterial);


//   GsTL_SoNode::initClass();
    GsTL_SoNode* obj = new GsTL_SoNode;
    obj->addChild(new SoCone);
    root->addChild( obj );
    obj->visible = true;


    // Create a renderArea in which to see our scene graph.
    // The render area will appear within the main window.
    SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);

    // Make myCamera see everything.
    myCamera->viewAll(root, myRenderArea->getViewportRegion());

    // Put our scene in myRenderArea, change the title
    myRenderArea->setSceneGraph(root);
    myRenderArea->setTitle("Hello Cone");
    myRenderArea->show();

    SoQt::show(myWindow);  // Display main window
    SoQt::mainLoop();      // Main Inventor event loop
}
Ejemplo n.º 5
0
SoSeparator *
createScenegraph(void)
{
  SoSeparator * texroot = new SoSeparator;
  texroot->ref();
  SoInput in;
  in.setBuffer(red_cone_iv, strlen(red_cone_iv));
  
  SoSeparator * result = SoDB::readAll(&in);
  if (result == NULL) { exit(1); }
 
  SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
  SoRotationXYZ *rot = new SoRotationXYZ;
  rot->axis  = SoRotationXYZ::X;
  rot->angle = M_PI_2;
  myCamera->position.setValue(SbVec3f(-0.2, -0.2, 2.0));
  myCamera->scaleHeight(0.4);
  texroot->addChild(myCamera);
  texroot->addChild(new SoDirectionalLight);
  texroot->addChild(rot);
  texroot->addChild(result);
  myCamera->viewAll(texroot, SbViewportRegion());

  // Generate the texture map
  SoTexture2 *texture = new SoTexture2;
  texture->ref();
  if (generateTextureMap(texroot, texture, 128, 128))
    printf ("Successfully generated texture map\n");
  else
    printf ("Could not generate texture map\n");
  texroot->unref();

  // Make a scene with a cube and apply the texture to it
  SoSeparator * root = new SoSeparator;
  root->addChild(texture);
  root->addChild(new SoCube);
  return root;
}
Ejemplo n.º 6
0
static SoSeparator *
setUpGraph(const SbViewportRegion &vpReg,
	   SoInput *sceneInput,
	   Options &options)
//
//////////////////////////////////////////////////////////////
{

    // Create a root separator to hold everything. Turn
    // caching off, since the transformation will blow
    // it anyway.
    SoSeparator *root = new SoSeparator;
    root->ref();
    root->renderCaching = SoSeparator::OFF;

    // Add a camera to view the scene
    SoPerspectiveCamera *camera = new SoPerspectiveCamera;
    root->addChild(camera);

    // Add a transform node to spin the scene
    SoTransform *sceneTransform = new SoTransform;
    sceneTransform->setName(SCENE_XFORM_NAME);
    root->addChild(sceneTransform);

    // Read and add input scene graph
    SoSeparator *inputRoot = SoDB::readAll(sceneInput);
    if (inputRoot == NULL) {
	fprintf(stderr, "Cannot read scene graph\n");
	root->unref();
	exit(1);
    }
    root->addChild(inputRoot);

    SoPath 	*path;
    SoGroup	*parent, *group;
    SoSearchAction	act;

    // expand out all File nodes and replace them with groups
    //    containing the children
    SoFile 	*fileNode;
    act.setType(SoFile::getClassTypeId());
    act.setInterest(SoSearchAction::FIRST);
    act.apply(inputRoot);
    while ((path = act.getPath()) != NULL) {
	fileNode = (SoFile *) path->getTail();
	path->pop();
	parent = (SoGroup *) path->getTail();
	group = fileNode->copyChildren();
	if (group) {
	    parent->replaceChild(fileNode, group);
	    // apply action again and continue
	    act.apply(inputRoot);
	}
    }

    // expand out all node kits and replace them with groups
    //    containing the children
    SoBaseKit	*kitNode;
    SoChildList	*childList;
    act.setType(SoBaseKit::getClassTypeId());
    act.setInterest(SoSearchAction::FIRST);
    act.apply(inputRoot);
    while ((path = act.getPath()) != NULL) {
	kitNode = (SoBaseKit *) path->getTail();
	path->pop();
	parent = (SoGroup *) path->getTail();
	group = new SoGroup;
	childList = kitNode->getChildren();
	for (int i=0; i<childList->getLength(); i++) 
	    group->addChild((*childList)[i]);
	parent->replaceChild(kitNode, group);
	act.apply(inputRoot);
    }

    // check to see if there are any lights
    // if no lights, add a directional light to the scene
    act.setType(SoLight::getClassTypeId());
    act.setInterest(SoSearchAction::FIRST);
    act.apply(inputRoot);
    if (act.getPath() == NULL) { // no lights
	SoDirectionalLight *light = new SoDirectionalLight;
	root->insertChild(light, 1);
    }
    else 
	options.hasLights = TRUE;

    // check to see if there are any texures in the scene
    act.setType(SoTexture2::getClassTypeId());
    act.setInterest(SoSearchAction::FIRST);
    act.apply(inputRoot);
    if (act.getPath() != NULL)
	options.hasTextures = TRUE;

    camera->viewAll(root, vpReg);

    // print out information about the scene graph

    int32_t numTris, numLines, numPoints, numNodes;
    countPrimitives( inputRoot, numTris, numLines, numPoints, numNodes );
    printf("Number of nodes in scene graph:     %d\n", numNodes );
    printf("Number of triangles in scene graph: %d\n", numTris );
    printf("Number of lines in scene graph:     %d\n", numLines );
    printf("Number of points in scene graph:    %d\n\n", numPoints );

    // Make the center of rotation the center of
    // the scene
    SoGetBoundingBoxAction	bba(vpReg);
    bba.apply(root);
    sceneTransform->center = bba.getBoundingBox().getCenter();

    return root;
}
Ejemplo n.º 7
0
int
main(int argc, char ** argv)

#endif

{
  // initialize Coin and glut libraries

  SoDB::init();
  SoNodeKit::init();
  SoInteraction::init();

#ifdef _WIN32
  int argc = 1;
  char * argv[] = { "glutiv.exe", (char *) NULL };
  glutInit(&argc, argv);
#else
  glutInit(&argc, argv);
#endif
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

  // Note: _don't_ use SoGroup, as TGS' Inventor has a bug where
  // lightsource contribution will get accumulated over runs.
  SoSeparator * root[SCENEWINDOWS];

  for (unsigned int i=0; i < SCENEWINDOWS; i++) {
    // set up individual parts of scenegraph

    root[i] = new SoSeparator;
    root[i]->ref();
    SoPerspectiveCamera * camera = new SoPerspectiveCamera;
    root[i]->addChild(camera);
    root[i]->addChild(new SoDirectionalLight);
    SoDrawStyle * drawstyle = new SoDrawStyle;
    drawstyle->style.setValue(i % 3);
    root[i]->addChild(drawstyle);
    root[i]->addChild(commongraph());

    // initialize scenemanager instance

    scenemanager[i] = new SoSceneManager;
    scenemanager[i]->setRenderCallback(redraw_cb, (void *)i);
    scenemanager[i]->setBackgroundColor(SbColor(0.2f, 0.2f, i * 0.2f));
    scenemanager[i]->activate();
    camera->viewAll(root[i], scenemanager[i]->getViewportRegion());
    scenemanager[i]->setSceneGraph(root[i]);

    // glut window initialization

    glutInitWindowSize(512, 400);
    SbString title("window ");
    title += (char)(i + 0x30);
    glutwin[i] = glutCreateWindow(title.getString());
    glutDisplayFunc(expose_cb);
    glutReshapeFunc(reshape_cb);
  }

  SoDB::setRealTimeInterval(1/120.0);

  // start main loop processing (with an idle callback)

  glutIdleFunc(idle_cb);
  glutMainLoop();

  // clean up Coin resource use

  for (int j=0; j < SCENEWINDOWS; j++) {
    root[j]->unref();
    delete scenemanager[j];
  }

  return 0;
}
Ejemplo n.º 8
0
int main(int argc, char * argv[])
{
  /* Default values of program arguments. */
  char * heightmap_name = NULL;
  int triangle_count = 1000;
  int tile_size = 33;
  int pixel_error = 6;
  int edgeSize = 4096;
  int xOffset = 0;
  int yOffset = 0;
  bool drawWater = false;

  SbBool is_full_screen = FALSE;
  SbBool is_frustrum_culling = TRUE;

  /* Get program arguments. */
  int command = 0;
  while ((command = getopt(argc, argv, "h:x:y:s:S:a:e:r:g:fcW")) != -1)
  {
    switch (command)
    {
      /* Heightmap. */
      case 'h':
      {
        heightmap_name = optarg;
      }
      break;
      /* Algorithm. */
      case 'a':
      {
        if (!strcmp(optarg, "roam"))
        {
          algorithm = ID_ALG_ROAM;
        }
        else if (!strcmp(optarg, "geomipmapping"))
        {
          algorithm = ID_ALG_GEO_MIPMAP;
        }
        else if (!strcmp(optarg, "chunkedlod"))
        {
          algorithm = ID_ALG_CHUNKED_LOD;
        }
        else if (!strcmp(optarg, "brutalforce"))
        {
          algorithm = ID_ALG_BRUAL_FORCE;
        }
      }
      break;
      /* Size of the plot map, in data points a long one edge (map is a square). */
      case 's':
      {
        sscanf(optarg, "%d", &edgeSize);
      }
      /* Scaling factor. */
      case 'S':
      {
        sscanf(optarg, "%d", &scaleFactor);
      }
      break;
      /* X offset in data points. */
      case 'x':      {
        sscanf(optarg, "%d", &xOffset);
      }
      break;
      /* Y offset in data points. */
      case 'y':      {
        sscanf(optarg, "%d", &yOffset);
      }
      break;
      /* Pixel error of rendering. */
      case 'e':
      {
        sscanf(optarg, "%d", &pixel_error);
      }
      break;
      /* Number of triangles in triangulation. */
      case 'r':
      {
        sscanf(optarg, "%d", &triangle_count);
      }
      break;
      /* Tile side size. */
      case 'g':
      {
        sscanf(optarg, "%d", &tile_size);
      }
      break;
      /* Fullscreen. */
      case 'f':
      {
        is_full_screen = TRUE;
      }
      break;
      /* Frustrum culling. */
      case 'c':
      {
        is_frustrum_culling = FALSE;
      }
      break;
      /* Draw water line. */
      case 'W':
      {
        drawWater = true;
      }
      break;
      case '?':
      {
        std::cout << "Unknown option!" << std::endl;
        help();
        exit(1);
      }
      break;
    }
  }

  /* Check obligatory arguments. */
  if (heightmap_name == NULL)
  {
    std::cout << "Input height map wasn't specified!" << std::endl;
    help();
    exit(1);
  }

  /* Load heightmap. */
  int height = 0;

  // SoTerrain only seems to handle size which
  // are multiples of 1024.  The +1 maybe due
  // to some sloppiness some later in the code
  // (i.e. "<" vs "<=" or something).
  int width = edgeSize +1; // 1024 + 1;// 1024 * 4 + 1;
  height = width;

  PR_INIT_PROFILER();

  /* Set environment variables. */
  //putenv("IV_SEPARATOR_MAX_CACHES=0");
  putenv((char*)"COIN_SHOW_FPS_COUNTER=1");
  //putenv("COIN_AUTO_CACHING=0");

  /* Create window. */
  QWidget * window;
  if ((window = SoQt::init(argc, argv, "SoTerrain Test Application")) == NULL)
  {
    exit(1);
  }

  /* Initialization of custom Inventor classes. */
  SoSimpleROAMTerrain::initClass();
  SoSimpleGeoMipmapTerrain::initClass();
  SoSimpleChunkedLoDTerrain::initClass();
  SoProfileGroup::initClass();

  /* Create scene graph. */
  SoProfileGroup *root = new SoProfileGroup();
  SoEventCallback *style_callback = new SoEventCallback();
  SoPerspectiveCamera *camera = new SoPerspectiveCamera();
  SoDrawStyle *style = new SoDrawStyle();
  SoDirectionalLight *light = new SoDirectionalLight();
  SoSeparator *separator = new SoSeparator();
  SoSeparator *terrainSeparator = new SoSeparator();
  SoSeparator *markers = new SoSeparator();

  // not sure turning off Culling here is having any effect.
  terrainSeparator->pickCulling.setValue(SoSeparator::OFF);
  terrainSeparator->renderCulling.setValue(SoSeparator::OFF);
 
  SoEventCallback *terrain_callback = new SoEventCallback();

  /* Use the TerrainBuilder class to generating the various components. */
  TerrainBuilder terrainBuilder;
  terrainBuilder.setHeight(height);
  terrainBuilder.setWidth(width);
  terrainBuilder.initialize();
  terrainBuilder.setScalingFactor(scaleFactor);
  terrainBuilder.setYOffset(yOffset);
  terrainBuilder.setXOffset(xOffset);

  terrainBuilder.loadXYZFile(heightmap_name, 4801 * 4801);

  SoTexture2 *texture = terrainBuilder.getTexture();
  SoTextureCoordinate2 *texture_coords = terrainBuilder.getTextureCoordinates();
  SoCoordinate3 *coords = terrainBuilder.getMapCoordinates();
  SoNormal *normals = terrainBuilder.getNormals();

  SoNormalBinding *normal_binding = new SoNormalBinding();

  ref_long = terrainBuilder.getRefLong();
  ref_lat  = terrainBuilder.getRefLat();

  style_callback->addEventCallback(SoKeyboardEvent::getClassTypeId(),
    styleCallback, style);
  light->direction.setValue(-0.5f, 0.5f, -1.0f);
  normal_binding->value.setValue(SoNormalBinding::PER_VERTEX_INDEXED);

  // Create the push pin marker.
  marker_lat = 37.753;
  marker_long = -122.440;
  SoResetTransform *resetForTerrain = new SoResetTransform();

  MarkerPin *marker = new MarkerPin();
  marker->setScalingFactor(scaleFactor);
  marker->setReferencePosition(ref_lat, ref_long);
  marker->setLabel("San Francisco");
  marker->setLocation(marker_lat, marker_long, 0.0);

  SoEventCallback * marker_callback = new SoEventCallback();
   marker_callback->addEventCallback(
       SoKeyboardEvent::getClassTypeId(),
       markerCallback,
       marker);

  vesselMarker = new MarkerPin();
  vesselMarker->setScalingFactor(scaleFactor);
  vesselMarker->setReferencePosition(ref_lat, ref_long);
  vesselMarker->setLabel("Farralon");
  vesselMarker->setLocation(37.7, -123.0, 0.0);

  /* Connect scene graph nodes. */
  root->ref();
  root->addChild(style);
  root->addChild(separator);
  separator->addChild(terrain_callback);
  separator->addChild(style_callback);
  separator->addChild(marker_callback);
  separator->addChild(camera);
  separator->addChild(light);
  separator->addChild(terrainSeparator);
  
  terrainSeparator->addChild(resetForTerrain);
  terrainSeparator->addChild(texture);
  terrainSeparator->addChild(texture_coords);
  terrainSeparator->addChild(coords);
  terrainSeparator->addChild(normals);
  terrainSeparator->addChild(normal_binding);
  
  separator->addChild(markers);
  separator->addChild(marker->getSoMarker());
  separator->addChild(vesselMarker->getSoMarker());
  // Water drawing has performance issues.
  if (drawWater) {
    separator->addChild(terrainBuilder.getWater());
  }

  switch (algorithm)
  {
    case ID_ALG_ROAM:
    {
      SoSimpleROAMTerrain * terrain = new SoSimpleROAMTerrain();
      terrain->mapSize.setValue(width);
      terrain->pixelError.setValue(pixel_error);
      terrain->triangleCount.setValue(triangle_count);
      terrain->frustrumCulling.setValue(is_frustrum_culling);
      terrain_callback->addEventCallback(SoKeyboardEvent::getClassTypeId(),
	terrainCallback, terrain);
      terrainSeparator->addChild(terrain);
    }
    break;
    case ID_ALG_GEO_MIPMAP:
    {
      SoSimpleGeoMipmapTerrain * terrain = new SoSimpleGeoMipmapTerrain();
      terrain->mapSize.setValue(width);
      terrain->tileSize.setValue(tile_size);
      terrain->pixelError.setValue(pixel_error);
      terrain_callback->addEventCallback(SoKeyboardEvent::getClassTypeId(),
	terrainCallback, terrain);
      terrainSeparator->addChild(terrain);
    }
    break;
    case ID_ALG_CHUNKED_LOD:
    {
      SoSimpleChunkedLoDTerrain * terrain = new SoSimpleChunkedLoDTerrain();
      terrain->mapSize.setValue(width);
      terrain->tileSize.setValue(tile_size);
      terrain->pixelError.setValue(pixel_error);
      terrain_callback->addEventCallback(SoKeyboardEvent::getClassTypeId(),
	terrainCallback, terrain);
      terrainSeparator->addChild(terrain);
    }
    break;
    case ID_ALG_BRUAL_FORCE:
    {
      SoIndexedTriangleStripSet * terrain = new SoIndexedTriangleStripSet();

      /* Create terrain heightmap vertices indices. */
      terrain->coordIndex.setNum((height - 1) * ((2 * width) + 1));
      int * indices = terrain->coordIndex.startEditing();

      int I = 0;
      for (int Y = 0; Y < (height - 1); Y++)
      {
        for (int X = 0; X < width; X++)
        {
          indices[I++] = (Y * width) + X;
          indices[I++] = ((Y + 1) * width) + X;
        }
        indices[I++] = -1;
      }
      terrain->coordIndex.finishEditing();
      terrainSeparator->addChild(terrain);
    }
    break;
  }

//  terrainSeparator->addChild(terrainBuilder.getWater());

  /* Setup camera and render area. */
  SoQtFreeViewer * render_area = new SoQtFreeViewer(window);
  SoSceneManager * scene_manager = new SoSceneManager();
  render_area->setHeadlight(TRUE /*FALSE*/);
  render_area->setSceneManager(scene_manager);
  scene_manager->setRenderCallback(renderCallback, render_area);
  scene_manager->activate();
  camera->viewAll(root, render_area->getViewportRegion());
  camera->nearDistance.setValue(0.01f);
  render_area->setSceneGraph(root);
  render_area->setTitle("Terrain Viewer Application");
  render_area->setSize(SbVec2s(640, 480));
  render_area->show();
  render_area->setFullScreen(is_full_screen);

  camera->position.setValue(0 , 0, 1);

  // Use a SoIdleSensor to update marker position, this is because
  // we can't add new markers when the tree is still being traversed
  // (only when idle).
  SoIdleSensor * positionUpdater = new SoIdleSensor();
  positionUpdater->setFunction(updatePositionCallback);
  positionUpdater->setData(markers);

  // Use a SoTimeSensor to periodically schedule
  // the SoIdleSensor to update marker positions.
  SoTimerSensor * timerSensor = new SoTimerSensor(timerSensorCallback, root);
  timerSensor->setInterval(0.2f);
  timerSensor->setData(positionUpdater);
  timerSensor->schedule();

  /* Run application. */
  SoQt::show(window);
  SoQt::mainLoop();
  SoQt::done();

//  PR_PRINT_RESULTS(profile_name);

  /* Free memory. */
  root->unref();
  delete positionUpdater;
  delete render_area;

  return EXIT_SUCCESS;
}