コード例 #1
0
void AnimationTexture(SoSeparator * root)
{

  // Generate a julia set to use as a texturemap
  julia(cr, ci, 2.5, texturewidth, textureheight, 4, bitmap, 64);

 
  SoTexture2 * texnode = texture();

  // Enable backface culling
  SoShapeHints * hints = new SoShapeHints;

  hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
  hints->shapeType = SoShapeHints::SOLID;

  // Timer sensor
  SoTimerSensor * texturetimer = new SoTimerSensor(timersensorcallback, texnode);
  texturetimer->setInterval(0.05);
  texturetimer->schedule();

  // Scene graph
  if ( root == NULL ) return; // Shouldn't happen.
  root->ref(); // prevent from being deleted because of the still running timer sensor
//  SoSeparator * root = new SoSeparator;
//  root->ref();

  root->addChild(hints);
  root->addChild(texnode);
  root->addChild(new SoCube);

 }
コード例 #2
0
ファイル: RrtGuiWindow.cpp プロジェクト: TheMarex/simox
RrtGuiWindow::RrtGuiWindow(const std::string &sceneFile, const std::string &sConf, const std::string &gConf, 
	const std::string &rns, const std::string &colModelRob1, const std::string &colModelRob2,  const std::string &colModelEnv, Qt::WFlags flags)
:QMainWindow(NULL)
{
	VR_INFO << " start " << endl;

	this->sceneFile = sceneFile;
		
	allSep = new SoSeparator;
	allSep->ref();
	sceneFileSep = new SoSeparator;
	startGoalSep = new SoSeparator;
	rrtSep = new SoSeparator;
	
	allSep->addChild(sceneFileSep);
	allSep->addChild(startGoalSep);
	allSep->addChild(rrtSep);

	setupUI();
	
	loadScene();

	selectRNS(rns);
	selectStart(sConf);
	selectGoal(gConf);

	selectColModelRobA(colModelRob1);
	selectColModelRobB(colModelRob2);
	selectColModelEnv(colModelEnv);

	if (sConf!="")
		UI.comboBoxStart->setEnabled(false);
	if (gConf!="")
		UI.comboBoxGoal->setEnabled(false);
	if (rns!="")
		UI.comboBoxRNS->setEnabled(false);
	if (colModelRob1!="")
		UI.comboBoxColModelRobot->setEnabled(false);
	if (colModelRob2!="")
		UI.comboBoxColModelRobotStatic->setEnabled(false);
	//if (colModelEnv!="")
	//	UI.comboBoxColModelEnv->setEnabled(false);

	viewer->viewAll();

	SoSensorManager *sensor_mgr = SoDB::getSensorManager();
	SoTimerSensor *timer = new SoTimerSensor(timerCB, this);
	timer->setInterval(SbTime(TIMER_MS/1000.0f));
	sensor_mgr->insertTimerSensor(timer);
}
コード例 #3
0
ファイル: vpSimulator.cpp プロジェクト: tswang/visp
void
vpSimulator::mainLoop()
{
  if (mainWindowInitialized==false)
  {
    vpERROR_TRACE("main window is not opened ") ;
  }

  vpTime::wait(1000) ;

  // Timer sensor
  SoTimerSensor * timer = new SoTimerSensor(timerSensorCallback, (void *)this);
  timer->setInterval(0.01);
  timer->schedule();
  vpViewer::mainLoop() ;
}
コード例 #4
0
ファイル: IKRRTWindow.cpp プロジェクト: gkalogiannis/simox
IKRRTWindow::IKRRTWindow(std::string& sceneFile, std::string& reachFile, std::string& rns, std::string& eef, std::string& colModel, std::string& colModelRob, Qt::WFlags flags)
    : QMainWindow(NULL)
{
    VR_INFO << " start " << endl;

    this->sceneFile = sceneFile;
    this->reachFile = reachFile;
    eefName = eef;
    rnsName = rns;
    this->colModelName = colModel;
    this->colModelNameRob = colModelRob;

    sceneSep = new SoSeparator;
    sceneSep->ref();
    robotSep = new SoSeparator;
    objectSep = new SoSeparator;
    graspsSep = new SoSeparator;
    reachableGraspsSep = new SoSeparator;
    reachabilitySep = new SoSeparator;
    obstaclesSep = new SoSeparator;
    rrtSep = new SoSeparator;

    playbackMode = false;

    //sceneSep->addChild(robotSep);

    sceneSep->addChild(robotSep);
    sceneSep->addChild(objectSep);
    sceneSep->addChild(graspsSep);
    sceneSep->addChild(reachableGraspsSep);
    sceneSep->addChild(reachabilitySep);
    sceneSep->addChild(obstaclesSep);
    sceneSep->addChild(rrtSep);

    setupUI();

    loadScene();

    loadReach();

    viewer->viewAll();

    SoSensorManager* sensor_mgr = SoDB::getSensorManager();
    SoTimerSensor* timer = new SoTimerSensor(timerCB, this);
    timer->setInterval(SbTime(TIMER_MS / 1000.0f));
    sensor_mgr->insertTimerSensor(timer);
}
コード例 #5
0
ファイル: GraspQualityWindow.cpp プロジェクト: TheMarex/simox
GraspQualityWindow::GraspQualityWindow(std::string &robFile, std::string &objFile, Qt::WFlags flags)
:QMainWindow(NULL)
{
	VR_INFO << " start " << endl;

	this->robotFile = robFile;
	this->objectFile = objFile;
	
	sceneSep = new SoSeparator;
	sceneSep->ref();
	robotSep = new SoSeparator;
	objectSep = new SoSeparator;
    frictionConeSep = new SoSeparator;
	gws1Sep = new SoSeparator;
	gws2Sep = new SoSeparator;
	ows1Sep = new SoSeparator;
	ows2Sep = new SoSeparator;
	
	sceneSep->addChild(robotSep);
	sceneSep->addChild(objectSep);
	sceneSep->addChild(frictionConeSep);
	sceneSep->addChild(gws1Sep);
	sceneSep->addChild(gws2Sep);
	sceneSep->addChild(ows1Sep);
	sceneSep->addChild(ows2Sep);

	setupUI();
	

	loadObject();    
	loadRobot();


	m_pExViewer->viewAll();

	SoSensorManager *sensor_mgr = SoDB::getSensorManager();
	SoTimerSensor *timer = new SoTimerSensor(timerCB, this);
	timer->setInterval(SbTime(TIMER_MS/1000.0f));
	sensor_mgr->insertTimerSensor(timer);
}
コード例 #6
0
void GenericIKWindow::setupUI()
{
    UI.setupUi(this);
    exViewer = new SoQtExaminerViewer(UI.frameViewer, "", TRUE, SoQtExaminerViewer::BUILD_POPUP);

    // setup
    exViewer->setBackgroundColor(SbColor(1.0f, 1.0f, 1.0f));
    exViewer->setAccumulationBuffer(true);
    exViewer->setAntialiasing(true, 4);

    exViewer->setTransparencyType(SoGLRenderAction::BLEND);
    exViewer->setFeedbackVisibility(true);
    exViewer->setSceneGraph(sceneSep);
    exViewer->viewAll();

    connect(UI.pushButtonReset, SIGNAL(clicked()), this, SLOT(resetSceneryAll()));
    connect(UI.pushButtonLoad, SIGNAL(clicked()), this, SLOT(loadRobot()));

    connect(UI.checkBoxColModel, SIGNAL(clicked()), this, SLOT(collisionModel()));
    connect(UI.comboBoxKC, SIGNAL(activated(int)), this, SLOT(selectKC(int)));

    connect(UI.pushButtonBox2TCP, SIGNAL(clicked()), this, SLOT(box2TCP()));
    connect(UI.pushButtonSolve, SIGNAL(clicked()), this, SLOT(solve()));


    connect(UI.horizontalSliderX, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));
    connect(UI.horizontalSliderY, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));
    connect(UI.horizontalSliderZ, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));
    connect(UI.horizontalSliderA, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));
    connect(UI.horizontalSliderB, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));
    connect(UI.horizontalSliderG, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()));

    // a method, that is called by a timer, is allowed to update the IV models without disturbing the render loop
    SoTimerSensor* timer = new SoTimerSensor((SoSensorCB*)(&updateCB), this);
    SbTime interval(1.0 / 30);
    timer->setInterval(interval);
    timer->schedule();
}
コード例 #7
0
int main(int argc, char** argv)
{

	// init Inventor
	HWND w = SoWin::init(argv[0]);
	SoWinExaminerViewer * v = new SoWinExaminerViewer(w);
	
	//Preguntar donde iria
	SoViewportRegion::initClass();

	// Iniciamos la escena
	SoSeparator *root = new SoSeparator;
	root->ref();
	root->addChild(new SoUnits);


	Pointers * mypointers= new Pointers();

	//De este separador colgará la escena que se carga de 
	//fichero, así como las cámaras y luces encargadas de 
	//mostrarla
	SoSeparator *ojo_izq= new SoSeparator;
	
	
    //Partimos la pantalla
    SoViewportRegion *vp1 = new SoViewportRegion();
    vp1->height=0.4f;
    vp1->width=0.2f;
	vp1->y_pos=0.6f;
    vp1->x_pos=0.0f;
    vp1->onTop=TRUE; 
    
    ojo_izq->addChild(vp1);
    
	//Introducimos una nueva cámara. Esta cámara pintará
	//los draggers siempre en la misma posición 
	SoFrustumCamera *cam = new SoFrustumCamera();	
	ojo_izq->addChild(cam);

	

	

	SoSeparator * escena = new SoSeparator;
	LightControl * luces;
	luces = new LightControl(escena);
	CheckStick * mystickcontrol;

	mypointers->lights=luces;
	
	mypointers->viewer=v;
	

	SoSeparator *habitacion=new SoSeparator;
	SoTransform * centrar = new SoTransform;

	//centrar->translation.setValue(60.0f,-60.0f,60.0f);
	centrar->translation.setValue(0,-1.f,0.5f);
	//centrar->scaleFactor.setValue(0.0001f,0.0001f,0.0001f);//bateria wena
	//centrar->scaleFactor.setValue(3.f,3.f,3.f);

	habitacion->addChild(centrar);
	//Desplazamiento de la pantalla 

	 // model
	  SoFile *model = new SoFile;
	  if (argc > 1) model->name.setValue(argv[1]);
	  else model->name.setValue("drumconparedes.wrl");
	  habitacion->addChild(model);

	escena->addChild(habitacion);

	SoSeparator * esqueleto= new SoSeparator;

	DrawCoin::CrearEsqueleto(esqueleto);

	mystickcontrol=new CheckStick(DrawCoin::t_cabeza,DrawCoin::t_mano_izq,DrawCoin::t_mano_der);
	mypointers->sticks=mystickcontrol;

	escena->addChild(esqueleto);

	ojo_izq->addChild (escena);
	//Colocamos la camara de modo que pueda ver toda la escena
	cam->viewAll(escena,vp1->getViewportRegion());

	//cam->position.setValue(0.0f,10.0f,-10.f);
	//cam->orientation.setValue(SbVec3f(0.0f,-1.f,1.f),0);
	//De este separador colgará la escena que se carga de 
	//fichero, así como las cámaras y luces encargadas de 
	//mostrarla
	SoSeparator *ojo_der= new SoSeparator;
	root->addChild (ojo_der);
	root->addChild (ojo_izq);
    //Partimos la pantalla
    SoViewportRegion *vp2 = new SoViewportRegion();
    vp2->height=1.0f;
    vp2->width=1.0f;
    vp2->x_pos=0.0f;
    vp2->onTop=FALSE; 
    
    ojo_der->addChild(vp2);
    
	//Introducimos una nueva cámara. Esta cámara pintará
	//los draggers siempre en la misma posición 
	SoFrustumCamera * cam2;

	cam2 = new SoFrustumCamera();	
	mypointers->camera2=cam2;
	//cam2->farDistance = 3.f;

	ojo_der->addChild(cam2);
	SoTransform * cabeza;
	SoRotation * rotacion;

	cabeza=DrawCoin::Get_Cabeza_Pos();
	rotacion=DrawCoin::Get_Cabeza_Rot();
	cam2->position.connectFrom(&cabeza->translation);
	cam2->orientation.connectFrom(&rotacion->rotation);
	
	ojo_der->addChild (escena);

	//Colocamos la camara de modo que pueda ver toda la escena
	cam2->viewAll(escena,vp2->getViewportRegion());
	cam2->viewportMapping = SoCamera::LEAVE_ALONE;
	cam2->position.setValue(0.0f,0.0f,0.0f);
	
	int Data_Of_Thread = 1;
    HANDLE Handle_Of_Thread;

	Handle_Of_Thread = CreateThread( NULL, 0, Thread, &Data_Of_Thread, 0, NULL);  
    if ( Handle_Of_Thread == NULL) ExitProcess(Data_Of_Thread);



	//Creamos un sensor encargado del render
	SoTimerSensor*   rendertimer = new SoTimerSensor(renderCallback,(void *)mypointers);
	rendertimer->setInterval(FPS); 
	rendertimer->schedule();


	SoEventCallback *eventCB = new SoEventCallback;
	eventCB->addEventCallback(SoKeyboardEvent::getClassTypeId(),handle_keyboard,(void*)mypointers);
	root->addChild(eventCB);
	
	
	v->setBackgroundColor(SbColor(0.0f, 0.2f, 0.3f));
	v->setFeedbackVisibility(TRUE);
	v->setSceneGraph(root);
	//v->setViewing(FALSE);
	v->setTitle("Kinect Tracking");
	v->setAutoRedraw(FALSE);
	///v->setDecoration(FALSE);

	
	SoWin::show(w);
	SoWin::mainLoop();


	root->unref();
	delete v;
	
	
	
	
	return 0;
}
コード例 #8
0
ファイル: chain-id.cpp プロジェクト: erwincoumans/Moby
int main(int argc, char** argv)
{
	// verify that argument is given
	if (argc < 2)
	{
		std::cerr << "syntax: chain <XML file>" << std::endl;
		return -1;
	}
				
	// setup the simulation
	XMLReader::read(std::string(argv[1]));

	// get the (only) simulation object
	boost::shared_ptr<Simulator> s = XMLReader::_sim_objs.front();

	// setup the visualization
	QWidget* mainwin = SoQt::init(argc, argv, argv[0]);
	SoQtExaminerViewer* viewer = new SoQtExaminerViewer(mainwin);
	SoSeparator* main_sep = new SoSeparator;
	main_sep->ref();

	// add a camera
	SoPerspectiveCamera* camera = new SoPerspectiveCamera;
	camera->position = SbVec3f(0, 0, 150);
	camera->pointAt(SbVec3f(0,0,1));
	main_sep->addChild(camera);

	// add lights
	SoDirectionalLight* light = new SoDirectionalLight;
	light->direction = SbVec3f(0,0,1);
	SoDirectionalLight* light2 = new SoDirectionalLight;
	light2->direction = SbVec3f(0,0,-1);
	SoDirectionalLight* light3 = new SoDirectionalLight;
	light3->direction = SbVec3f(-10,-5,-1);
	SoDirectionalLight* light4 = new SoDirectionalLight;
	light4->direction = SbVec3f(-10,-5,1);
	SoDirectionalLight* light5 = new SoDirectionalLight;
	light5->direction = SbVec3f(0,-10,1);
	main_sep->addChild(light);
	main_sep->addChild(light2);
	main_sep->addChild(light3);
	main_sep->addChild(light4);
	main_sep->addChild(light5);
	
	// setup the simulator visualization
	viz = boost::shared_ptr<InventorOutput>(new InventorOutput(s));
	SoSeparator* sep = viz->get_root();
	main_sep->addChild(sep);

	// start rendering
	viewer->setSceneGraph(sep);
	viewer->show();

	// add a timer sensor that runs the simulation
	SoTimerSensor* timer = new SoTimerSensor(&render, &s);
	SbTime interval(STEP_SIZE);
	timer->setInterval(interval);
	timer->schedule();

	// popup the main window
	SoQt::show(mainwin);
	SoQt::mainLoop();
	delete viewer;
}
コード例 #9
0
ファイル: TerrainViewer.cpp プロジェクト: irox/subnav
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;
}
コード例 #10
0
ファイル: GraspRrtWindow.cpp プロジェクト: gkalogiannis/simox
GraspRrtWindow::GraspRrtWindow(const std::string& sceneFile, const std::string& sConf, const std::string& goalObject,
                               const std::string& rns, const std::string& rnsB, const std::string& eefName, const std::string& eefNameB,
                               const std::string& colModelRob1, const std::string& colModelRob1B, const std::string& colModelRob2, const std::string& colModelRob2B,
                               const std::string& colModelEnv)
    : QMainWindow(NULL)
{
    VR_INFO << " start " << endl;

    this->sceneFile = sceneFile;

    allSep = new SoSeparator;
    allSep->ref();
    sceneFileSep = new SoSeparator;
    graspsSep = new SoSeparator;
    rrtSep = new SoSeparator;

    allSep->addChild(sceneFileSep);
    allSep->addChild(graspsSep);
    allSep->addChild(rrtSep);

    planSetA.rns = rns;
    planSetA.eef = eefName;
    planSetA.colModelRob1 = colModelRob1;
    planSetA.colModelRob2 = colModelRob2;
    planSetA.colModelEnv = colModelEnv;

    planSetB.rns = rnsB;
    planSetB.eef = eefNameB;
    planSetB.colModelRob1 = colModelRob1B;
    planSetB.colModelRob2 = colModelRob2B;
    planSetB.colModelEnv = colModelEnv;
    setupUI();

    loadScene();



    selectPlanSet(0);

    selectStart(sConf);
    selectTargetObject(goalObject);



    if (sConf != "")
    {
        UI.comboBoxStart->setEnabled(false);
    }

    if (goalObject != "")
    {
        UI.comboBoxGoal->setEnabled(false);
    }

    if (rns != "")
    {
        UI.comboBoxRNS->setEnabled(false);
    }

    //if (eefName!="")
    //  UI.comboBoxEEF->setEnabled(false);
    if (colModelRob1 != "")
    {
        UI.comboBoxColModelRobot->setEnabled(false);
    }

    if (colModelRob2 != "")
    {
        UI.comboBoxColModelRobotStatic->setEnabled(false);
    }

    //if (colModelEnv!="")
    //  UI.comboBoxColModelEnv->setEnabled(false);

    viewer->viewAll();

    SoSensorManager* sensor_mgr = SoDB::getSensorManager();
    SoTimerSensor* timer = new SoTimerSensor(timerCB, this);
    timer->setInterval(SbTime(TIMER_MS / 1000.0f));
    sensor_mgr->insertTimerSensor(timer);
}