Exemple #1
0
void initGLUI(int window) {
	GLUI *gluiSide = GLUI_Master.create_glui_subwindow(window, GLUI_SUBWINDOW_RIGHT);
	gluiSide->set_main_gfx_window(window);

	gluiSide->add_button("New Curve",     NEW_CURVE,   gluiHandler);

	gluiSide->add_button("New Surface",   NEW_SURFACE, gluiHandler);
	surfPanel = gluiSide->add_panel("Surface Parms", GLUI_PANEL_EMBOSSED);
	GLUI_Spinner *xS = gluiSide->add_spinner_to_panel(surfPanel, "X Pts.", 
									GLUI_SPINNER_INT, &surf_x, SURF_X, gluiHandler);
	xS->set_int_limits(3, 10);
	GLUI_Spinner *yS = gluiSide->add_spinner_to_panel(surfPanel, "Y Pts.", 
									GLUI_SPINNER_INT, &surf_y, SURF_Y, gluiHandler);
	yS->set_int_limits(3, 10);
	gluiSide->add_button_to_panel(surfPanel, "Ok", SURF_OK, gluiHandler);
	surfPanel->disable();

	gluiSide->add_button("Modify Points", MODIFY,      gluiHandler);
	gluiSide->add_button("Clear Screen",  CLEAR,       gluiHandler);
	gluiSide->add_button("Camera Mode",   CAMERA,      gluiHandler);

	gluiSide->add_separator();

	GLUI_Spinner *uS = gluiSide->add_spinner("U", GLUI_SPINNER_FLOAT, &u, U, gluiHandler);
	uS->set_float_limits(0.0f, 1.0f);
	uS->set_speed(50);
	GLUI_Spinner *vS = gluiSide->add_spinner("V", GLUI_SPINNER_FLOAT, &v, V, gluiHandler);
	vS->set_float_limits(0.0f, 1.0f);
	vS->set_speed(50);

	gluiSide->add_separator();

	gluiSide->add_button("Quit", QUIT, gluiHandler);
}
//-----------------------------------------------------------------------------
// implement to initialize additional gui functionality
void NetPedestrianPlugin::initGui( void* pkUserdata ) 
{
	if( false == this->isRemoteObject() )
	{		

		GLUI* glui = ::getRootGLUI();
		GLUI_Panel* pluginPanel = static_cast<GLUI_Panel*>( pkUserdata );

		glui->add_checkbox_to_panel( pluginPanel, "Wander randomly", &this->m_bWanderSwitch);
		glui->add_checkbox_to_panel( pluginPanel, "Use direct path following", &this->m_bUseDirectedPathFollowing);
		GLUI_Control* pkControl;
		pkControl = glui->add_button_to_panel( pluginPanel, "Add", -1, addPedestrian );
		pkControl->set_ptr_val( this );
		pkControl = glui->add_button_to_panel( pluginPanel, "Remove", -1, removePedestrian  );
		pkControl->set_ptr_val( this );
	}
};
Exemple #3
0
void glutAndGluiInit(int argc, char* argv[]) {
	//////////////////////////////////////////
	//   Initialize GLUT and create window  
	//////////////////////////////////////////
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(-1, -1);
	glutInitWindowSize(640, 480);
 
	int main_window = glutCreateWindow("Scenegraph");
	glutDisplayFunc(display);
	GLUI_Master.set_glutReshapeFunc(reshape);  

	//////////////////////////////////////////
	//         GLUI UI setup         
	//////////////////////////////////////////
	// Create the side subwindow 
	GLUI* glui = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_RIGHT );
	glui->set_main_gfx_window( main_window );

	////////// Buttons 
	GLUI_Panel* panel = glui->add_panel("Add Object");
	glui->add_button_to_panel(panel, "Cone",    CONE_ID,    control_cb);
	glui->add_button_to_panel(panel, "Sphere",  SPHERE_ID,  control_cb);
	glui->add_button_to_panel(panel, "Spindle", SPINDLE_ID, control_cb);
	glui->add_button_to_panel(panel, "Teapot",  TEAPOT_ID,  control_cb);
	glui->add_button_to_panel(panel, "Torus",   TORUS_ID,   control_cb);

	panel = glui->add_panel("Grouping");
	glui->add_button_to_panel(panel, "Add Selected", ADD_ID,    control_cb);
	glui->add_button_to_panel(panel, "Select Next",  NEXT_ID,   control_cb);
	glui->add_button_to_panel(panel, "Close Group",  CLOSE_ID,  control_cb);
	glui->add_button_to_panel(panel, "Reopen Group", REOPEN_ID, control_cb);

	panel = glui->add_panel("Other");
	glui->add_button_to_panel(panel, "Print Graph", PRINT_ID, control_cb);
	glui->add_button_to_panel(panel, "Quit",        0,        control_cb);

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

	///////////// View rotation
	GLUI_Rotation *view_rot   = glui2->add_rotation( "View", &root.view_rotate.m[0]);
	view_rot->set_spin( 1.0 );  glui2->add_column( false );

	///////////// Object Translations
	GLUI_Translation *trans_x = glui2->add_translation("Xlate X", GLUI_TRANSLATION_X, &root.obj_xlate[0], 0, xformCallback);
	trans_x->set_speed( .005 ); glui2->add_column( false );
	GLUI_Translation *trans_y = glui2->add_translation("Xlate Y", GLUI_TRANSLATION_Y, &root.obj_xlate[1], 0, xformCallback);
	trans_y->set_speed( .005 ); glui2->add_column( false );
	GLUI_Translation *trans_z = glui2->add_translation("Xlate Z", GLUI_TRANSLATION_Z, &root.obj_xlate[2], 0, xformCallback);
	trans_z->set_speed( .005 ); glui2->add_column( false );

	///////////// Object Rotations
	GLUI_Translation *r_x = glui2->add_translation("Rotate X", GLUI_TRANSLATION_X, &root.obj_rdelta[0], 0, xformCallback);
	r_x->set_speed( .005 ); glui2->add_column( false );
	GLUI_Translation *r_y = glui2->add_translation("Rotate Y", GLUI_TRANSLATION_X, &root.obj_rdelta[1], 0, xformCallback);
	r_y->set_speed( .005 ); glui2->add_column( false );
	GLUI_Translation *r_z = glui2->add_translation("Rotate Z", GLUI_TRANSLATION_X, &root.obj_rdelta[2], 0, xformCallback);
	r_z->set_speed( .005 ); glui2->add_column( false );

	////////// Object Scale
	GLUI_Spinner *xspin = glui2->add_spinner("XScale:", GLUI_SPINNER_FLOAT, &root.obj_scale[0], 0, xformCallback);
	xspin->set_float_limits( .5f, 4.0 ); xspin->set_alignment( GLUI_ALIGN_RIGHT );
	GLUI_Spinner *yspin = glui2->add_spinner("YScale:", GLUI_SPINNER_FLOAT, &root.obj_scale[1], 0, xformCallback);
	yspin->set_float_limits( .5f, 4.0 ); yspin->set_alignment( GLUI_ALIGN_RIGHT );
	GLUI_Spinner *zspin = glui2->add_spinner("ZScale:", GLUI_SPINNER_FLOAT, &root.obj_scale[2], 0, xformCallback);
	zspin->set_float_limits( .5f, 4.0 ); zspin->set_alignment( GLUI_ALIGN_RIGHT );
}
int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); //double buffering, RGB mode, need depth buffer
	glutInitWindowSize(WIDTH,HEIGHT); //width, height of the window
	glutInitWindowPosition(0, 0);	// location on the screen the window appears
	
	window = glutCreateWindow("Project GUI");	// creates the window
	
	init(); //things to do once, mostly in beginning	
	
	glutDisplayFunc(handleDisplay);		// tells glut which function to call to render a screen.
	glutMotionFunc(handleMotion);		// handle when motion (this generally means when mouse is moved with a button pressed)
	
 	GLUI_Master.set_glutReshapeFunc( handleReshape );

  	//Setting opengl lights

  	GLfloat light0_ambient[] =  {0.1f, 0.1f, 0.3f, 1.0f};
  	GLfloat light0_diffuse[] =  {.6f, .6f, 1.0f, 1.0f};
  	GLfloat light0_position[] = {1.0f, 1.0f, 1.0f, 0.0f};

  	glEnable(GL_LIGHTING);
  	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_DEPTH_TEST);		// enabling depth
	
	GLUI *glui = GLUI_Master.create_glui_subwindow(window,
                     GLUI_SUBWINDOW_RIGHT);
  	new GLUI_StaticText( glui, "Project GLUI" );
  	new GLUI_Separator(glui);
	
	glui->set_main_gfx_window( window );
	GLUI_Panel *obj_panel = glui->add_panel ("Display option panel");
  	
	listbox = new GLUI_Listbox(obj_panel, "Mesh display option", &display_type, 1, controlBlock);
  	listbox->add_item(FLAT_SHADED, "Flat Shaded");
	listbox->add_item(SMOOTH_SHADED, "Smooth Shaded");
	listbox->add_item(WIREFRAME, "Wireframe");
  	listbox->add_item(EDGES_SHADED, "Shaded with mesh edges");

	//scale code
	GLUI_Spinner *scale_spinner = new GLUI_Spinner( obj_panel, "Scale:", &scale);
  	scale_spinner->set_float_limits( .2f, 5.0 );
  	scale_spinner->set_alignment( GLUI_ALIGN_RIGHT );
	
	//rotation code
	GLUI_Panel * rotation_panel = glui->add_panel_to_panel(obj_panel, "", GLUI_PANEL_NONE);
	
	GLUI_Rotation *sph_rot =
		glui->add_rotation_to_panel(rotation_panel,"Rotate", sphere_rotate,
		ROTATION_ID, controlBlock); 
	sph_rot->set_spin(1.0);

	//translation code
	GLUI_Panel * translate_panel = glui->add_panel_to_panel(obj_panel, "",
		GLUI_PANEL_NONE);	

	GLUI_Translation * move_z =
		glui->add_translation_to_panel(translate_panel,"Object Z",
		GLUI_TRANSLATION_Z, &obj_pos[2]); 
	move_z->scale_factor = 0.1f;

	glui->add_column_to_panel(translate_panel, true);
	
	GLUI_Translation * move_around =
		glui->add_translation_to_panel(translate_panel,"Object XY",
		GLUI_TRANSLATION_XY, obj_pos);
	move_around->scale_factor = 0.1f;

	GLUI_Panel * decimate_panel = glui->add_panel("Decimate Panel");

	glui->add_edittext_to_panel(decimate_panel, "No. of collapse iteration: ", GLUI_EDITTEXT_INT, &collapseCount);

	glui->add_edittext_to_panel(decimate_panel, "Random count (k): ", GLUI_EDITTEXT_INT, &KValue);

	glui->add_button_to_panel(decimate_panel, "Decimate", DECIMATE_ID, controlBlock);

	glui->add_button_to_panel(decimate_panel, "Shape Preserve", SHAPE_PRESERVE_DECIMATE_ID, controlBlock);

	glui->add_separator();

	GLUI_Panel * shape_panel = glui->add_panel("Shape based Panel");
	
	glui->add_button_to_panel(shape_panel, "Go", SURE_SHAPE_PRESERVE_DECIMATE_ID, controlBlock);

	glui->add_separator();

	GLUI_Panel * mapping_panel = glui->add_panel("Mapping Panel");

	glui->add_button_to_panel(mapping_panel, "Open map file", MAPPING_OPEN_ID, controlBlock);
	//other details
	glui->add_separator();
	glui->add_button("Open", OPEN_ID, controlBlock);
	glui->add_button("Save", SAVE_ID, controlBlock);
	glui->add_button("Reset", RESET_ID, controlBlock);
  	glui->add_button("Quit", QUIT_ID, (GLUI_Update_CB)exit);

	/* register idle callback with GLUI, NOT with GLUT */
  	GLUI_Master.set_glutIdleFunc( handleIdle );	// handle when no events are occuring 

	glutMainLoop();				// once this is called, glut takes over --
						// returns only when the window is closed	
	
	return EXIT_SUCCESS;
}