Example #1
0
void GameInterface::initGUI()
{
	int* option= &((XMLScene*) scene)->option;
	GLUI_Panel* viewPanel= addPanel("View Points",1);
	viewPanel->set_alignment(1);
	GLUI_RadioGroup* group = addRadioGroupToPanel(viewPanel,&((XMLScene*) scene)->viewPoint,16);
	addRadioButtonToGroup(group,"Lateral");
	addRadioButtonToGroup(group,"Upper");
	GLUI_Panel *gameModePanel = addPanel("Game", 1);
	gameModePanel->set_alignment(0);
	GLUI_Listbox* themeListBox =addListboxToPanel(gameModePanel,"Theme: ",option,8);
	themeListBox->add_item (0, "Classic");
	themeListBox->add_item (1, "Minecraft");
	themeListBox->add_item (2, "Dragon Ball");
	GLUI_Button* undo = addButtonToPanel(gameModePanel,"Undo",12);
	addColumnToPanel(gameModePanel);
	GLUI_Listbox* gameModeListbox=addListboxToPanel(gameModePanel,"Game Mode", &((XMLScene*) scene)->data->newGameMode,9);
	gameModeListbox->add_item(1,"PVP");
	gameModeListbox->add_item(2,"Player vs PC");
	gameModeListbox->add_item(3,"PC vs PC");
	GLUI_Button* redo = addButtonToPanel(gameModePanel,"Redo",13);
	addColumnToPanel(gameModePanel);
	GLUI_Panel* difficultiesPanel=addPanelToPanel(gameModePanel,"Difficulties",1);
	difficultiesPanel->set_alignment(0);
	GLUI_Listbox* difficulty1Listbox=addListboxToPanel(difficultiesPanel,"Computer 1", &((XMLScene*) scene)->data->newDifficulties[0],10);
	difficulty1Listbox->add_item(1,"Normal");
	difficulty1Listbox->add_item(2,"Hard");
	GLUI_Button* restart = addButtonToPanel(gameModePanel,"Restart",14);
	GLUI_Listbox* difficulty2Listbox=addListboxToPanel(difficultiesPanel,"Computer 2", &((XMLScene*) scene)->data->newDifficulties[1],11);
	difficulty2Listbox->add_item(1,"Normal");
	difficulty2Listbox->add_item(2,"Hard");
	GLUI_Button* gameMovie = addButtonToPanel(gameModePanel,"Game Movie",15);

}
Example #2
0
GLUI_Listbox   *GLUI::add_listbox_to_panel( GLUI_Panel *panel,
					    char *name, int *value_ptr,
					    int id, 
					    GLUI_Update_CB callback )
{
  GLUI_Listbox *control;

  control = new GLUI_Listbox;

  if ( control ) {
    control->set_ptr_val( value_ptr );
    control->user_id    = id;
    control->set_name( name );
    control->callback    = callback;

    add_control( panel, control );

    control->init_live();

    return control;
  }
  else {
    return NULL;
  }
}
Example #3
0
void TPinterface::initGUI() {
	// Check CGFinterface.h and GLUI documentation for the types of controls available
	GLUI_Panel *varPanel = addPanel("Lights", 1);

	// You could also pass a reference to a variable from the scene class, if public

	addCheckboxToPanel(varPanel, "light0", &on0, 0);
	addCheckboxToPanel(varPanel, "light1", &on1, 1);
	addCheckboxToPanel(varPanel, "light2", &on2, 2);
	addCheckboxToPanel(varPanel, "light3", &on3, 3);
	addCheckboxToPanel(varPanel, "light4", &on4, 4);

	addButtonToPanel(varPanel, "Clock", 5);


	GLUI_RadioGroup* wireframeGroup = addRadioGroupToPanel(varPanel,&radioStatus, 6);

	addRadioButtonToGroup(wireframeGroup, "Textured");
	addRadioButtonToGroup(wireframeGroup, "Wireframed");



	GLUI_Listbox* listBox = addListboxToPanel(varPanel,"Textures",&listStatus, 7);

	listBox->add_item(0, "Default");
	listBox->add_item(1, "Earth");

}
Example #4
0
void TPinterface::initGUI()
{
	// Check CGFinterface.h and GLUI documentation for the types of controls available
	//GLUI_Panel *varPanel= addPanel("Group", 1);
	//addSpinnerToPanel(varPanel, "Val 1(interface)", 2, &testVar, 1);

	// You could also pass a reference to a variable from the scene class, if public
	//addSpinnerToPanel(varPanel, "Val 2(scene)", 2, &(((LightingScene*) scene)->sceneVar), 2);
	//addColumn ();
	GLUI_Panel *varLuz= addPanel("Luzes", 2);
	addCheckboxToPanel(varLuz, "Luz 1",&((LightingScene *) scene)->state1,NULL);
	addCheckboxToPanel(varLuz, "Luz 2",&((LightingScene *) scene)->state2,NULL);
	addCheckboxToPanel(varLuz, "Luz 3",&((LightingScene *) scene)->state3,NULL);
	addCheckboxToPanel(varLuz, "Luz 4",&((LightingScene *) scene)->state4,NULL);
	addColumn ();
	GLUI_Panel *varClock= addPanel("Relogio", 3);
	addStaticText("Relógio");
	addButton ("Pause/Start",1);
	addColumn ();
	GLUI_Panel *vartext= addPanel("Texturas",4);
	GLUI_Listbox *textvar =addListboxToPanel(vartext,"Texturas",&((LightingScene *) scene)->statetext,NULL);
	textvar->add_item (1, "Default");
	textvar->add_item (2, "Sky");
	textvar->add_item (3, "Space");
	textvar->set_int_val (3); 
	addColumn();
	GLUI_Panel *varwire= addPanel("Wireframe",5);
	GLUI_RadioGroup *group=addRadioGroupToPanel(varwire,&((LightingScene *) scene)->wire);
	addRadioButtonToGroup(group,"Normal");
	addRadioButtonToGroup(group,"Wireframe");
	addColumn();
}
Example #5
0
void GameInterface::initGUI()
{
	int* option= &((XMLScene*) scene)->option;
	/*
	GLUI_Panel *varPanel1 = addPanel("Cameras", 1);
	int* camera = &((XMLScene*) scene)->camera;
	GLUI_Listbox *texturesListbox =addListboxToPanel(varPanel1,"Camera: ",camera,7);
	unsigned int size=((XMLScene*) scene)->file->sceneCameras.size();
	for(unsigned int i = 0;i<size;i++)
	{
	texturesListbox->add_item (i, ((XMLScene*) scene)->file->sceneCameras[i].first);
	}

	//addColumn();
	GLUI_Panel *varPanel2 = addPanel("Draw Mode", 1);
	varPanel2->set_alignment(0);
	GLUI_RadioGroup* radioGroup = addRadioGroupToPanel(varPanel2,&((XMLScene*) scene)->drawmode,3);
	addRadioButtonToGroup(radioGroup,"Fill");
	addRadioButtonToGroup(radioGroup,"Line");
	addRadioButtonToGroup(radioGroup,"Point");

	addColumn();
	*/
	GLUI_Panel *gameModePanel = addPanel("Game", 1);
	gameModePanel->set_alignment(0);
	GLUI_Listbox* themeListBox =addListboxToPanel(gameModePanel,"Theme: ",option,8);
	themeListBox->add_item (0, "Classic");
	themeListBox->add_item (1, "Minecraft");
	GLUI_Button* undo = addButtonToPanel(gameModePanel,"Undo",12);
	addColumnToPanel(gameModePanel);
	GLUI_Listbox* gameModeListbox=addListboxToPanel(gameModePanel,"Game Mode", &((XMLScene*) scene)->data->gameMode,9);
	gameModeListbox->add_item(1,"PVP");
	gameModeListbox->add_item(2,"Player vs PC");
	gameModeListbox->add_item(3,"PC vs PC");
	GLUI_Button* redo = addButtonToPanel(gameModePanel,"Redo",13);
	addColumnToPanel(gameModePanel);
	GLUI_Panel* difficultiesPanel=addPanelToPanel(gameModePanel,"Difficulties",1);;
	difficultiesPanel->set_alignment(0);
	GLUI_Listbox* difficulty1Listbox=addListboxToPanel(difficultiesPanel,"Computer 1", &((XMLScene*) scene)->data->difficulties[0],10);
	difficulty1Listbox->add_item(1,"Normal");
	difficulty1Listbox->add_item(2,"Hard");
	GLUI_Button* restart = addButtonToPanel(gameModePanel,"Restart",14);
	GLUI_Listbox* difficulty2Listbox=addListboxToPanel(difficultiesPanel,"Computer 2", &((XMLScene*) scene)->data->difficulties[1],11);
	difficulty2Listbox->add_item(1,"Normal");
	difficulty2Listbox->add_item(2,"Hard");
	GLUI_Button* gameFilm = addButtonToPanel(gameModePanel,"Game Film",15);

}
Example #6
0
void TPinterface::initGUI()
{
	GLUI_Panel *lightPanel= addPanel("Lights",1);
	for(unsigned int i=0;i<((LightingScene*) scene)->lightState.size();i++){
		char name[30]="";
		std::string s = ((LightingScene*) scene)->lights[i]->getID();
		sprintf(name, "%s", s.c_str());
		addCheckboxToPanel(lightPanel,name,&(((LightingScene*) scene)->lightState[i]),0);
	}

	addColumn();

	GLUI_Panel *cameraPanel= addPanel("Cameras",1);
	if(((LightingScene*) scene)->cameras.size()<5){
		GLUI_RadioGroup *radioCameras=addRadioGroupToPanel(cameraPanel,&((LightingScene*) scene)->camera,1);
		for(unsigned int i=0;i<((LightingScene*) scene)->cameras.size();i++){
			char name[30]="";
			std::string s =((LightingScene*) scene)->cameras[i]->getID();
			sprintf(name, "%s", s.c_str());
			addRadioButtonToGroup(radioCameras,name);
		}
	}
	else{
		GLUI_Listbox *listbox = addListboxToPanel(cameraPanel,"Cameras",&((LightingScene*) scene)->camera,2);

		for(unsigned int i=0;i<2;i++){
			char name[30]="";
			std::string s =((LightingScene*) scene)->cameras[i]->getID();
			sprintf(name, "%s", s.c_str());
			listbox->add_item(i,name);
			((LightingScene*) scene)->camera= listbox->get_int_val();
		}
	}

	addColumn();

	GLUI_Panel *drawmodePanel= addPanel("Drawmode",1);
	GLUI_RadioGroup *radioDrawmode=addRadioGroupToPanel(drawmodePanel,&((LightingScene*) scene)->drawmode,3);
	addRadioButtonToGroup(radioDrawmode,"Point");
	addRadioButtonToGroup(radioDrawmode,"Line");
	addRadioButtonToGroup(radioDrawmode,"Fill");

	addColumn();

	GLUI_Panel *themesPanel= addPanel("Themes",1);
	GLUI_Listbox *themeslistbox = addListboxToPanel(themesPanel,"Themes",&((LightingScene*) scene)->app,4);
	themeslistbox->add_item(0, "classic");
	themeslistbox->add_item(1, "mario");
	themeslistbox->add_item(2, "dragon ball");
	themeslistbox->add_item(3, "angry birds");
}
int main(int argc, char** argv)
{
	// Place a communicator at serialport (Default COM1)
	communicator = new Communicator(serialport);

	// Hide joints
	settings.drawJoints=0;

	// Set startup view position
	settings.viewCenter=b2Vec2(35,16);

	simulatorPageCount = 0;
	while (g_simulatorPageEntries[simulatorPageCount].createFcn != NULL)
	{
		++simulatorPageCount;
	}

	simulatorPageIndex = b2Clamp(simulatorPageIndex, 0, simulatorPageCount-1);
	simulatorPageSelection = simulatorPageIndex;

	entry = g_simulatorPageEntries + simulatorPageIndex;
	simulatorPage = entry->createFcn(communicator);

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);

	char title[32];
	sprintf(title, "Educational simulator for control-system development");

	mainWindow = glutCreateWindow(title);
	//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glutDisplayFunc(SimulationLoop);
	GLUI_Master.set_glutReshapeFunc(Resize);
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutMouseFunc(Mouse);
#ifdef FREEGLUT
	glutMouseWheelFunc(MouseWheel);
#endif
	glutMotionFunc(MouseMotion);

	glutKeyboardUpFunc(KeyboardUp);


	glui = GLUI_Master.create_glui_subwindow( mainWindow,
		GLUI_SUBWINDOW_RIGHT );


	glui->add_statictext("Simulator-page:");
	GLUI_Listbox* simulatorPageList =
		glui->add_listbox("", &simulatorPageSelection);

	int32 simulatorPageCount = 0;
	SimulatorPageEntry* e = g_simulatorPageEntries;
	while (e->createFcn)
	{
		simulatorPageList->add_item(simulatorPageCount, e->name);
		++simulatorPageCount;
		++e;
	}
	glui->add_separator();
	glui->add_edittext( "Serialport:", GLUI_EDITTEXT_TEXT, serialport );
	glui->add_button("Apply", 0, (GLUI_Update_CB)SetSerialPort);

	glui->add_separator();

	glui->add_button("Pause", 0, Pause);
	glui->add_button("Single Step", 0, SingleStep);
	glui->add_button("Restart", 0, Restart);

	glui->add_button("Quit", 0,(GLUI_Update_CB)Exit);

	glui->add_separator();

	glui->add_button("Help", 0,(GLUI_Update_CB)Help);
	glui->add_button("About", 0,(GLUI_Update_CB)About);


	glui->set_main_gfx_window( mainWindow );


	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

	glutMainLoop();

	return 0;
}
Example #8
0
void main(int argc, char* argv[])
{



  figinit();




  /****************************************/
  /*   Initialize GLUT and create window  */
  /****************************************/

  glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowPosition( 50, 50 );
  glutInitWindowSize( 800, 600 );
 
  main_window = glutCreateWindow( "GLUI Example 5" );
  glutDisplayFunc( myGlutDisplay );
  GLUI_Master.set_glutReshapeFunc( myGlutReshape );  
  GLUI_Master.set_glutKeyboardFunc( myGlutKeyboard );
  GLUI_Master.set_glutSpecialFunc( NULL );
  GLUI_Master.set_glutMouseFunc( myGlutMouse );
  glutMotionFunc( myGlutMotion );

  /****************************************/
  /*       Set up OpenGL lights           */
  /****************************************/

  glEnable(GL_LIGHTING);
  glEnable( GL_NORMALIZE );

  glEnable(GL_LIGHT0);
  glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, light0_position);

  glEnable(GL_LIGHT1);
  glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
  glLightfv(GL_LIGHT1, GL_POSITION, light1_position);

  /****************************************/
  /*          Enable z-buferring          */
  /****************************************/

  glEnable(GL_DEPTH_TEST);

  /****************************************/
  /*         Here's the GLUI code         */
  /****************************************/

  printf( "GLUI version: %3.2f\n", GLUI_Master.get_version() );

  /*** Create the side subwindow ***/
  glui = GLUI_Master.create_glui_subwindow( main_window, 
					    GLUI_SUBWINDOW_LEFT );

  obj_panel = glui->add_rollout( "Properties", false );

  /***** Control for object params *****/

  checkbox = 
    glui->add_checkbox_to_panel( obj_panel, "Wireframe", &wireframe, 1, 
				 control_cb );
  spinner  = glui->add_spinner_to_panel( obj_panel, "Segments:",
					 GLUI_SPINNER_INT, &segments);
  spinner->set_int_limits( 3, 60 );
  spinner->set_alignment( GLUI_ALIGN_RIGHT );

  GLUI_Spinner *scale_spinner = 
    glui->add_spinner_to_panel( obj_panel, "Scale:",
				GLUI_SPINNER_FLOAT, &scale);
  scale_spinner->set_float_limits( .2f, 4.0 );
  scale_spinner->set_alignment( GLUI_ALIGN_RIGHT );


  /******** Add some controls for lights ********/

  GLUI_Rollout *roll_lights = glui->add_rollout( "Lights", false );

  GLUI_Panel *light0 = glui->add_panel_to_panel( roll_lights, "Light 1" );
  GLUI_Panel *light1 = glui->add_panel_to_panel( roll_lights, "Light 2" );

  glui->add_checkbox_to_panel( light0, "Enabled", &light0_enabled,
			       LIGHT0_ENABLED_ID, control_cb );
  light0_spinner = 
    glui->add_spinner_to_panel( light0, "Intensity:", GLUI_SPINNER_FLOAT,
				&light0_intensity, LIGHT0_INTENSITY_ID,
				control_cb );
  light0_spinner->set_float_limits( 0.0, 1.0 );

  glui->add_checkbox_to_panel( light1, "Enabled", &light1_enabled,
			       LIGHT1_ENABLED_ID, control_cb );
  light1_spinner = 
    glui->add_spinner_to_panel( light1, "Intensity:", GLUI_SPINNER_FLOAT,
				&light1_intensity, LIGHT1_INTENSITY_ID,
				control_cb );
  light1_spinner->set_float_limits( 0.0, 1.0 );


  /*** Add another rollout ***/
  GLUI_Rollout *options = glui->add_rollout( "Options", true );
  glui->add_checkbox_to_panel( options, "Draw sphere", &show_sphere );
  glui->add_checkbox_to_panel( options, "Draw torus", &show_torus );
  glui->add_checkbox_to_panel( options, "Draw axes", &show_axes );
  glui->add_checkbox_to_panel( options, "Draw text", &show_text );


  /**** Add listbox ****/
  glui->add_statictext( "" );
  GLUI_Listbox *list = glui->add_listbox( "Text:", &curr_string );
  int i;
  for( i=0; i<4; i++ )
    list->add_item( i, string_list[i] );




  /**** Add listbox ****/
  glui->add_statictext( "" );
  GLUI_Listbox *headwear = glui->add_listbox( "HeadWear:", &curr_string );
  for( i=0; i< CategorySize[0]; i++ )
    headwear->add_item( i, CategoryPtr[0][i].FirstLine->Comment );

  /**** Add listbox ****/
  glui->add_statictext( "" );
  GLUI_Listbox *heads = glui->add_listbox( "Head:", &curr_string );
  for( i=0; i< CategorySize[1]; i++ )
    heads->add_item( i, CategoryPtr[1][i].FirstLine->Comment );

  /**** Add listbox ****/
  glui->add_statictext( "" );
  GLUI_Listbox *neckwear = glui->add_listbox( "NeckWear:", &curr_string );
  for( i=0; i< CategorySize[2]; i++ )
    neckwear->add_item( i, CategoryPtr[2][i].FirstLine->Comment );

  /**** Add listbox ****/
  glui->add_statictext( "" );
  GLUI_Listbox *torso = glui->add_listbox( "Torso:", &curr_string );
  for( i=0; i< CategorySize[3]; i++ )
    torso->add_item( i, CategoryPtr[3][i].FirstLine->Comment );





  glui->add_statictext( "" );


  /*** Disable/Enable buttons ***/
  glui->add_button( "Disable movement", DISABLE_ID, control_cb );
  glui->add_button( "Enable movement", ENABLE_ID, control_cb );
  glui->add_button( "Hide", HIDE_ID, control_cb );
  glui->add_button( "Show", SHOW_ID, control_cb );

  glui->add_statictext( "" );

  /****** A 'quit' button *****/
  glui->add_button( "Quit", 0,(GLUI_Update_CB)exit );


  /**** Link windows to GLUI, and register idle callback ******/
  
  glui->set_main_gfx_window( main_window );


#if 0
  /*** Create the bottom subwindow ***/
  glui2 = GLUI_Master.create_glui_subwindow( main_window, 
					     GLUI_SUBWINDOW_BOTTOM );
  glui2->set_main_gfx_window( main_window );

  GLUI_Rotation *view_rot = glui2->add_rotation( "Objects", view_rotate );
  view_rot->set_spin( 1.0 );
  glui2->add_column( false );
  GLUI_Rotation *sph_rot = glui2->add_rotation( "Sphere", sphere_rotate );
  sph_rot->set_spin( .98 );
  glui2->add_column( false );
  GLUI_Rotation *tor_rot = glui2->add_rotation( "Torus", torus_rotate );
  tor_rot->set_spin( .98 );
  glui2->add_column( false );
  GLUI_Rotation *lights_rot = glui2->add_rotation( "Blue Light", lights_rotation );
  lights_rot->set_spin( .82 );
  glui2->add_column( false );
  GLUI_Translation *trans_xy = 
    glui2->add_translation( "Objects XY", GLUI_TRANSLATION_XY, obj_pos );
  trans_xy->set_speed( .005 );
  glui2->add_column( false );
  GLUI_Translation *trans_x = 
    glui2->add_translation( "Objects X", GLUI_TRANSLATION_X, obj_pos );
  trans_x->set_speed( .005 );
  glui2->add_column( false );
  GLUI_Translation *trans_y = 
    glui2->add_translation( "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] );
  trans_y->set_speed( .005 );
  glui2->add_column( false );
  GLUI_Translation *trans_z = 
    glui2->add_translation( "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] );
  trans_z->set_speed( .005 );
#endif


  /**** We register the idle callback with GLUI, *not* with GLUT ****/
  GLUI_Master.set_glutIdleFunc( myGlutIdle );

  /**** Regular GLUT main loop ****/
  
  glutMainLoop();
}
Example #9
0
int main(int argc, char** argv)
{
	entry = g_testEntries + testIndex;
	test = entry->createFcn();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);
	char title[32];
	sprintf(title, "Box2D Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
	mainWindow = glutCreateWindow(title);
	//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glutDisplayFunc(SimulationLoop);
	GLUI_Master.set_glutReshapeFunc(Resize);  
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutMouseFunc(Mouse);
	glutMouseWheelFunc(MouseWheel);
	glutMotionFunc(MouseMotion);

	glui = GLUI_Master.create_glui_subwindow( mainWindow, 
		GLUI_SUBWINDOW_RIGHT );

	glui->add_statictext("Tests");
	GLUI_Listbox* testList =
		glui->add_listbox("", &testSelection);

	glui->add_separator();

	GLUI_Spinner* iterationSpinner =
		glui->add_spinner("Iterations", GLUI_SPINNER_INT, &settings.iterationCount);
	iterationSpinner->set_int_limits(1, 100);

	GLUI_Spinner* hertzSpinner =
		glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &settings.hz);
	hertzSpinner->set_float_limits(5.0f, 200.0f);

	glui->add_checkbox("Position Correction", &settings.enablePositionCorrection);
	glui->add_checkbox("Warm Starting", &settings.enableWarmStarting);
	glui->add_checkbox("Time of Impact", &settings.enableTOI);

	glui->add_separator();

	GLUI_Panel* drawPanel =	glui->add_panel("Draw");
	glui->add_checkbox_to_panel(drawPanel, "Shapes", &settings.drawShapes);
	glui->add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
	glui->add_checkbox_to_panel(drawPanel, "Core Shapes", &settings.drawCoreShapes);
	glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
	glui->add_checkbox_to_panel(drawPanel, "OBBs", &settings.drawOBBs);
	glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs);
	glui->add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
	glui->add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
	glui->add_checkbox_to_panel(drawPanel, "Contact Forces", &settings.drawContactForces);
	glui->add_checkbox_to_panel(drawPanel, "Friction Forces", &settings.drawFrictionForces);
	glui->add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
	glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);

	int32 testCount = 0;
	TestEntry* e = g_testEntries;
	while (e->createFcn)
	{
		testList->add_item(testCount, e->name);
		++testCount;
		++e;
	}

	glui->add_button("Pause", 0, Pause);
	glui->add_button("Single Step", 0, SingleStep);

	glui->add_button("Quit", 0,(GLUI_Update_CB)exit);
	glui->set_main_gfx_window( mainWindow );

	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

	glutMainLoop();

	return 0;
}
Example #10
0
int main(int argc, char** argv)
{

//#define CHECK_FPU_EXCEPTIONS 1
#ifdef CHECK_FPU_EXCEPTIONS

	int cw = _control87(0, 0);

	// Set the exception masks off, turn exceptions on
	cw &= ~(EM_ZERODIVIDE | EM_INVALID);

	printf("control87 = %#x\n", cw);

	// Set the control word
	_control87(cw, MCW_EM);
#endif //CHECK_FPU_EXCEPTIONS


	setDefaultSettings();
	
	int bulletVersion = btGetVersion();
	printf("Bullet version %d\n",bulletVersion);

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH | GLUT_STENCIL);
	glutInitWindowSize(width, height);
	mainWindow = glutCreateWindow("http://bulletphysics.com");
#ifdef BT_USE_FREEGLUT
	glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif
	entry = g_demoEntries + testIndex;
	demo = CreatDemo(entry);
	
	glutDisplayFunc(SimulationLoop);
	GLUI_Master.set_glutReshapeFunc(Resize);  
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutSpecialUpFunc(KeyboardSpecialUp);
	GLUI_Master.set_glutMouseFunc(Mouse);
	glutMotionFunc(MouseMotion);


	glui = GLUI_Master.create_glui_subwindow( mainWindow, 
		GLUI_SUBWINDOW_RIGHT );

	

	glui->add_statictext("Tests");
	GLUI_Listbox* testList =
		glui->add_listbox("", &testSelection);
	glui->add_button("Next Scene", 0,(GLUI_Update_CB)NextScene);

	glui->add_separator();

	GLUI_Spinner* iterationSpinner =
		glui->add_spinner("Iterations", GLUI_SPINNER_INT, &iterationCount);
	iterationSpinner->set_int_limits(1, 250);

/*	GLUI_Spinner* hertzSpinner =
		glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &hz);
	hertzSpinner->set_float_limits(5.0f, 200.0f);
*/

	
	glui->add_checkbox("DisableDeactivation", &gDebugNoDeactivation);
	glui->add_checkbox("Split Impulse", &gUseSplitImpulse);
	GLUI_Spinner* spinner = 0;

	spinner = glui->add_spinner("ERP", GLUI_SPINNER_FLOAT, &gErp);
//	spinner->set_float_limits(0.f,1.f);
//	spinner = glui->add_spinner("ERP2", GLUI_SPINNER_FLOAT, &gErp2);
	spinner->set_float_limits(0.f,1.f);
	spinner = glui->add_spinner("Slop", GLUI_SPINNER_FLOAT, &gSlop);
	spinner->set_float_limits(0.f,1.f);
//	spinner = glui->add_spinner("WSP", GLUI_SPINNER_FLOAT,&gWarmStartingParameter);
//	spinner->set_float_limits (0.f,1.0);
	glui->add_checkbox("Warmstarting", &gUseWarmstarting);
	glui->add_checkbox("Randomize Constraints", &gRandomizeConstraints);
	

	glui->add_button("Reset Defaults", 0,(GLUI_Update_CB)setDefaultSettingsAndSync);
	glui->add_separator();

	GLUI_Panel* drawPanel =	glui->add_panel("Debug Draw");

	glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb);
	glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame);
	glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts);
	glui->add_checkbox_to_panel(drawPanel, "Textures", &gDrawTextures);
	glui->add_checkbox_to_panel(drawPanel, "Shadows", &gDrawShadows);
	glui->add_checkbox_to_panel(drawPanel, "Clusters", &gDrawClusters);

	int testCount = 0;
	btDemoEntry* e = g_demoEntries;
	while (e->createFcn)
	{
		testList->add_item(testCount, e->name);
		++testCount;
		++e;
	}
	
	glui->add_separator();

	glui->add_button("Toggle Pause", 0,(GLUI_Update_CB)TogglePause);
	
	glui->add_button("Single Step", 0,(GLUI_Update_CB)SingleSimulationStep);
	glui->add_button("Reset Scene", 0,(GLUI_Update_CB)ResetScene);
	glui->add_button("Restart Scene", 0,(GLUI_Update_CB)RestartScene);

	glui->add_separator();
	
//	glui->add_button("Exit", 0,(GLUI_Update_CB)exit);

	glui->set_main_gfx_window( mainWindow );

	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

	glutMainLoop();

	return 0;
}
Example #11
0
 void UpdateLinkListboxGUI()
 {
   link_listbox->set_int_val(cur_link);
   UpdateLinkInfoGUI();
   //driver_listbox->set_int_val(cur_driver);
 }
Example #12
0
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);  
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);

	main_window = glutCreateWindow("OBJ Loader");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);  
	glutMouseFunc(myGlutMouse);
	glutMotionFunc(myGlutMotion);

	initScene();
	Objects.push_back(Object());

	glui = GLUI_Master.create_glui("OBJ Loader GUI", 0, 600, 50);

	GLUI_Panel *objPanel = glui->add_panel("");
	GLUI_Panel *objPanel2 = glui->add_panel_to_panel(objPanel, "", 0);
	objFileNameTextField = glui->add_edittext_to_panel(objPanel2, "Filename:",GLUI_EDITTEXT_TEXT,NULL,OBJ_TEXTFIELD,textCB);
	objFileNameTextField->set_text("cow");
	glui->add_button_to_panel(objPanel2, "Load", LOAD_BUTTON, buttonCB);
	glui->add_button_to_panel(objPanel2, "Screenshot (or it didn't happen)", SCREENSHOT, buttonCB);

	glui->add_column_to_panel(objPanel, 0);

	GLUI_Panel *projPanel = glui->add_panel_to_panel(objPanel, "", 0);
	GLUI_RadioGroup *projGroup = glui->add_radiogroup_to_panel(projPanel, (int*) &projType, -1, projCB);
	glui->add_radiobutton_to_group(projGroup, "Orthographic");
	glui->add_radiobutton_to_group(projGroup, "Perspective");
	projGroup->set_int_val(ORTHO);

	GLUI_Spinner *fovSpinner = glui->add_spinner_to_panel(projPanel, "FOV", GLUI_SPINNER_INT, &fov, FOV, projCB);
	fovSpinner->set_int_limits(FOVMIN, FOVMAX);
	fovSpinner->set_int_val(30);

	glui->add_column_to_panel(projPanel, 0);

	GLUI_Translation *scale = glui->add_translation_to_panel(projPanel, "Scale", GLUI_TRANSLATION_Y , &scaleFactor, -1, (GLUI_Update_CB) projCB);
	scale->set_speed(0.005f);

	GLUI_Panel *lightingPanel = glui->add_panel("", 0);

	GLUI_Panel *objMaterialPanel = glui->add_panel_to_panel(lightingPanel, "Object material");

	GLUI_Panel *objDiffusePanel = glui->add_panel_to_panel(objMaterialPanel, "Diffuse");
	GLUI_Spinner *kdRedValue = glui->add_spinner_to_panel(objDiffusePanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.diffuse[0], 0, colorCB);
	kdRedValue->set_float_limits(0.f, 1.f);
	kdRedValue->set_float_val(1.f);
	GLUI_Spinner *kdGreenValue = glui->add_spinner_to_panel(objDiffusePanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.diffuse[1], 0, colorCB);
	kdGreenValue->set_float_limits(0.f, 1.f);
	kdGreenValue->set_float_val(1.f);
	GLUI_Spinner *kdBlueValue = glui->add_spinner_to_panel(objDiffusePanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.diffuse[2], 0, colorCB);
	kdBlueValue->set_float_limits(0.f, 1.f);
	kdBlueValue->set_float_val(1.f);

	GLUI_Panel *objAmbientPanel = glui->add_panel_to_panel(objMaterialPanel, "Ambient");
	GLUI_Spinner *kaRedValue = glui->add_spinner_to_panel(objAmbientPanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.ambient[0], 0, colorCB);
	kaRedValue->set_float_limits(0.f, 1.f);
	kaRedValue->set_float_val(1.f);
	GLUI_Spinner *kaGreenValue = glui->add_spinner_to_panel(objAmbientPanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.ambient[1], 0, colorCB);
	kaGreenValue->set_float_limits(0.f, 1.f);
	kaGreenValue->set_float_val(1.f);
	GLUI_Spinner *kaBlueValue = glui->add_spinner_to_panel(objAmbientPanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.ambient[2], 0, colorCB);
	kaBlueValue->set_float_limits(0.f, 1.f);
	kaBlueValue->set_float_val(1.f);

	GLUI_Panel *objSpecularPanel = glui->add_panel_to_panel(objMaterialPanel, "Specular");
	GLUI_Spinner *ksRedValue = glui->add_spinner_to_panel(objSpecularPanel, "Red", GLUI_SPINNER_FLOAT, &objectMat.specular[0], 0, colorCB);
	ksRedValue->set_float_limits(0.f, 1.f);
	ksRedValue->set_float_val(1.f);
	GLUI_Spinner *ksGreenValue = glui->add_spinner_to_panel(objSpecularPanel, "Green", GLUI_SPINNER_FLOAT, &objectMat.specular[1], 0, colorCB);
	ksGreenValue->set_float_limits(0.f, 1.f);
	ksGreenValue->set_float_val(1.f);
	GLUI_Spinner *ksBlueValue = glui->add_spinner_to_panel(objSpecularPanel, "Blue", GLUI_SPINNER_FLOAT, &objectMat.specular[2], 0, colorCB);
	ksBlueValue->set_float_limits(0.f, 1.f);
	ksBlueValue->set_float_val(1.f);

	glui->add_column_to_panel(lightingPanel,0);
	GLUI_Panel *lightPanel = glui->add_panel_to_panel(lightingPanel, "Light source");

	GLUI_Panel *lightDiffusePanel = glui->add_panel_to_panel(lightPanel, "Diffuse");
	GLUI_Spinner *ldRedValue = glui->add_spinner_to_panel(lightDiffusePanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[0], -1, colorCB);
	ldRedValue->set_float_limits(0.f, 1.f);
	ldRedValue->set_float_val(1.f);
	GLUI_Spinner *ldGreenValue = glui->add_spinner_to_panel(lightDiffusePanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[1], -1, colorCB);
	ldGreenValue->set_float_limits(0.f, 1.f);
	ldGreenValue->set_float_val(1.f);
	GLUI_Spinner *ldBlueValue = glui->add_spinner_to_panel(lightDiffusePanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.diffuse[2], -1, colorCB);
	ldBlueValue->set_float_limits(0.f, 1.f);
	ldBlueValue->set_float_val(1.f);

	GLUI_Panel *lightAmbientPanel = glui->add_panel_to_panel(lightPanel, "Ambient");
	GLUI_Spinner *laRedValue = glui->add_spinner_to_panel(lightAmbientPanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[0], -1, colorCB);
	laRedValue->set_float_limits(0.f, 1.f);
	laRedValue->set_float_val(1.f);
	GLUI_Spinner *laGreenValue = glui->add_spinner_to_panel(lightAmbientPanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[1], -1, colorCB);
	laGreenValue->set_float_limits(0.f, 1.f);
	laGreenValue->set_float_val(1.f);
	GLUI_Spinner *laBlueValue = glui->add_spinner_to_panel(lightAmbientPanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.ambient[2], -1, colorCB);
	laBlueValue->set_float_limits(0.f, 1.f);
	laBlueValue->set_float_val(1.f);

	GLUI_Panel *lightSpecularPanel = glui->add_panel_to_panel(lightPanel, "Specular");
	GLUI_Spinner *lsRedValue = glui->add_spinner_to_panel(lightSpecularPanel, "Red", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[0], -1, colorCB);
	lsRedValue->set_float_limits(0.f, 1.f);
	lsRedValue->set_float_val(1.f);
	GLUI_Spinner *lsGreenValue = glui->add_spinner_to_panel(lightSpecularPanel, "Green", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[1], -1, colorCB);
	lsGreenValue->set_float_limits(0.f, 1.f);
	lsGreenValue->set_float_val(1.f);
	GLUI_Spinner *lsBlueValue = glui->add_spinner_to_panel(lightSpecularPanel, "Blue", GLUI_SPINNER_FLOAT, &lightCoeffs.specular[2], -1, colorCB);
	lsBlueValue->set_float_limits(0.f, 1.f);
	lsBlueValue->set_float_val(1.f);

	GLUI_Panel *texturingPanel = glui->add_panel("Texturing");
	GLUI_Listbox *textureListbox = glui->add_listbox_to_panel(texturingPanel, "Texture", (int*)&texture, -1, textureCB);
	textureListbox->add_item(NOTEXTURE, "No texture");
	textureListbox->add_item(OSU, "OSU");
	textureListbox->add_item(EARTH, "EARTH");
	textureListbox->add_item(WOOD, "WOOD");
	textureListbox->set_int_val(NOTEXTURE);

	GLUI_Panel *texFiltersPanel = glui->add_panel_to_panel(texturingPanel, "", 0);
	GLUI_Panel *minFilterPanel = glui->add_panel_to_panel(texFiltersPanel, "Minifying filter", 1);
	GLUI_RadioGroup *minFilterGroup = glui->add_radiogroup_to_panel(minFilterPanel, (int*) &texMinFilter, -1, textureCB);
	glui->add_radiobutton_to_group(minFilterGroup, "Linear");
	glui->add_radiobutton_to_group(minFilterGroup, "Nearest");
	minFilterGroup->set_int_val(LINEAR);

	GLUI_Panel *magFilterPanel = glui->add_panel_to_panel(texFiltersPanel, "Magnifying filter", 1);
	GLUI_RadioGroup *magFilterGroup = glui->add_radiogroup_to_panel(magFilterPanel, (int*) &texMagFilter, -1, textureCB);
	glui->add_radiobutton_to_group(magFilterGroup, "Linear");
	glui->add_radiobutton_to_group(magFilterGroup, "Nearest");
	magFilterGroup->set_int_val(LINEAR);

	glui->add_column_to_panel(texFiltersPanel, 0);

	GLUI_Panel *texWrapSPanel = glui->add_panel_to_panel(texFiltersPanel, "Wrapping S", 1);
	GLUI_RadioGroup *texWrapSGroup = glui->add_radiogroup_to_panel(texWrapSPanel, (int*) &texWrap_S, -1, textureCB);
	glui->add_radiobutton_to_group(texWrapSGroup, "Repeat");
	glui->add_radiobutton_to_group(texWrapSGroup, "Clamp to edge");
	texWrapSGroup->set_int_val(CLAMPTOEDGE);

	GLUI_Panel *texWrapTPanel = glui->add_panel_to_panel(texFiltersPanel, "Wrapping T", 1);
	GLUI_RadioGroup *texWrapTGroup = glui->add_radiogroup_to_panel(texWrapTPanel, (int*) &texWrap_T, -1, textureCB);
	glui->add_radiobutton_to_group(texWrapTGroup, "Repeat");
	glui->add_radiobutton_to_group(texWrapTGroup, "Clamp to edge");
	texWrapTGroup->set_int_val(CLAMPTOEDGE);

	GLUI_Listbox *texEnvListbox = glui->add_listbox_to_panel(texturingPanel, "Environment", (int*)&texEnv, -1, textureCB);
	texEnvListbox->add_item(REPLACE, "GL_REPLACE");
	texEnvListbox->add_item(MODULATE, "GL_MODULATE");
	texEnvListbox->add_item(DECAL, "GL_DECAL");
	texEnvListbox->add_item(BLEND, "GL_BLEND");
	texEnvListbox->set_int_val(MODULATE);

	GLUI_Listbox *texGenListbox = glui->add_listbox_to_panel(texturingPanel, "UV Generation", (int*)&texGen, -1, textureCB);
	texGenListbox->add_item(OBJECT, "Object Linear");
	texGenListbox->add_item(EYE, "Eye Linear");
	texGenListbox->add_item(SPHERE, "Sphere Map");
	texGenListbox->set_int_val(OBJECT);

	GLUI_Panel *shadingPanel = glui->add_panel("Shading");
	GLUI_RadioGroup *shadingGroup = glui->add_radiogroup_to_panel(shadingPanel, (int*) &shadingModel, -1, shadingCB);
	glui->add_radiobutton_to_group(shadingGroup, "Flat");
	glui->add_radiobutton_to_group(shadingGroup, "Smooth");
	shadingGroup->set_int_val(SMOOTH);

	GLUI_Listbox *shaderListbox = glui->add_listbox_to_panel(shadingPanel, "Shader", (int*)&shader, -1, shadingCB);
	shaderListbox->add_item(NOSHADER, "Fixed function");
	shaderListbox->add_item(PASS_THROUGH, "Pass through");
	shaderListbox->add_item(DIFFUSE, "Lambert illumination");
	shaderListbox->add_item(PHONG, "Phong illumination");
	shaderListbox->add_item(TOON, "Toon shading");
	shaderListbox->add_item(PROCEDURAL, "Procedural texture");
	shaderListbox->set_int_val(PASS_THROUGH);

	glui->set_main_gfx_window(main_window);

	// We register the idle callback with GLUI, *not* with GLUT 
	GLUI_Master.set_glutIdleFunc(NULL);
	glui->sync_live();
	glutMainLoop();
	return EXIT_SUCCESS;
}
Example #13
0
  virtual bool Initialize()
  {
    cur_link=0;
    cur_driver=0;
    link_value = 0;
    driver_value = 0;
    draw_geom = 1;
    draw_bbs = 0;
    draw_com = 0;
    draw_frame = 0;
    draw_expanded = 0;
    draw_self_collision_tests = 0;
    hoverLink=hoverWidget=-1;
    hoverPt.setZero();
    pose_ik = 0;
    if(!RobotViewProgram::Initialize()) return false;
    self_colliding.resize(robot->links.size(),false);   
    UpdateConfig();

    /*
    //TEST: robot-to-robot IK test.  only works for AL5Dx2
    IKGoal test;
    test.link = 8;
    test.destLink = 16;
    test.localPosition.set(0,0,0.05);
    test.endPosition.set(0,0,0.05);
    //test.SetFixedPosition(test.endPosition);
    Matrix3 R;
    R.setRotateZ(120);
    test.SetFixedRotation(R);

    vector<IKGoal> problem(1,test);
    int iters=100;
    bool res=SolveIK(*robot,problem,1e-3,iters);
    printf("Solved IK: %d, %d iters, error %g\n",(int)res,iters,RobotIKError(*robot,test));
    UpdateConfig();
    */

    //setup GUI 
    glui = GLUI_Master.create_glui_subwindow(main_window,GLUI_SUBWINDOW_RIGHT);
    glui->set_main_gfx_window(main_window);
    GLUI_Panel* panel = glui->add_panel("Link controls");
    link_spinner = glui->add_spinner_to_panel(panel,"Index",GLUI_SPINNER_INT,&cur_link,LINK_SPINNER_ID,ControlFunc);
    link_spinner->set_int_limits(0,robot->links.size()-1,GLUI_LIMIT_WRAP);

    link_listbox = glui->add_listbox_to_panel(panel,"Name",&cur_link,LINK_LISTBOX_ID,ControlFunc);
    for(size_t i=0;i<robot->links.size();i++) {
      char buf[256];
      strcpy(buf,robot->linkNames[i].c_str());
      link_listbox->add_item(i,buf);
    }

    link_value_spinner = glui->add_spinner_to_panel(panel,"Angle",GLUI_SPINNER_FLOAT,&link_value,LINK_VALUE_SPINNER_ID,ControlFunc);
    link_info = glui->add_statictext_to_panel(panel,"Info");
    UpdateLinkValueGUI();
    UpdateLinkInfoGUI();

    panel = glui->add_panel("Driver controls");
    glui->add_checkbox_to_panel(panel,"Pose by IK",&pose_ik);
    driver_spinner = glui->add_spinner_to_panel(panel,"Index",GLUI_SPINNER_INT,&cur_driver,DRIVER_SPINNER_ID,ControlFunc);
    driver_spinner->set_int_limits(0,(int)robot->drivers.size()-1,GLUI_LIMIT_WRAP);

    driver_listbox = glui->add_listbox_to_panel(panel,"Name",&cur_driver,DRIVER_LISTBOX_ID,ControlFunc);
    for(size_t i=0;i<robot->drivers.size();i++) {
      char buf[256];
      strcpy(buf,robot->driverNames[i].c_str());
      driver_listbox->add_item(i,buf);
    }

    driver_value_spinner = glui->add_spinner_to_panel(panel,"Angle",GLUI_SPINNER_FLOAT,&driver_value,DRIVER_VALUE_SPINNER_ID,ControlFunc);
    driver_info = glui->add_statictext_to_panel(panel,"Info");

    glui->add_checkbox("Draw geometry",&draw_geom);
    glui->add_checkbox("Draw COM",&draw_com);
    glui->add_checkbox("Draw frame",&draw_frame);
    glui->add_checkbox("Draw bboxes",&draw_bbs);
    glui->add_checkbox("Draw expanded",&draw_expanded,DRAW_EXPANDED_CHECKBOX_ID,ControlFunc);
    glui->add_checkbox("Draw collision tests",&draw_self_collision_tests);
    UpdateDriverValueGUI();
    UpdateDriverInfoGUI();
    return true;
  }
Example #14
0
 void UpdateDriverListboxGUI()
 {
   driver_listbox->set_int_val(cur_driver);
   //driver_listbox->set_int_val(cur_driver);
   UpdateDriverInfoGUI();
 }
Example #15
0
int main(int argc, char** argv)
{
	using namespace TestMain;

	testCount = 0;
	while (g_testEntries[testCount].createFcn != NULL)
	{
		++testCount;
	}

	testIndex = b2Clamp(testIndex, 0, testCount-1);
	testSelection = testIndex;

	entry = g_testEntries + testIndex;
	if (entry && entry->createFcn) {
		test = entry->createFcn();
		testSelection = testIndex;
		testIndex = -1;
	}

	glutInit(&argc, argv);
	glutInitContextVersion(2, 0);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);
	char title[32];
	sprintf(title, "Box2D Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
	mainWindow = glutCreateWindow(title);
	//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glutDisplayFunc(SimulationLoop);

#if ENABLE_GLUI
	GLUI_Master.set_glutReshapeFunc(Resize);
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutMouseFunc(Mouse);
#else
	{
		glutReshapeFunc(Resize);
		glutKeyboardFunc(Keyboard);
		glutSpecialUpFunc(KeyboardSpecial);
		glutMouseFunc(Mouse);
	}
#endif  // ENABLE_GLUI

#ifdef FREEGLUT
	glutMouseWheelFunc(MouseWheel);
#endif
	glutMotionFunc(MouseMotion);

	glutKeyboardUpFunc(KeyboardUp);

#if ENABLE_GLUI
	glui = GLUI_Master.create_glui_subwindow( mainWindow,
		GLUI_SUBWINDOW_RIGHT );

	glui->add_statictext("Tests");
	GLUI_Listbox* testList =
		glui->add_listbox("", &testSelection);

	glui->add_separator();

	GLUI_Spinner* velocityIterationSpinner =
		glui->add_spinner("Vel Iters", GLUI_SPINNER_INT, &settings.velocityIterations);
	velocityIterationSpinner->set_int_limits(1, 500);

	GLUI_Spinner* positionIterationSpinner =
		glui->add_spinner("Pos Iters", GLUI_SPINNER_INT, &settings.positionIterations);
	positionIterationSpinner->set_int_limits(0, 100);

	GLUI_Spinner* particleIterationSpinner =
		glui->add_spinner("Pcl Iters", GLUI_SPINNER_INT, &settings.particleIterations);
	particleIterationSpinner->set_int_limits(1, 100);

	GLUI_Spinner* hertzSpinner =
		glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &settingsHz);

	hertzSpinner->set_float_limits(5.0f, 200.0f);

	glui->add_checkbox("Sleep", &settings.enableSleep);
	glui->add_checkbox("Warm Starting", &settings.enableWarmStarting);
	glui->add_checkbox("Time of Impact", &settings.enableContinuous);
	glui->add_checkbox("Sub-Stepping", &settings.enableSubStepping);
	glui->add_checkbox("Strict Particle/Body Contacts", &settings.strictContacts);

	//glui->add_separator();

	GLUI_Panel* drawPanel =	glui->add_panel("Draw");
	glui->add_checkbox_to_panel(drawPanel, "Shapes", &settings.drawShapes);
	glui->add_checkbox_to_panel(drawPanel, "Particles", &settings.drawParticles);
	glui->add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
	glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
	glui->add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
	glui->add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
	glui->add_checkbox_to_panel(drawPanel, "Contact Impulses", &settings.drawContactImpulse);
	glui->add_checkbox_to_panel(drawPanel, "Friction Impulses", &settings.drawFrictionImpulse);
	glui->add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
	glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
	glui->add_checkbox_to_panel(drawPanel, "Profile", &settings.drawProfile);

	int32 testCount = 0;
	TestEntry* e = g_testEntries;
	while (e->createFcn)
	{
		testList->add_item(testCount, e->name);
		++testCount;
		++e;
	}

	glui->add_button("Pause", 0, Pause);
	glui->add_button("Single Step", 0, SingleStep);
	glui->add_button("Restart", 0, Restart);

	glui->add_button("Quit", 0,(GLUI_Update_CB)Exit);

	glui->set_main_gfx_window( mainWindow );

#endif  // ENABLE_GLUI

	// Configure the fullscreen UI's viewport parameters.
	fullscreenUI.SetViewParameters(&settings.viewCenter, &extents);

	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

	glutMainLoop();

	return 0;
}
Example #16
0
int main(int argc, char** argv)
{
	simulatorPageCount = 0;
	while (g_testEntries[simulatorPageCount].createFcn != NULL)
	{
		++simulatorPageCount;
	}

	simulatorPageIndex = b2Clamp(simulatorPageIndex, 0, simulatorPageCount-1);
	simulatorPageSelection = simulatorPageIndex;

	entry = g_testEntries + simulatorPageIndex;
	simulatorPage = entry->createFcn();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);
	char title[32];
	sprintf(title, "Simulert plankesorteringsanlegg");
	mainWindow = glutCreateWindow(title);
	//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glutDisplayFunc(SimulationLoop);
	GLUI_Master.set_glutReshapeFunc(Resize);  
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutMouseFunc(Mouse);
#ifdef FREEGLUT
	glutMouseWheelFunc(MouseWheel);
#endif
	glutMotionFunc(MouseMotion);

	glutKeyboardUpFunc(KeyboardUp);

	glui = GLUI_Master.create_glui_subwindow( mainWindow, 
		GLUI_SUBWINDOW_RIGHT );

	glui->add_statictext("Tests");
	GLUI_Listbox* testList =
		glui->add_listbox("", &simulatorPageSelection);

	glui->add_separator();

	GLUI_Spinner* velocityIterationSpinner =
		glui->add_spinner("Vel Iters", GLUI_SPINNER_INT, &settings.velocityIterations);
	velocityIterationSpinner->set_int_limits(1, 500);

	GLUI_Spinner* positionIterationSpinner =
		glui->add_spinner("Pos Iters", GLUI_SPINNER_INT, &settings.positionIterations);
	positionIterationSpinner->set_int_limits(0, 100);

	GLUI_Spinner* hertzSpinner =
		glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &settingsHz);

	hertzSpinner->set_float_limits(5.0f, 200.0f);

	glui->add_checkbox("Warm Starting", &settings.enableWarmStarting);
	glui->add_checkbox("Time of Impact", &settings.enableContinuous);
	glui->add_checkbox("Sub-Stepping", &settings.enableSubStepping);

	//glui->add_separator();

	GLUI_Panel* drawPanel =	glui->add_panel("Draw");
	glui->add_checkbox_to_panel(drawPanel, "Shapes", &settings.drawShapes);
	glui->add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
	glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
	glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs);
	glui->add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
	glui->add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
	glui->add_checkbox_to_panel(drawPanel, "Contact Forces", &settings.drawContactForces);
	glui->add_checkbox_to_panel(drawPanel, "Friction Forces", &settings.drawFrictionForces);
	glui->add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
	glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
	glui->add_checkbox_to_panel(drawPanel, "Profile", &settings.drawProfile);

	int32 testCount = 0;
	SimulatorPageEntry* e = g_testEntries;
	while (e->createFcn)
	{
		testList->add_item(testCount, e->name);
		++testCount;
		++e;
	}

	glui->add_button("Pause", 0, Pause);
	glui->add_button("Single Step", 0, SingleStep);
	glui->add_button("Restart", 0, Restart);

	glui->add_button("Quit", 0,(GLUI_Update_CB)Exit);

	glui->add_separator();
	glui->add_edittext( "Serialport:", GLUI_EDITTEXT_TEXT, serialport );
	glui->add_button("Set serialport", 0, (GLUI_Update_CB)SetSerialport);

	glui->set_main_gfx_window( mainWindow );


	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

	glutMainLoop();

	return 0;
}
Example #17
0
int main(int argc, char** argv)
{
	testCount = 0;
	while (g_testEntries[testCount].createFcn != NULL)
	{
		++testCount;
	}

	testIndex = b2Clamp(testIndex, 0, testCount-1);
	testSelection = testIndex;

	entry = g_testEntries + testIndex;

	test = entry->createFcn();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(width, height);
	char title[32];
	sprintf(title, "Box2D Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
	mainWindow = glutCreateWindow(title);
	//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glutDisplayFunc(SimulationLoop);

/*	int theConnection=0;
	theConnection=setup_rlglue_network();
	runEnvironmentEventLoop(theConnection);*/

	GLUI_Master.set_glutReshapeFunc(Resize);  
	GLUI_Master.set_glutKeyboardFunc(Keyboard);
	GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
	GLUI_Master.set_glutMouseFunc(Mouse);
#ifdef FREEGLUT
	glutMouseWheelFunc(MouseWheel);
#endif
	glutMotionFunc(MouseMotion);

	glui = GLUI_Master.create_glui_subwindow( mainWindow, 
		GLUI_SUBWINDOW_RIGHT );

	glui->add_statictext("Tests");
	GLUI_Listbox* testList =
		glui->add_listbox("", &testSelection);

	glui->add_separator();

	GLUI_Spinner* velocityIterationSpinner =
		glui->add_spinner("Vel Iters", GLUI_SPINNER_INT, &settings.velocityIterations);
	velocityIterationSpinner->set_int_limits(1, 500);

	GLUI_Spinner* positionIterationSpinner =
		glui->add_spinner("Pos Iters", GLUI_SPINNER_INT, &settings.positionIterations);
	positionIterationSpinner->set_int_limits(0, 100);

	GLUI_Spinner* hertzSpinner =
		glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &settingsHz);

	hertzSpinner->set_float_limits(5.0f, 200.0f);

	glui->add_checkbox("Warm Starting", &settings.enableWarmStarting);
	glui->add_checkbox("Time of Impact", &settings.enableContinuous);

	//glui->add_separator();

	GLUI_Panel* drawPanel =	glui->add_panel("Draw");
	glui->add_checkbox_to_panel(drawPanel, "Shapes", &settings.drawShapes);
	glui->add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
	glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
	glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs);
	glui->add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
	glui->add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
	glui->add_checkbox_to_panel(drawPanel, "Contact Forces", &settings.drawContactForces);
	glui->add_checkbox_to_panel(drawPanel, "Friction Forces", &settings.drawFrictionForces);
	glui->add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
	glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);

	int32 testCount = 0;
	TestEntry* e = g_testEntries;
	while (e->createFcn)
	{
		testList->add_item(testCount, e->name);
		++testCount;
		++e;
	}

	glui->add_button("Pause", 0, Pause);
	glui->add_button("Single Step", 0, SingleStep);
	glui->add_button("Restart", 0, Restart);

	glui->add_button("Quit", 0,(GLUI_Update_CB)exit);
	glui->set_main_gfx_window( mainWindow );

	// Use a timer to control the frame rate.
	glutTimerFunc(framePeriod, Timer, 0);

////////////////////////////////////////////////////////////////////////////////////////////
	/*const char *task_spec;
	printf("\nThis is a RL Test program(Start)\n");
	task_spec = RL_init();
	printf("\nTASK SPEC : %s\n",task_spec);
   	printf("Starting offline demo\n----------------------------\nWill alternate learning for 25 episodes, then freeze policy and evaluate for 10 episodes.\n\n");
	printf("After Episode\tMean Return\tStandard Deviation\n-------------------------------------------------------------------------\n");

	oa = RL_start();

	RL_agent_message("load_policy results.dat");
	RL_agent_message("freeze learning");*/

	const char* task_spec;
	task_spec = env_init();
	agent_init(task_spec);

////////////////////////////////////////////////////////////////////////////////////////////
/*
	agent_message("load_policy results.dat");
	agent_message("freeze learning");*/

	glutMainLoop();

	return 0;
}