Esempio n. 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);
}
Esempio n. 2
0
bool GLUIRealTimePlannerGUI::Initialize()
{
  if(!BaseT::Initialize()) return false;

  glui = GLUI_Master.create_glui_subwindow(main_window,GLUI_SUBWINDOW_RIGHT);
  glui->set_main_gfx_window(main_window);
  AddControl(glui->add_button("New target"),"new_target");
  AddControl(glui->add_checkbox("Draw desired"),"draw_desired");
  AddControl(glui->add_checkbox("Draw commanded"),"draw_desired");
  AddControl(glui->add_checkbox("Draw UI"),"draw_ui");
  AddControl(glui->add_checkbox("Draw path"),"draw_path");
  AddControl(glui->add_checkbox("Draw contacts"),"draw_contacts");
  GLUI_Spinner* spinner = glui->add_spinner("Collision margin",GLUI_SPINNER_FLOAT);
  spinner->set_float_limits(0.0,1.0);
  AddControl(spinner,"collision_margin");

  AnyCollection c;
  bool res=c.read("{type:button_press,button:new_target}");
  Assert(res == true);
  AddCommandRule(c,"new_target","");
  res=c.read("{type:widget_value,widget:collision_margin,value:_1}");
  Assert(res == true);
  AddCommandRule(c,"set_collision_margin","_1");
  
  printf("Done initializing...\n");
  return true;
}
Esempio n. 3
0
int main(int argc, char* argv[])
{
  /****************************************/
  /*   Initialize GLUT and create window  */
  /****************************************/

  glutInit(&argc, argv);
  glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowPosition( 50, 50 );
  glutInitWindowSize( 300, 300 );
 
  main_window = glutCreateWindow( "GLUI Example 1" );
  glutDisplayFunc( myGlutDisplay );
  glutReshapeFunc( myGlutReshape );  

  /****************************************/
  /*       Set up 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);

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

  glEnable(GL_DEPTH_TEST);


  /****************************************/
  /*         Here's the GLUI code         */
  /****************************************/
  
  GLUI *glui = GLUI_Master.create_glui( "GLUI" );
  new GLUI_Checkbox( glui, "Wireframe", &wireframe );
  (new GLUI_Spinner( glui, "Segments:", &segments ))
    ->set_int_limits( 3, 60 ); 
   
  glui->set_main_gfx_window( main_window );

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

  glutMainLoop();

  return EXIT_SUCCESS;
}
Esempio n. 4
0
//! This function creates all the GLUI gui elements
void create_glui_ui(void)
{
  GLUI *glui = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_RIGHT );
  glui->add_statictext("Group 11 Simulation"); 
  new GLUI_Separator(glui);
  glui->add_statictext("Simulation Timesteps"); 
  GLUI_Spinner* velocityIterationSpinner =
    glui->add_spinner("Velocity Iterations", GLUI_SPINNER_INT, &settings.velocity_iterations);
  velocityIterationSpinner->set_int_limits(1, 500);
  
  GLUI_Spinner* positionIterationSpinner =
    glui->add_spinner("Position Iterations", GLUI_SPINNER_INT, &settings.position_iterations);
  positionIterationSpinner->set_int_limits(0, 100);
  
  GLUI_Spinner* hertzSpinner =
    glui->add_spinner("Sim steps per frame", GLUI_SPINNER_FLOAT, &settings.hz);
  hertzSpinner->set_float_limits(5.0f, 200.0f);


  new GLUI_Separator(glui);
  //new GLUI_Column( glui, false );
  glui->add_statictext("Simulation Parameters"); 
  glui->add_checkbox("Warm Starting", &settings.enable_warm_starting);
  glui->add_checkbox("Time of Impact", &settings.enable_continuous);
  glui->add_checkbox("Sub-Stepping", &settings.enable_sub_stepping);


  
  //new GLUI_Column( glui, false );
  new GLUI_Separator(glui);
  glui->add_statictext("Display Options"); 
  GLUI_Panel* drawPanel =	glui->add_panel("Draw");
  glui->add_checkbox_to_panel(drawPanel, "Shapes", &settings.draw_shapes);
  glui->add_checkbox_to_panel(drawPanel, "Joints", &settings.draw_joints);
  glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.draw_AABBs);
  glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.draw_stats);
  glui->add_checkbox_to_panel(drawPanel, "Profile", &settings.draw_profile);
  
  //new GLUI_Column( glui, false );
  new GLUI_Separator(glui);
  glui->add_button("Pause", 0, callbacks_t::pause_cb);
  glui->add_button("Single Step", 0, callbacks_t::single_step_cb);
  glui->add_button("Restart", 0, callbacks_t::restart_cb);
  glui->add_button("Quit", 0,(GLUI_Update_CB)callbacks_t::exit_cb);
  glui->set_main_gfx_window( main_window );

  new GLUI_Separator(glui);
  glui->add_statictext("Mayank Meghwanshi"); 
  glui->add_statictext("Divyam Bansal"); 
  glui->add_statictext("Jaswant Kumar"); 

}
Esempio n. 5
0
int main(int argc, char* argv[])
{
        int a;
        do
        {
                system("clear");
                imprimir_help();
                printf("continuar? (1 para sim) "); scanf("%d", &a);
        }while(a != 1);

        paused=0;
        qtd_estados=2;
        old_qtd_estados=2;
        automato = new Automato(qtd_estados);

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

        glutInit(&argc,argv); 
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
        glutInitWindowSize(800,400);
        glutInitWindowPosition(0,0);
        main_window = glutCreateWindow("It's raining languages!");
        init();
        
        glutDisplayFunc(display);
        glutIdleFunc(animate);
        

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

        GLUI *glui = GLUI_Master.create_glui( "GLUI" );
        new GLUI_Checkbox( glui, "Paused", &paused );
        (new GLUI_Spinner( glui, "Qtd. Estados:", &qtd_estados ))->set_int_limits( 2, 6 );
        edittext = new GLUI_EditText(glui, "Text:", text,3, getRegex);

        glui->set_main_gfx_window( main_window );

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

        glutMainLoop();

  return 0;
}
Esempio n. 6
0
File: sea.cpp Progetto: bradens/uvc
int main(int argc, char** argv) {


  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutInitWindowSize(500,500);
  glutInitWindowPosition(100,100);
  win =  glutCreateWindow(argv[0]);

  /* initialize background, objects, camera, etc. */
  init();

  /* callback functions */
  GLUI_Master.set_glutDisplayFunc(display);
  GLUI_Master.set_glutReshapeFunc(reshape);
  GLUI_Master.set_glutKeyboardFunc(keyboard);

  /*  GLUI Code */
  //Subwindow doesn't seem to work with mac.. refresh is not correct
  //  GLUI *glui = GLUI_Master.create_glui_subwindow(win, GLUI_SUBWINDOW_RIGHT);
  GLUI *glui = GLUI_Master.create_glui("Controls"/*name*/,0/*flags*/,100+500,100 /*x y*/);
  glui->set_main_gfx_window(win);
  GLUI_Rotation *view_rot = glui->add_rotation("Camera", curview);
  view_rot->set_spin(1.0);
  GLUI_Translation *trans_xy = glui->add_translation("XY", GLUI_TRANSLATION_XY, cameraPosition);
  trans_xy->set_speed(0.005);
  
  GLUI_Translation *trans_x = 
    glui->add_translation( "Objects X", GLUI_TRANSLATION_X, cameraPosition );
  trans_x->set_speed( .005 );
  
  GLUI_Translation *trans_y = 
    glui->add_translation( "Objects Y", GLUI_TRANSLATION_Y, &cameraPosition[1] );
  trans_y->set_speed( .005 );
  
  GLUI_Translation *trans_z = 
    glui->add_translation( "Objects Z", GLUI_TRANSLATION_Z, &cameraPosition[2] );
  trans_z->set_speed( .005 );
  
  glui->add_button("Reset View", RESET_VIEW, placeCamera);

  GLUI_Master.set_glutIdleFunc(myGlutIdle);
  glutMainLoop();
  return(0);
}
int main(int argc, char* argv[])
{
	atexit(onExit);

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

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(500, 500);

	main_window = glutCreateWindow("COMP 175 Assignment 2");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

	/****************************************/
	/*       Set up OpenGL lighting         */
	/****************************************/


	    glClearColor (0.38, 0.38, 0.38, 0.0);
        glShadeModel (GL_SMOOTH);

        GLfloat light_pos0[] = {0.0f, 0.0f, 1.0f, 0.0f};
        GLfloat diffuse[] = {0.5f, 0.5f, 0.5f, 0.0f};
        GLfloat ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};

        glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
        glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
        glLightfv (GL_LIGHT0, GL_POSITION, light_pos0);

        glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
        glEnable (GL_COLOR_MATERIAL);

        glEnable(GL_LIGHTING);
        glEnable (GL_LIGHT0);
        glEnable (GL_DEPTH_TEST);

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


	glPolygonOffset(1, 1);



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

	GLUI *glui = GLUI_Master.create_glui("GLUI");

	GLUI_Panel *render_panel = glui->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
	new GLUI_Checkbox(render_panel, "Fill", &fill);
	new GLUI_Checkbox(render_panel, "Normal", &normal);
	(new GLUI_Spinner(render_panel, "Segments X:", &segmentsX))
		->set_int_limits(3, 60);
	(new GLUI_Spinner(render_panel, "Segments Y:", &segmentsY))
		->set_int_limits(3, 60);

	GLUI_Panel *camera_panel = glui->add_panel("Camera");
	(new GLUI_Spinner(camera_panel, "RotateV:", &camRotV))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateU:", &camRotU))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateW:", &camRotW))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "Angle:", &viewAngle))
		->set_int_limits(1, 179);

	GLUI_Spinner* eyex_widget = glui->add_spinner_to_panel(camera_panel, "EyeX:", GLUI_SPINNER_FLOAT, &eyeX);
	eyex_widget->set_float_limits(-5, 5);
	GLUI_Spinner* eyey_widget = glui->add_spinner_to_panel(camera_panel, "EyeY:", GLUI_SPINNER_FLOAT, &eyeY);
	eyey_widget->set_float_limits(-5, 5);
	GLUI_Spinner* eyez_widget = glui->add_spinner_to_panel(camera_panel, "EyeZ:", GLUI_SPINNER_FLOAT, &eyeZ);
	eyez_widget->set_float_limits(-5, 5);

	GLUI_Spinner* lookx_widget = glui->add_spinner_to_panel(camera_panel, "LookX:", GLUI_SPINNER_FLOAT, &lookX);
	lookx_widget->set_float_limits(-5, 5);
	GLUI_Spinner* looky_widget = glui->add_spinner_to_panel(camera_panel, "LookY:", GLUI_SPINNER_FLOAT, &lookY);
	looky_widget->set_float_limits(-5, 5);
	GLUI_Spinner* lookz_widget = glui->add_spinner_to_panel(camera_panel, "LookZ:", GLUI_SPINNER_FLOAT, &lookZ);
	lookz_widget->set_float_limits(-5, 5);

	GLUI_Spinner* clipN_widget = glui->add_spinner_to_panel(camera_panel, "Near:", GLUI_SPINNER_FLOAT, &clipNear);
	clipN_widget->set_float_limits(0, 10);
	GLUI_Spinner* clipF_widget = glui->add_spinner_to_panel(camera_panel, "Far:", GLUI_SPINNER_FLOAT, &clipFar);
	clipF_widget->set_float_limits(0, 100);

	glui->add_column(true);

	GLUI_Panel *obj_panel = glui->add_panel("Object Type");
	GLUI_RadioGroup *group1 =
		glui->add_radiogroup_to_panel(obj_panel, (int*)(&objType), 3, callback_obj);
	glui->add_radiobutton_to_group(group1, "Cube");
	glui->add_radiobutton_to_group(group1, "Cylinder");
	glui->add_radiobutton_to_group(group1, "Cone");
	glui->add_radiobutton_to_group(group1, "Sphere");
	glui->add_radiobutton_to_group(group1, "Special1");


	GLUI_Panel *object_panel = glui->add_panel("Object");
	(new GLUI_Spinner(object_panel, "Rotate X:", &rotX))
		->set_int_limits(0, 359);
	(new GLUI_Spinner(object_panel, "Rotate Y:", &rotY))
		->set_int_limits(0, 359);
	(new GLUI_Spinner(object_panel, "Rotate Z:", &rotZ))
		->set_int_limits(0, 359);
	(new GLUI_Spinner(object_panel, "Scale:", &scale))
		->set_int_limits(1, 100);

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

	glui->set_main_gfx_window(main_window);

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

	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 8
0
int main(int argc, char* argv[])
{

	atexit(onExit);
	/****************************************/
	/*   Initialize GLUT and create window  */
	/****************************************/
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(100, 100);
	glutInitWindowSize(windowXSize, windowYSize);

	main_window = glutCreateWindow("COMP 175 In Class Assignment 7");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);
	/****************************************/
	/*       Set up OpenGL lighting         */
	/****************************************/
	glShadeModel(GL_SMOOTH);

	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);
	
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	static float one[] = { 1, 1, 1, 1 };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, one);
	/****************************************/
	/*          Enable z-buferring          */
	/****************************************/
	glEnable(GL_DEPTH_TEST);
	glPolygonOffset(1, 1);

	/****************************************/
	/*		Setup textured Objects          */
	/****************************************/
	myObject->setTexture(0,"./data/pink.ppm");
	myObject->setTexture(1,"./data/smile.ppm");

	/****************************************/
	/*         Here's the GLUI code         */
	/****************************************/
	GLUI *glui = GLUI_Master.create_glui("GLUI");

	GLUI_Scrollbar* sb1 = new GLUI_Scrollbar(glui, "Red", GLUI_SCROLL_HORIZONTAL, &red_Scroll, COLORR_ID, control_cb);
	sb1->set_int_limits(0, 255);
	GLUI_Scrollbar* sb2 = new GLUI_Scrollbar(glui, "Green", GLUI_SCROLL_HORIZONTAL, &green_Scroll, COLORG_ID, control_cb);
	sb2->set_int_limits(0, 255);
	GLUI_Scrollbar* sb3 = new GLUI_Scrollbar(glui, "Blue", GLUI_SCROLL_HORIZONTAL, &blue_Scroll, COLORB_ID, control_cb);
	sb3->set_int_limits(0, 255);
	sb1->set_int_val(255);
	sb2->set_int_val(255);

/*
    // Create a rotation widget
    GLUI_Rotation *view_rot = new GLUI_Rotation(glui, "Objects", view_rotate );
    view_rot->set_spin( 1.0 );

    // Navigate our scene
    new GLUI_Column( glui, false );
    GLUI_Translation *trans_x =  new GLUI_Translation(glui, "Objects X", GLUI_TRANSLATION_X, obj_pos );
    trans_x->set_speed( .1 );
    new GLUI_Column( glui, false );
    GLUI_Translation *trans_y =  new GLUI_Translation( glui, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] );
    trans_y->set_speed( .1 );
    new GLUI_Column( glui, false );
    GLUI_Translation *trans_z =  new GLUI_Translation( glui, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] );
    trans_z->set_speed( .1 );
*/
	glui->add_column(true);

	GLUI_Panel *render_panel = glui->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
	new GLUI_Checkbox(render_panel, "Filled", &filled);
	new GLUI_Checkbox(render_panel, "Paint", &paint);

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

	glui->set_main_gfx_window(main_window);
	/* We register the idle callback with GLUI, *not* with GLUT */
	GLUI_Master.set_glutIdleFunc(myGlutIdle);
	GLUI_Master.set_glutMouseFunc( myGlutMouse );
	glutMotionFunc( myGlutMotion );

	glutMainLoop();

	return EXIT_SUCCESS;
}
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;
}
Esempio n. 10
0
// initialize GLUI
int MeshGui::initGlui(void)
{
	// create the side subwindow
	GLUI *glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_RIGHT);

	// radio button group
	GLUI_RadioGroup *ot_group = new GLUI_RadioGroup (glui, &radiogroup_item_id, SHADING_MODE, control_cb);
	// shading choices
	glui->add_radiobutton_to_group( ot_group, "flatShaded" );
	glui->add_radiobutton_to_group( ot_group, "smoothShaded" );
	glui->add_radiobutton_to_group( ot_group, "wireframe" );
	glui->add_radiobutton_to_group( ot_group, "shadedEdges" );
	glui->add_radiobutton_to_group( ot_group, "point" );
	// load and save smf file
	new GLUI_EditText (glui, "smf/", GLUI_EDITTEXT_TEXT, filetext, INPUT_FILE, control_cb);
	new GLUI_Button( glui, "open", OPEN_MESH, control_cb );
	new GLUI_Button( glui, "save", SAVE_MESH, control_cb );
	// A 'quit' button
	new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit );

	// some controls for lights
	//GLUI_Rollout *roll_lights = new GLUI_Rollout(glui, "Lights", false);
	GLUI_Panel *light0 = new GLUI_Panel( glui, "Light 0" );
	GLUI_Panel *light1 = new GLUI_Panel( glui, "Light 1" );
	new GLUI_Checkbox( light0, "Enabled", &light0_enabled, LIGHT0_ENABLE, control_cb );
	light0_spinner = new GLUI_Spinner( light0, "Intensity:", &light0_intensity, LIGHT0_INTENSITY, control_cb );
	light0_spinner->set_float_limits( 0.0, 1.0 );
	GLUI_Scrollbar *sb;
	sb = new GLUI_Scrollbar( light0, "Red",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[0],LIGHT0_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	sb = new GLUI_Scrollbar( light0, "Green",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[1],LIGHT0_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	sb = new GLUI_Scrollbar( light0, "Blue",GLUI_SCROLL_HORIZONTAL, &light0_diffuse[2],LIGHT0_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	new GLUI_Checkbox( light1, "Enabled", &light1_enabled, LIGHT1_ENABLE, control_cb );
	light1_spinner = new GLUI_Spinner( light1, "Intensity:", &light1_intensity, LIGHT1_INTENSITY, control_cb );
	light1_spinner->set_float_limits( 0.0, 1.0 );
	sb = new GLUI_Scrollbar( light1, "Red",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[0],LIGHT1_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	sb = new GLUI_Scrollbar( light1, "Green",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[1],LIGHT1_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	sb = new GLUI_Scrollbar( light1, "Blue",GLUI_SCROLL_HORIZONTAL, &light1_diffuse[2],LIGHT1_INTENSITY,control_cb);
	sb->set_float_limits(0,1);
	// edge number to randomly choose from
	GLUI_Spinner *edge_spinner = new GLUI_Spinner(glui, "EdgeNumber", &edge_number, EDGE_NUMBER, control_cb );
	edge_spinner->set_float_limits(2, 100);
	// edge percentage to collapse
	GLUI_Spinner *percentage_spinner = new GLUI_Spinner(glui, "CollapsePercentage%", &collapse_percentage, COLLAPSE_NUMBER, control_cb );
	percentage_spinner->set_float_limits(1, 100);
	new GLUI_Button(glui, "decimate", DECIMATE, control_cb );

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

	// Create the bottom subwindow
	GLUI *glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM );
	glui2->set_main_gfx_window( main_window );
	// rotate the world
	GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "Objects", view_rotate );
	view_rot->set_spin( 1.0 );
	// rotate the model
	new GLUI_Column( glui2, false );
	GLUI_Rotation *sph_rot = new GLUI_Rotation(glui2, "Model", mesh_rotate );
	sph_rot->set_spin( .98 );
	// rotate the blue light
	new GLUI_Column( glui2, false );
	GLUI_Rotation *lights_rot = new GLUI_Rotation(glui2, "Blue Light", lights_rotation );
	lights_rot->set_spin( .82 );
	// object XY translate
	new GLUI_Column( glui2, false );
	GLUI_Translation *trans_xy = new GLUI_Translation(glui2, "Objects XY", GLUI_TRANSLATION_XY, obj_pos );
	trans_xy->set_speed( .005 );
	// object X translate
	new GLUI_Column( glui2, false );
	GLUI_Translation *trans_x = new GLUI_Translation(glui2, "Objects X", GLUI_TRANSLATION_X, obj_pos );
	trans_x->set_speed( .005 );
	// object Y translate
	new GLUI_Column( glui2, false );
	GLUI_Translation *trans_y = new GLUI_Translation( glui2, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] );
	trans_y->set_speed( .005 );
	// object y translate
	new GLUI_Column( glui2, false );
	GLUI_Translation *trans_z = new GLUI_Translation( glui2, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] );
	trans_z->set_speed( .005 );

	return EXIT_SUCCESS;
}
Esempio n. 11
0
int main(int argc, char **argv) {

    /* Seed random */
    srand(time(NULL));

    /* Init glut and glew */
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(X_SIZE, Y_SIZE);
    glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
    glutInitContextProfile(GLUT_CORE_PROFILE);
    glewExperimental = GL_TRUE;

    /* Create window */
    main_window = glutCreateWindow("Project");
    glewInit();
    glEnable(GL_DEPTH_TEST);

    /* Model init */
    Model::program_init();

    /* Data init */
    init();

    /* Glut functions */
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(special);
    glutIdleFunc(NULL);

    /* Glui */
    GLUI* glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_RIGHT);
    
    glui->set_main_gfx_window(main_window);

    glui->add_statictext("Camera Rotate");
    glui->add_separator();
    glui->add_button("X+", CAMERA_XPR, button_callback);
    glui->add_button("X-", CAMERA_XNR, button_callback);  
    glui->add_button("Y+", CAMERA_YPR, button_callback);
    glui->add_button("Y-", CAMERA_YNR, button_callback);
    glui->add_button("Z+", CAMERA_ZPR, button_callback);
    glui->add_button("Z-", CAMERA_ZNR, button_callback);

    glui->add_statictext("Camera Translate");
    glui->add_separator();
    glui->add_button("X+", CAMERA_XPT, button_callback);
    glui->add_button("X-", CAMERA_XNT, button_callback);  
    glui->add_button("Y+", CAMERA_YPT, button_callback);
    glui->add_button("Y-", CAMERA_YNT, button_callback);
    glui->add_button("Z+", CAMERA_ZPT, button_callback);
    glui->add_button("Z-", CAMERA_ZNT, button_callback);    

    glui->add_statictext("Light");
    glui->add_separator();
    glui->add_button("X+", LIGHT_XPT, button_callback);
    glui->add_button("X-", LIGHT_XNT, button_callback); 
    glui->add_button("Y+", LIGHT_YPT, button_callback);
    glui->add_button("Y-", LIGHT_YNT, button_callback);    
    glui->add_button("Z+", LIGHT_ZPT, button_callback);
    glui->add_button("Z-", LIGHT_ZNT, button_callback);   
    glui->add_button("Light+", LIGHTP, button_callback);
    glui->add_button("Light-", LIGHTN, button_callback);      

    glui->add_statictext("Materials");
    glui->add_separator();
    glui->add_button("Ambient+", AMBIENTP, button_callback);
    glui->add_button("Ambient-", AMBIENTN, button_callback); 
    glui->add_button("Diffuse+", DIFFUSEP, button_callback);
    glui->add_button("Diffuse-", DIFFUSEN, button_callback);    
    glui->add_button("Specular+", SPECULARP, button_callback);
    glui->add_button("Specular-", SPECULARN, button_callback);       
        
    GLUI_Master.set_glutIdleFunc(idle);

    /* Main loop */
    glutMainLoop();

    return 0;
}
Esempio n. 12
0
int main(int argc, char* argv[])
{
	Sub_mesh_d.load_mesh(argv[1]);
	Con_mesh_d.load_mesh(argv[1]);
	Sub_mesh_d.triangulation();
  for(int i=0;i<3;i++){
	Sub_mesh_d.make_edges();
	Sub_mesh_d.make_neighbours();
	//Sub_mesh_d.calculate_normals();

	Sub_mesh_d.subdivide();
	Sub_mesh_d.calculate_normals();
}
	printf("\n\t\t Dodecahedron finished**********\n");
	Sub_mesh_e.load_mesh(argv[2]);
	Con_mesh_e.load_mesh(argv[2]);
	Sub_mesh_e.triangulation();
  Sub_mesh_e.calculate_normals();

	Sub_mesh_e.make_edges();
	Sub_mesh_e.make_neighbours();
	Sub_mesh_e.subdivide();
	Sub_mesh_e.calculate_normals();
  /****************************************/
  /*   Initialize GLUT and create window  */
  /****************************************/

  glutInit(&argc, argv);
  glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowPosition( 50, 50 );
  glutInitWindowSize( 300, 300 );

  main_window = glutCreateWindow( "GLUI Example 2" );
  glutDisplayFunc( myGlutDisplay );
  glutReshapeFunc( myGlutReshape );
  glutKeyboardFunc( myGlutKeyboard );
  glutMotionFunc( myGlutMotion );
  glutMouseFunc( myGlutMouse );

  /****************************************/
  /*       Set up 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);

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

  glEnable(GL_DEPTH_TEST);

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

  GLUI *glui = GLUI_Master.create_glui( "GLUI", 0, 400, 50 ); /* name, flags,
                 x, and y */
  new GLUI_StaticText( glui, "GLUI Example 2" );
  new GLUI_Separator( glui );
  checkbox = new GLUI_Checkbox( glui, "Control Mesh", &wireframe, 1, control_cb );

  spinner  = new GLUI_Spinner( glui, "Subdivision _factor", &segments, 2, control_cb );
  spinner->set_int_limits( 3, 60 );

  rotate = new GLUI_Rotation(glui, "view_rotate",view_rotate);
  rotate -> set_spin(1.0);

  Light_rotate = new GLUI_Rotation(glui, "light_rotate",light_rotate);
  Light_rotate -> set_spin(1.0);
  GLUI_Panel *obj_panel = new GLUI_Panel( glui, "mesh selection" );
  radio = new GLUI_RadioGroup( obj_panel,&obj,4,control_cb );
  new GLUI_RadioButton( radio, "Dodecahedron" );
  new GLUI_RadioButton( radio, "Ellel" );

  GLUI_Panel *control = new GLUI_Panel(glui,"Control Mesh Changer");
  new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit );

  glui->set_main_gfx_window( main_window );

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

  glutMainLoop();

  return EXIT_SUCCESS;
}
Esempio n. 13
0
int main(int argc, char* argv[])
{
	atexit(onExit);

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

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(500, 500);

	main_window = glutCreateWindow("COMP 175 Assignment 4");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

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

	GLUI* glui = GLUI_Master.create_glui("GLUI");

	filenameTextField = new GLUI_EditText( glui, "Filename:", filenamePath);
	filenameTextField->set_w(300);
	glui->add_button("Load", 0, callback_load);
	glui->add_button("Start!", 0, callback_start);
	glui->add_checkbox("Isect Only", &isectOnly);
	
	GLUI_Panel *camera_panel = glui->add_panel("Camera");
	(new GLUI_Spinner(camera_panel, "RotateV:", &camRotV))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateU:", &camRotU))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateW:", &camRotW))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "Angle:", &viewAngle))
		->set_int_limits(1, 179);

	glui->add_column_to_panel(camera_panel, true);

	GLUI_Spinner* eyex_widget = glui->add_spinner_to_panel(camera_panel, "EyeX:", GLUI_SPINNER_FLOAT, &eyeX);
	eyex_widget->set_float_limits(-10, 10);
	GLUI_Spinner* eyey_widget = glui->add_spinner_to_panel(camera_panel, "EyeY:", GLUI_SPINNER_FLOAT, &eyeY);
	eyey_widget->set_float_limits(-10, 10);
	GLUI_Spinner* eyez_widget = glui->add_spinner_to_panel(camera_panel, "EyeZ:", GLUI_SPINNER_FLOAT, &eyeZ);
	eyez_widget->set_float_limits(-10, 10);

	GLUI_Spinner* lookx_widget = glui->add_spinner_to_panel(camera_panel, "LookX:", GLUI_SPINNER_FLOAT, &lookX);
	lookx_widget->set_float_limits(-10, 10);
	GLUI_Spinner* looky_widget = glui->add_spinner_to_panel(camera_panel, "LookY:", GLUI_SPINNER_FLOAT, &lookY);
	looky_widget->set_float_limits(-10, 10);
	GLUI_Spinner* lookz_widget = glui->add_spinner_to_panel(camera_panel, "LookZ:", GLUI_SPINNER_FLOAT, &lookZ);
	lookz_widget->set_float_limits(-10, 10);

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

	glui->set_main_gfx_window(main_window);

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

	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 14
0
void createInterface() {

    GLUI *glui = GLUI_Master.create_glui("RGBD Effects", 0, 1050, 100);

    //Effect Selection
    GLUI_Panel *effectSelectionPanel = glui->add_panel("Effect");
    GLUI_RadioGroup *effectRadioGroup = glui->add_radiogroup_to_panel(effectSelectionPanel, &selectedEffect, -1, gluiCallback);
    glui->add_radiobutton_to_group(effectRadioGroup, "Maps");
    glui->add_radiobutton_to_group(effectRadioGroup, "Fog");
    glui->add_radiobutton_to_group(effectRadioGroup, "Depth of Field");
    glui->add_radiobutton_to_group(effectRadioGroup, "Relighting");
    glui->add_radiobutton_to_group(effectRadioGroup, "Cartoon Shading");

    //Depth range
    glui->add_statictext("");
    GLUI_Panel *depthRangePanel = glui->add_panel("Depth Range");
    GLUI_Checkbox *adaptiveDepthRangeCheckBox = glui->add_checkbox_to_panel(depthRangePanel, "Adaptive ", &adaptiveDepthRange, -1, gluiCallback);
    GLUI_Spinner *nearPlaneSpinner = glui->add_spinner_to_panel(depthRangePanel, "Near Plane ", GLUI_SPINNER_FLOAT, &nearPlane, -1, gluiCallback);
    nearPlaneSpinner->set_float_limits(10, 2000);
    GLUI_Spinner *farPlaneSpinner = glui->add_spinner_to_panel(depthRangePanel, "Far Plane ", GLUI_SPINNER_FLOAT, &farPlane, -1, gluiCallback);
    farPlaneSpinner->set_float_limits(10, 2000);

    //View maps
    GLUI_Rollout *mapRollout = glui->add_rollout("Maps", 0);
    mapRollout->set_w(218);
    glui->add_statictext_to_panel(mapRollout, "")->set_w(200);
    GLUI_RadioGroup *mapRadioGroup = glui->add_radiogroup_to_panel(mapRollout, &mapEffect->selectedMap, -1, gluiCallback);
    glui->add_radiobutton_to_group(mapRadioGroup, "Colour");
    glui->add_radiobutton_to_group(mapRadioGroup, "Depth");
    glui->add_radiobutton_to_group(mapRadioGroup, "Normals");

    GLUI_Panel* mapPreblurPanel = glui->add_panel_to_panel(mapRollout, "Pre-processing");
    GLUI_RadioGroup *mapPreblurRadioGroup = glui->add_radiogroup_to_panel(mapPreblurPanel, &mapEffect->selectedPreFilter, -1, gluiCallback);
    glui->add_radiobutton_to_group(mapPreblurRadioGroup, "None");
    glui->add_radiobutton_to_group(mapPreblurRadioGroup, "Blur");
    glui->add_radiobutton_to_group(mapPreblurRadioGroup, "Bilateral");

    GLUI_Spinner *mapPreblurPassesSpinner = glui->add_spinner_to_panel(mapPreblurPanel, "Filter Passes ", GLUI_SPINNER_INT, &mapEffect->preblurFilterPasses, -1, gluiCallback);
    mapPreblurPassesSpinner->set_int_limits(0, 10);
    GLUI_Spinner *mapPreblurKernelSizeSpinner = glui->add_spinner_to_panel(mapPreblurPanel, "Kernel Size ", GLUI_SPINNER_INT, &mapEffect->preblurKernelSize, -1, gluiCallback);
    mapPreblurKernelSizeSpinner->set_int_limits(1, 100);
    GLUI_Spinner *mapPreblurSigmaSpinner = glui->add_spinner_to_panel(mapPreblurPanel, "Sample Deviation ", GLUI_SPINNER_FLOAT, &mapEffect->preblurSigma, -1, gluiCallback);
    mapPreblurSigmaSpinner->set_float_limits(0.001, 0.15);



    //FOG
    GLUI_Rollout *fogRollout = glui->add_rollout("Fog", 0);
    fogRollout->set_w(218);
    glui->add_statictext_to_panel(fogRollout, "")->set_w(200);
    GLUI_Spinner *fogDensitySpinner = glui->add_spinner_to_panel(fogRollout, "Density ", GLUI_SPINNER_FLOAT, &fogEffect->fogDensity, -1, gluiCallback);
    fogDensitySpinner->set_float_limits(0.0, 20.0);
    GLUI_Spinner *fogAmountSpinner = glui->add_spinner_to_panel(fogRollout, "Amount ", GLUI_SPINNER_FLOAT, &fogEffect->fogAmount, -1, gluiCallback);
    fogAmountSpinner->set_float_limits(0.0, 1);

    glui->add_statictext_to_panel(fogRollout, "");
    GLUI_Panel* fogPreblurPanel = glui->add_panel_to_panel(fogRollout, "Preblur");

    GLUI_Spinner *fogPreblurPassesSpinner = glui->add_spinner_to_panel(fogPreblurPanel, "Filter Passes ", GLUI_SPINNER_INT, &fogEffect->preblurFilterPasses, -1, gluiCallback);
    fogPreblurPassesSpinner->set_int_limits(0, 10);
    GLUI_Spinner *fogPreblurKernelSizeSpinner = glui->add_spinner_to_panel(fogPreblurPanel, "Kernel Size ", GLUI_SPINNER_INT, &fogEffect->preblurKernelSize, -1, gluiCallback);
    fogPreblurKernelSizeSpinner->set_int_limits(1, 100);
    GLUI_Spinner *fogPreblurSigmaSpinner = glui->add_spinner_to_panel(fogPreblurPanel, "Sample Deviation ", GLUI_SPINNER_FLOAT, &fogEffect->preblurSigma, -1, gluiCallback);
    fogPreblurSigmaSpinner->set_float_limits(0.001, 0.15);


    glui->add_statictext_to_panel(fogRollout, "");
    GLUI_Panel* fogColourPanel = glui->add_panel_to_panel(fogRollout, "Colour", GLUI_PANEL_EMBOSSED);

    GLUI_Spinner *fogColourRedSpinner = glui->add_spinner_to_panel(fogColourPanel, "Red ", GLUI_SPINNER_FLOAT, &fogEffect->fogColourRed, -1, gluiCallback);
    fogColourRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *fogColourGreenSpinner = glui->add_spinner_to_panel(fogColourPanel, "Green ", GLUI_SPINNER_FLOAT, &fogEffect->fogColourGreen, -1, gluiCallback);
    fogColourGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *fogColourBlueSpinner = glui->add_spinner_to_panel(fogColourPanel, "Blue ", GLUI_SPINNER_FLOAT, &fogEffect->fogColourBlue, -1, gluiCallback);
    fogColourBlueSpinner->set_float_limits(0.0, 1);


    //DEPTH OF FIELD
    GLUI_Rollout *DOFRollout = glui->add_rollout("Depth of Field", 0);
    DOFRollout->set_w(218);
    glui->add_statictext_to_panel(DOFRollout, "")->set_w(200);

    GLUI_Spinner *distributionSigmaSpinner = glui->add_spinner_to_panel(DOFRollout, "Sample Deviation ", GLUI_SPINNER_FLOAT, &dofEffect->distributionSigma, -1, gluiCallback);
    distributionSigmaSpinner->set_float_limits(0.001, 0.15);
    GLUI_Spinner *sampleRadiusSpinner = glui->add_spinner_to_panel(DOFRollout, "Sample Radius ", GLUI_SPINNER_INT, &dofEffect->sampleRadius, -1, gluiCallback);
    sampleRadiusSpinner->set_int_limits(1, 40);


    GLUI_Spinner *lensDiameterSpinner = glui->add_spinner_to_panel(DOFRollout, "Aperture Size ", GLUI_SPINNER_FLOAT, &dofEffect->lensDiameter, -1, gluiCallback);
    lensDiameterSpinner->set_float_limits(0.001, 1);
    GLUI_Spinner *focalLengthSpinner = glui->add_spinner_to_panel(DOFRollout, "Focal Length ", GLUI_SPINNER_FLOAT, &dofEffect->focalLength, -1, gluiCallback);
    focalLengthSpinner->set_float_limits(0.001, 1);
    GLUI_Spinner *focalDepthSpinner = glui->add_spinner_to_panel(DOFRollout, "Focal Depth ", GLUI_SPINNER_FLOAT, &dofEffect->focalPlaneDepth, -1, gluiCallback);
    focalDepthSpinner->set_float_limits(0.0, 1);

    glui->add_statictext_to_panel(DOFRollout, "");
    GLUI_Panel* DOFPreblurPanel = glui->add_panel_to_panel(DOFRollout, "Preblur");

    GLUI_Spinner *DOFPreblurPassesSpinner = glui->add_spinner_to_panel(DOFPreblurPanel, "Filter Passes ", GLUI_SPINNER_INT, &dofEffect->preblurFilterPasses, -1, gluiCallback);
    DOFPreblurPassesSpinner->set_int_limits(0, 10);
    GLUI_Spinner *DOFPreblurKernelSizeSpinner = glui->add_spinner_to_panel(DOFPreblurPanel, "Kernel Size ", GLUI_SPINNER_INT, &dofEffect->preblurKernelSize, -1, gluiCallback);
    DOFPreblurKernelSizeSpinner->set_int_limits(1, 100);
    GLUI_Spinner *DOFPreblurSigmaSpinner = glui->add_spinner_to_panel(DOFPreblurPanel, "Sample Deviation ", GLUI_SPINNER_FLOAT, &dofEffect->preblurSigma, -1, gluiCallback);
    DOFPreblurSigmaSpinner->set_float_limits(0.001, 0.15);


    //Relighting
    GLUI_Rollout *relightingRollout = glui->add_rollout("Relighting", 0);
    relightingRollout->set_w(218);
    glui->add_statictext_to_panel(relightingRollout, "")->set_w(200);
    glui->add_rotation_to_panel(relightingRollout, "Light Direction", relightingEffect->lightDirection, -1, gluiCallback);


    GLUI_Panel* relightingPreblurPanel = glui->add_panel_to_panel(relightingRollout, "Pre-processing");
    GLUI_RadioGroup *relightingPreblurRadioGroup = glui->add_radiogroup_to_panel(relightingPreblurPanel, &relightingEffect->selectedPreFilter, -1, gluiCallback);
    glui->add_radiobutton_to_group(relightingPreblurRadioGroup, "None");
    glui->add_radiobutton_to_group(relightingPreblurRadioGroup, "Blur");
    glui->add_radiobutton_to_group(relightingPreblurRadioGroup, "Bilateral");

    GLUI_Spinner *relightingPreblurPassesSpinner = glui->add_spinner_to_panel(relightingPreblurPanel, "Filter Passes ", GLUI_SPINNER_INT, &relightingEffect->preblurFilterPasses, -1, gluiCallback);
    relightingPreblurPassesSpinner->set_int_limits(0, 10);
    GLUI_Spinner *relightingPreblurKernelSizeSpinner = glui->add_spinner_to_panel(relightingPreblurPanel, "Kernel Size ", GLUI_SPINNER_INT, &relightingEffect->preblurKernelSize, -1, gluiCallback);
    relightingPreblurKernelSizeSpinner->set_int_limits(1, 100);
    GLUI_Spinner *relightingPreblurSigmaSpinner = glui->add_spinner_to_panel(relightingPreblurPanel, "Sample Deviation ", GLUI_SPINNER_FLOAT, &relightingEffect->preblurSigma, -1, gluiCallback);
    relightingPreblurSigmaSpinner->set_float_limits(0.001, 0.15);




    GLUI_Rollout* materialRollout = glui->add_rollout_to_panel(relightingRollout, "Material", 0, GLUI_PANEL_EMBOSSED);

    GLUI_Panel* materialAmbientPanel = glui->add_panel_to_panel(materialRollout, "Ambient", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *materialAmbientRedSpinner = glui->add_spinner_to_panel(materialAmbientPanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->materialAmbient[0], -1, gluiCallback);
    materialAmbientRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialAmbientGreenSpinner = glui->add_spinner_to_panel(materialAmbientPanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->materialAmbient[1], -1, gluiCallback);
    materialAmbientGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialAmbientBlueSpinner = glui->add_spinner_to_panel(materialAmbientPanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->materialAmbient[2], -1, gluiCallback);
    materialAmbientBlueSpinner->set_float_limits(0.0, 1);

    GLUI_Panel* materialDiffusePanel = glui->add_panel_to_panel(materialRollout, "Diffuse", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *materialDiffuseRedSpinner = glui->add_spinner_to_panel(materialDiffusePanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->materialDiffuse[0], -1, gluiCallback);
    materialDiffuseRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialDiffuseGreenSpinner = glui->add_spinner_to_panel(materialDiffusePanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->materialDiffuse[1], -1, gluiCallback);
    materialDiffuseGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialDiffuseBlueSpinner = glui->add_spinner_to_panel(materialDiffusePanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->materialDiffuse[2], -1, gluiCallback);
    materialDiffuseBlueSpinner->set_float_limits(0.0, 1);

    GLUI_Panel* materialSpecularPanel = glui->add_panel_to_panel(materialRollout, "Specular", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *materialSpecularRedSpinner = glui->add_spinner_to_panel(materialSpecularPanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->materialSpecular[0], -1, gluiCallback);
    materialSpecularRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialSpecularGreenSpinner = glui->add_spinner_to_panel(materialSpecularPanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->materialSpecular[1], -1, gluiCallback);
    materialSpecularGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *materialSpecularBlueSpinner = glui->add_spinner_to_panel(materialSpecularPanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->materialSpecular[2], -1, gluiCallback);
    materialSpecularBlueSpinner->set_float_limits(0.0, 1);

    GLUI_Rollout* lightRollout = glui->add_rollout_to_panel(relightingRollout, "Light", 0, GLUI_PANEL_EMBOSSED);

    GLUI_Panel* lightAmbientPanel = glui->add_panel_to_panel(lightRollout, "Ambient", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *lightAmbientRedSpinner = glui->add_spinner_to_panel(lightAmbientPanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->lightAmbient[0], -1, gluiCallback);
    lightAmbientRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightAmbientGreenSpinner = glui->add_spinner_to_panel(lightAmbientPanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->lightAmbient[1], -1, gluiCallback);
    lightAmbientGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightAmbientBlueSpinner = glui->add_spinner_to_panel(lightAmbientPanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->lightAmbient[2], -1, gluiCallback);
    lightAmbientBlueSpinner->set_float_limits(0.0, 1);

    GLUI_Panel* lightDiffusePanel = glui->add_panel_to_panel(lightRollout, "Diffuse", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *lightDiffuseRedSpinner = glui->add_spinner_to_panel(lightDiffusePanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->lightDiffuse[0], -1, gluiCallback);
    lightDiffuseRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightDiffuseGreenSpinner = glui->add_spinner_to_panel(lightDiffusePanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->lightDiffuse[1], -1, gluiCallback);
    lightDiffuseGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightDiffuseBlueSpinner = glui->add_spinner_to_panel(lightDiffusePanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->lightDiffuse[2], -1, gluiCallback);
    lightDiffuseBlueSpinner->set_float_limits(0.0, 1);

    GLUI_Panel* lightSpecularPanel = glui->add_panel_to_panel(lightRollout, "Specular", GLUI_PANEL_EMBOSSED);
    GLUI_Spinner *lightSpecularRedSpinner = glui->add_spinner_to_panel(lightSpecularPanel, "Red ", GLUI_SPINNER_FLOAT, &relightingEffect->lightSpecular[0], -1, gluiCallback);
    lightSpecularRedSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightSpecularGreenSpinner = glui->add_spinner_to_panel(lightSpecularPanel, "Green ", GLUI_SPINNER_FLOAT, &relightingEffect->lightSpecular[1], -1, gluiCallback);
    lightSpecularGreenSpinner->set_float_limits(0.0, 1);
    GLUI_Spinner *lightSpecularBlueSpinner = glui->add_spinner_to_panel(lightSpecularPanel, "Blue ", GLUI_SPINNER_FLOAT, &relightingEffect->lightSpecular[2], -1, gluiCallback);
    lightSpecularBlueSpinner->set_float_limits(0.0, 1);

    glui->add_statictext_to_panel(relightingRollout, "");
    GLUI_Spinner *specularPowerSpinner = glui->add_spinner_to_panel(relightingRollout, "Shininess ", GLUI_SPINNER_FLOAT, &relightingEffect->shininess, -1, gluiCallback);
    specularPowerSpinner->set_float_limits(0.0, 50);


    //CARTOON SHADING
    GLUI_Rollout *cartoonRollout = glui->add_rollout("Cartoon Shading", 0);
    cartoonRollout->set_w(218);
    glui->add_statictext_to_panel(cartoonRollout, "")->set_w(200);

    GLUI_Panel *filteringPanel = glui->add_panel_to_panel(cartoonRollout, "Filtering");
    glui->add_statictext_to_panel(filteringPanel, "");
    GLUI_RadioGroup *filteringMethodRadioGroup = glui->add_radiogroup_to_panel(filteringPanel, &cartoonEffect->filteringMethod, -1, gluiCallback);
    glui->add_radiobutton_to_group(filteringMethodRadioGroup, "None");
    glui->add_radiobutton_to_group(filteringMethodRadioGroup, "Bilateral");
    glui->add_radiobutton_to_group(filteringMethodRadioGroup, "Kuwahara");

    glui->add_statictext_to_panel(filteringPanel, "");
    glui->add_checkbox_to_panel(filteringPanel, "Quantize Colours", &cartoonEffect->quantize, -1, gluiCallback);


    //Bilateral.
    glui->add_statictext_to_panel(filteringPanel, "");
    GLUI_Rollout* bilateralRollout = glui->add_rollout_to_panel(filteringPanel, "Bilateral", 0, GLUI_PANEL_EMBOSSED);

    GLUI_Spinner *bilateralFilterPassesSpinner = glui->add_spinner_to_panel(bilateralRollout, "Filter Passes ", GLUI_SPINNER_INT, &cartoonEffect->bilateralFilterPasses, -1, gluiCallback);
    bilateralFilterPassesSpinner->set_int_limits(1, 10);
    GLUI_Spinner *bilateralKernelSizeSpinner = glui->add_spinner_to_panel(bilateralRollout, "Kernel Size ", GLUI_SPINNER_INT, &cartoonEffect->bilateralKernelSize, -1, gluiCallback);
    bilateralKernelSizeSpinner->set_int_limits(1, 100);
    GLUI_Spinner *bilateralSigmaSpinner = glui->add_spinner_to_panel(bilateralRollout, "Sample Deviation ", GLUI_SPINNER_FLOAT, &cartoonEffect->bilateralSigma, -1, gluiCallback);
    bilateralSigmaSpinner->set_float_limits(0.001, 0.15);

    //Kuwahara.
    GLUI_Rollout* kuwaharaRollout = glui->add_rollout_to_panel(filteringPanel, "Kuwahara", 0, GLUI_PANEL_EMBOSSED);

    GLUI_Spinner *kuwaharaFilterPassesSpinner = glui->add_spinner_to_panel(kuwaharaRollout, "Filter Passes ", GLUI_SPINNER_INT, &cartoonEffect->kuwaharaFilterPasses, -1, gluiCallback);
    kuwaharaFilterPassesSpinner->set_int_limits(1, 10);
    GLUI_Spinner *kuwaharaKernelSizeSpinner = glui->add_spinner_to_panel(kuwaharaRollout, "Kernel Size ", GLUI_SPINNER_INT, &cartoonEffect->kuwaharaKernelSize, -1, gluiCallback);
    kuwaharaKernelSizeSpinner->set_int_limits(1, 100);


    //Edge
    glui->add_statictext_to_panel(cartoonRollout, "");
    GLUI_Panel *edgeDetectionPanel = glui->add_panel_to_panel(cartoonRollout, "Edge Detection");
    glui->add_statictext_to_panel(edgeDetectionPanel, "");
    GLUI_RadioGroup *edgeMethodRadioGroup = glui->add_radiogroup_to_panel(edgeDetectionPanel, &cartoonEffect->edgeMethod, -1, gluiCallback);
    glui->add_radiobutton_to_group(edgeMethodRadioGroup, "None");
    glui->add_radiobutton_to_group(edgeMethodRadioGroup, "Depth Discontinuity");
    glui->add_radiobutton_to_group(edgeMethodRadioGroup, "Sobel Depth");
    glui->add_radiobutton_to_group(edgeMethodRadioGroup, "Sobel Colour");





    glui->add_statictext_to_panel(edgeDetectionPanel, "");
    GLUI_Spinner *edgeThresholdSpinner = glui->add_spinner_to_panel(edgeDetectionPanel, "Threshold ", GLUI_SPINNER_FLOAT, &cartoonEffect->edgeThreshold, -1, gluiCallback);
    edgeThresholdSpinner->set_float_limits(0.0, 2.0);


    //glui->add_button("Quit", 0, (GLUI_Update_CB) exit);
    /** Tell GLUI window which other window to recognize as the main gfx window **/
    glui->set_main_gfx_window(window);

    //GLUI_Master.set_glutIdleFunc(NULL);


}
Esempio n. 15
0
int main(int argc, char* argv[])
{
	atexit(onExit);

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

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(500, 500);

	main_window = glutCreateWindow("COMP 175 Assignment 3");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

	glShadeModel (GL_SMOOTH);

	glEnable(GL_DEPTH_TEST);

	// Specular reflections will be off without this, since OpenGL calculates
	// specular highlights using an infinitely far away camera by default, not
	// the actual location of the camera
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	// Show all ambient light for the entire scene (not one by default)
	GLfloat one[] = { 0.5f, 0.5f, 0.5f, 1.0f };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, one);

	glPolygonOffset(1, 1);



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

	GLUI* glui = GLUI_Master.create_glui("GLUI");

	filenameTextField = new GLUI_EditText( glui, "Filename:", filenamePath);
	filenameTextField->set_w(300);
	glui->add_button("Load", 0, callback_load);
	
	GLUI_Panel *camera_panel = glui->add_panel("Camera");
	(new GLUI_Spinner(camera_panel, "RotateV:", &camRotV))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateU:", &camRotU))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "RotateW:", &camRotW))
		->set_int_limits(-179, 179);
	(new GLUI_Spinner(camera_panel, "Angle:", &viewAngle))
		->set_int_limits(1, 179);

	glui->add_column_to_panel(camera_panel, true);

	GLUI_Spinner* eyex_widget = glui->add_spinner_to_panel(camera_panel, "EyeX:", GLUI_SPINNER_FLOAT, &eyeX);
	eyex_widget->set_float_limits(-10, 10);
	GLUI_Spinner* eyey_widget = glui->add_spinner_to_panel(camera_panel, "EyeY:", GLUI_SPINNER_FLOAT, &eyeY);
	eyey_widget->set_float_limits(-10, 10);
	GLUI_Spinner* eyez_widget = glui->add_spinner_to_panel(camera_panel, "EyeZ:", GLUI_SPINNER_FLOAT, &eyeZ);
	eyez_widget->set_float_limits(-10, 10);

	GLUI_Spinner* lookx_widget = glui->add_spinner_to_panel(camera_panel, "LookX:", GLUI_SPINNER_FLOAT, &lookX);
	lookx_widget->set_float_limits(-10, 10);
	GLUI_Spinner* looky_widget = glui->add_spinner_to_panel(camera_panel, "LookY:", GLUI_SPINNER_FLOAT, &lookY);
	looky_widget->set_float_limits(-10, 10);
	GLUI_Spinner* lookz_widget = glui->add_spinner_to_panel(camera_panel, "LookZ:", GLUI_SPINNER_FLOAT, &lookZ);
	lookz_widget->set_float_limits(-10, 10);

	glui->add_column(true);

	GLUI_Panel *render_panel = glui->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
	new GLUI_Checkbox(render_panel, "Fill", &fillObj);
	(new GLUI_Spinner(render_panel, "Segments X:", &segmentsX))
		->set_int_limits(3, 60);
	(new GLUI_Spinner(render_panel, "Segments Y:", &segmentsY))
		->set_int_limits(3, 60);


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

	glui->set_main_gfx_window(main_window);

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

	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 16
0
void init(int* argc, char** argv)
{
	glutInit(argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Qix");

	const Qix::Color FrameColor = 0xff999999;
	const Qix::Color PlayerColor = 0xffff0000;
    
    

	sceneTransform = Qix::Transformation(
		Qix::Vector3(0, 0, -2),
		Qix::Vector3(0.1, 0.1, 0.1),
		Qix::Vector3(0, 0, 0)
	);

	light = Qix::Light(Qix::Vector4(6, 8, 0, 0));
	light.ambient = 0xff333333;

	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, -6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(-8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, 6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	bouncy = Qix::Bouncy(Qix::Sphere(
			Qix::Transformation(
				Qix::Vector3(0, 0, 0),
				Qix::Vector3(0.4, 0.4, 0.4),
				Qix::Vector3(0, 0, 0)
			),
			PlayerColor
		)
	);
    bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2;

	prepareScene();

	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

	//glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings");
    
    GLUI_Panel* pan;
    

    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));
    
    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));    
    
    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));
    
    mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    pan = new GLUI_Panel(mainPan, "Sphere Settings");
    pan->set_alignment(GLUI_ALIGN_LEFT);
    mainPan->set_w(500);
    new GLUI_Column(mainPan, false);
    createAngleSelector(pan, "Initial Angle", &ballAngle);
    createResetButton(pan, "Reset");

    pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE);
    new GLUI_StaticText(pan, "                                                ");
    new GLUI_Column(mainPan, false);

    pan = new GLUI_Panel(mainPan, "Other");
    new GLUI_Column(mainPan, false);
    pan->set_alignment(GLUI_ALIGN_RIGHT);
    createExitButton(pan, "Exit");
	

	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	glutMainLoop();
}
Esempio n. 17
0
int ProgramManager::Run(int argc, char **argv)
{

	DoSomeTests();

	int x, y;
	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);

	int window_id = glutCreateWindow(PROGRAM_NAME);

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping ( NEW )
	glDisable(GL_BLEND); //just killing to be sure

	//glBlendFunc (GL_SRC_ALPHA, GL_DST_ALPHA);
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LESS);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	//glEnable(GL_CULL_FACE);
	//glCullFace(GL_BACK);
	//glFrontFace(GL_CCW);

	glEnable(GL_NORMALIZE);


	//set up key state tracking
	glutIgnoreKeyRepeat(true);
	GLUI_Master.set_glutKeyboardFunc(ProgramManager::KeyboardDown);
	glutKeyboardUpFunc(ProgramManager::KeyboardUp);
	GLUI_Master.set_glutSpecialFunc(ProgramManager::SpecialFunc);

	GLUI_Master.set_glutMouseFunc( ProgramManager::mousebutton );
	GLUI_Master.set_glutReshapeFunc( ProgramManager::reshape );

	glutMotionFunc(ProgramManager::mousemove);
	glutDisplayFunc(ProgramManager::display);

	GLUI *glui = GLUI_Master.create_glui_subwindow(window_id, GLUI_SUBWINDOW_RIGHT);
	glui->set_main_gfx_window(window_id);

	GLUI_Master.set_glutIdleFunc(ProgramManager::tick);
	
	m_gui.Initialize(window_id, glui);

	GLUI_Master.get_viewport_area(&x, &y, &width, &height);
	m_gui.SetViewportSize(width, height);
	//char sdf[100];
	//sprintf_s(sdf, "width: %d", WINDOW_WIDTH - width);
	//UserPromptUtil::UserMessageBox(sdf, "ARAR");
	
	m_gui.SetDefaults();

	glutMainLoop();

	return 0;
}
Esempio n. 18
0
int main(int argc, char* argv[])
{
	atexit(onExit);

	/****************************************/
	/*   Initialize GLUT and create window  */
	/****************************************/
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(500, 500);

	main_window = glutCreateWindow("COMP 175 In Class Assignment 5");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

	/****************************************/
	/*       Set up OpenGL lighting         */
	/****************************************/
	glShadeModel(GL_SMOOTH);

	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);
	
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	static float one[] = { 1, 1, 1, 1 };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, one);
	/****************************************/
	/*          Enable z-buferring          */
	/****************************************/
	glEnable(GL_DEPTH_TEST);
	glPolygonOffset(1, 1);

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

	GLUI *glui = GLUI_Master.create_glui("GLUI");

	/*** Create the bottom subwindow ***/
    glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM );
    // Create a rotation widget
    GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "Objects", view_rotate );
    view_rot->set_spin( 1.0 );

    // Navigate our scene
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_x =  new GLUI_Translation(glui2, "Objects X", GLUI_TRANSLATION_X, obj_pos );
    trans_x->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_y =  new GLUI_Translation( glui2, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] );
    trans_y->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_z =  new GLUI_Translation( glui2, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] );
    trans_z->set_speed( .1 );

    new GLUI_Checkbox(glui2, "Follow Coaster", &followCoaster);

	glui2->add_column(true);

	GLUI_Panel *render_panel = glui2->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Render Spline", &renderSpline);
	new GLUI_Checkbox(render_panel, "Render ControlPoints", &renderControlPoints);
	new GLUI_Checkbox(render_panel, "Render Roller Coaster", &renderRollerCoaster);
	new GLUI_Checkbox(render_panel, "Grid", &grid);

	resolution_spinner =
    new GLUI_Spinner( render_panel, "Resolution:",
                     &resolution, RESOLUTION_ID,
                     pointer_cb );
    resolution_spinner->set_int_limits( 50, 500 );

	new GLUI_Button(render_panel, "CalculateSpline", SPLINE_ID, pointer_cb);
	glui2->add_button("Quit", 0, (GLUI_Update_CB)exit);

	glui->set_main_gfx_window(main_window);
	/* We register the idle callback with GLUI, *not* with GLUT */
	GLUI_Master.set_glutIdleFunc(myGlutIdle);

	// Setup the points for our spline
	populatePoints();

	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 19
0
int main(int argc, char* argv[])
{
	atexit(onExit);

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

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(100, 50);
	glutInitWindowSize(600, 600);

	main_window = glutCreateWindow("COMP 175 In Class Assignment 3");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

	/****************************************/
	/*       Set up OpenGL lighting         */
	/****************************************/

	// Essentially set the background color of the 3D scene.
	glClearColor(0.1, 0.1, 0.1, 1.0);
	glShadeModel(GL_FLAT);

	GLfloat light_pos0[] = { 0.0f, 0.0f, 1.0f, 0.0f };
	GLfloat diffuse[] = { 0.5f, 0.5f, 0.5f, 0.0f };
	GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_POSITION, light_pos0);

	//glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

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

	glEnable(GL_DEPTH_TEST);
	glPolygonOffset(1, 1);

	/****************************************/
	/*           Setup 3D Objects           */
	/****************************************/

	// Make the t-rex big!
	trex->setScale(10,10,10); 
	// Increase the size of the t-rex as well
	jeep->setScale(3,3,3);	  

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

	GLUI *glui = GLUI_Master.create_glui("GLUI");


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

    // Navigate our movie scene
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_x =  new GLUI_Translation(glui2, "View X", GLUI_TRANSLATION_X, view_pos );
    trans_x->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_y =  new GLUI_Translation( glui2, "View Y", GLUI_TRANSLATION_Y, &view_pos[1] );
    trans_y->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_z =  new GLUI_Translation( glui2, "View Z", GLUI_TRANSLATION_Z, &view_pos[2] );
    trans_z->set_speed( .1 );

    // Adds another column so the next panel will contain all of these elements.
	glui2->add_column(true);
	// Create a panel that will have 3 checkbox components
	GLUI_Panel *render_panel = glui2->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
	new GLUI_Checkbox(render_panel, "Filled", &filled);
	new GLUI_Checkbox(render_panel, "Grid", &grid);

	// Seperate out another column
	glui2->add_column(true);
	// Add a new panel, and then 3 buttons to it.
	GLUI_Panel *action_panel = glui2->add_panel("Ready And...");
	new GLUI_Button(action_panel, "Action", ACTION_ID, pointer_cb);
	new GLUI_Button(action_panel, "cut cut Cut!", CUT_ID, pointer_cb);

	glui2->add_button("Quit", 0, (GLUI_Update_CB)exit);

	glui->set_main_gfx_window(main_window);
	/* We register the idle callback with GLUI, *not* with GLUT */
	GLUI_Master.set_glutIdleFunc(myGlutIdle);

	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 20
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 );
}
Esempio n. 21
0
void
CurvatureUI::build()
{
   
   assert(!glui);

   int root_x, root_y, root_w, root_h;
   view->win()->size(root_w,root_h);
   view->win()->position(root_x,root_y);

   glui = GLUI_Master.create_glui("Curvature gTexture Controls", 0,
                                  root_x + root_w + 10, root_y);
   glui->set_main_gfx_window(view->win()->id());
   
   // General Controls:
   
   sliders[SLIDER_SC_THRESH]
      = new GLUI_Slider(glui, "Suggestive Contour Threshold",
         SLIDER_SC_THRESH, &CurvatureUI::slider_cb,
         GLUI_SLIDER_FLOAT, 0.0f, 0.1f,
         &(CurvatureUISingleton::Instance()._sc_thresh));
   
   // Line Drawing gTexture Controls:
   
   rollouts[ROLLOUT_LINE_DRAWING]
      = new GLUI_Rollout(glui, "Line Drawing Controls", true);
   
   checkboxes[CHECKBOX_DRAW_CONTOURS]
      = new GLUI_Checkbox(rollouts[ROLLOUT_LINE_DRAWING],
         "Draw Contours",
         &(CurvatureUISingleton::Instance()._line_drawing_draw_contours),
         CHECKBOX_DRAW_CONTOURS, &CurvatureUI::checkbox_cb);
   checkboxes[CHECKBOX_DRAW_SUGCONTOURS]
      = new GLUI_Checkbox(rollouts[ROLLOUT_LINE_DRAWING],
         "Draw Suggestive Contours",
         &(CurvatureUISingleton::Instance()._line_drawing_draw_sugcontours),
         CHECKBOX_DRAW_SUGCONTOURS, &CurvatureUI::checkbox_cb);
   checkboxes[CHECKBOX_DRAW_COLOR]
      = new GLUI_Checkbox(rollouts[ROLLOUT_LINE_DRAWING],
         "Draw in Color",
         &(CurvatureUISingleton::Instance()._line_drawing_draw_color),
         CHECKBOX_DRAW_COLOR, &CurvatureUI::checkbox_cb);
   
   // Curvature gTexture Controls:
   
   rollouts[ROLLOUT_CURVATURE_VIS]
      = new GLUI_Rollout(glui, "Curvature Controls", true);
   
   checkboxes[CHECKBOX_DRAW_GAUSSIAN_CURVATURE]
      = new GLUI_Checkbox(rollouts[ROLLOUT_CURVATURE_VIS],
         "Draw Gaussian Curvature",
         &(CurvatureUISingleton::Instance()._curvature_draw_gaussian_curv),
         CHECKBOX_DRAW_GAUSSIAN_CURVATURE, &CurvatureUI::checkbox_cb);
   rollouts[ROLLOUT_CURVATURE_GAUSSIAN_FILTER]
      = new GLUI_Rollout(rollouts[ROLLOUT_CURVATURE_VIS],
         "Gaussian Curvature Filter", true);
   radiogroups[RADIOGROUP_GAUSSIAN_FILTER]
      = new GLUI_RadioGroup(rollouts[ROLLOUT_CURVATURE_GAUSSIAN_FILTER],
         &(CurvatureUISingleton::Instance()._curvature_gaussian_filter),
         RADIOGROUP_GAUSSIAN_FILTER, &CurvatureUI::radiogroup_cb);
   radiobuttons[RADIOBUTTON_GAUSSIAN_FILTER_NONE]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_GAUSSIAN_FILTER],
         "None");
   radiobuttons[RADIOBUTTON_GAUSSIAN_FILTER_GAUSSIAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_GAUSSIAN_FILTER],
         "By Derivative of Gaussian Curvature");
   radiobuttons[RADIOBUTTON_GAUSSIAN_FILTER_MEAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_GAUSSIAN_FILTER],
         "By Derivative of Mean Curvature");
   radiobuttons[RADIOBUTTON_GAUSSIAN_FILTER_RADIAL]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_GAUSSIAN_FILTER],
         "By Derivative of Radial Curvature");
   
   checkboxes[CHECKBOX_DRAW_MEAN_CURVATURE]
      = new GLUI_Checkbox(rollouts[ROLLOUT_CURVATURE_VIS],
         "Draw Mean Curvature",
         &(CurvatureUISingleton::Instance()._curvature_draw_mean_curv),
         CHECKBOX_DRAW_MEAN_CURVATURE, &CurvatureUI::checkbox_cb);
   rollouts[ROLLOUT_CURVATURE_MEAN_FILTER]
      = new GLUI_Rollout(rollouts[ROLLOUT_CURVATURE_VIS],
         "Mean Curvature Filter", true);
   radiogroups[RADIOGROUP_MEAN_FILTER]
      = new GLUI_RadioGroup(rollouts[ROLLOUT_CURVATURE_MEAN_FILTER],
         &(CurvatureUISingleton::Instance()._curvature_mean_filter),
         RADIOGROUP_MEAN_FILTER, &CurvatureUI::radiogroup_cb);
   radiobuttons[RADIOBUTTON_MEAN_FILTER_NONE]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_MEAN_FILTER],
         "None");
   radiobuttons[RADIOBUTTON_MEAN_FILTER_GAUSSIAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_MEAN_FILTER],
         "By Derivative of Gaussian Curvature");
   radiobuttons[RADIOBUTTON_MEAN_FILTER_MEAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_MEAN_FILTER],
         "By Derivative of Mean Curvature");
   radiobuttons[RADIOBUTTON_MEAN_FILTER_RADIAL]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_MEAN_FILTER],
         "By Derivative of Radial Curvature");
   
   checkboxes[CHECKBOX_DRAW_RADIAL_CURVATURE]
      = new GLUI_Checkbox(rollouts[ROLLOUT_CURVATURE_VIS],
         "Draw Radial Curvature",
         &(CurvatureUISingleton::Instance()._curvature_draw_radial_curv),
         CHECKBOX_DRAW_RADIAL_CURVATURE, &CurvatureUI::checkbox_cb);
   rollouts[ROLLOUT_CURVATURE_RADIAL_FILTER]
      = new GLUI_Rollout(rollouts[ROLLOUT_CURVATURE_VIS],
         "Radial Curvature Filter", true);
   radiogroups[RADIOGROUP_RADIAL_FILTER]
      = new GLUI_RadioGroup(rollouts[ROLLOUT_CURVATURE_RADIAL_FILTER],
         &(CurvatureUISingleton::Instance()._curvature_radial_filter),
         RADIOGROUP_RADIAL_FILTER, &CurvatureUI::radiogroup_cb);
   radiobuttons[RADIOBUTTON_RADIAL_FILTER_NONE]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_RADIAL_FILTER],
         "None");
   radiobuttons[RADIOBUTTON_RADIAL_FILTER_GAUSSIAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_RADIAL_FILTER],
         "By Derivative of Gaussian Curvature");
   radiobuttons[RADIOBUTTON_RADIAL_FILTER_MEAN]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_RADIAL_FILTER],
         "By Derivative of Mean Curvature");
   radiobuttons[RADIOBUTTON_RADIAL_FILTER_RADIAL]
      = new GLUI_RadioButton(radiogroups[RADIOGROUP_RADIAL_FILTER],
         "By Derivative of Radial Curvature");
   
}
Esempio n. 22
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;
  }
Esempio n. 23
0
void init(int* argc, char** argv)
{
	glutInit(argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Qix");

	const Qix::Color FrameColor = 0xff999999;
	const Qix::Color PlayerColor = 0xffff0000;

	sceneTransform = Qix::Transformation(
		Qix::Vector3(0, 0, -2),
		Qix::Vector3(0.1, 0.1, 0.1),
		Qix::Vector3(0, 0, 0)
	);

	light = Qix::Light(Qix::Vector4(6, 8, 0, 0));
	light.ambient = 0xff333333;

	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, -6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(-8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, 6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Sphere(
			Qix::Transformation(
				Qix::Vector3(-5, 3, 0),
				Qix::Vector3(0.4, 0.4, 0.4),
				Qix::Vector3(0, 0, 0)
			),
			PlayerColor
		)
	);

	prepareScene();

	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

	//glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLUI* glui = GLUI_Master.create_glui("Light Controls", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    
    
    GLUI_Panel* pan;
    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));
    
    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));    
    
    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));
    
    createExitButton(glui, "Exit");
	

	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	glutMainLoop();
}
Esempio n. 24
0
int main(int argc, char* argv[])
{
        
        atexit(onExit);

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

        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
        glutInitWindowPosition(50, 50);
        glutInitWindowSize(500, 500);

        main_window = glutCreateWindow("COMP 175 In Class Lab 7");
        glutDisplayFunc(myGlutDisplay);
        glutReshapeFunc(myGlutReshape);

        /****************************************/
        /*       Set up OpenGL lighting         */
        /****************************************/

        // Essentially set the background color of the 3D scene.
        //glClearColor(.9f, .9f, .9f, 1.0f);
        glClearColor(0.1, 0.1, 0.1, 1.0);
        glShadeModel(GL_FLAT);

        GLfloat light_pos0[] = { 0.0f, 0.0f, 1.0f, 0.0f };
        GLfloat diffuse[] = { 0.5f, 0.5f, 0.5f, 0.0f };
        GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };

        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
        glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
        glLightfv(GL_LIGHT0, GL_POSITION, light_pos0);

        //glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
        glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
        glEnable(GL_COLOR_MATERIAL);

        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);

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

        glEnable(GL_DEPTH_TEST);
        glPolygonOffset(1, 1);

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

        GLUI *glui = GLUI_Master.create_glui("GLUI");

        GLUI_Panel *render_panel = glui->add_panel("Render");
        new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
        new GLUI_Checkbox(render_panel, "Filled", &filled);
        new GLUI_Checkbox(render_panel, "Silhouette", &silhouette);

        GLUI_Panel *camera_panel = glui->add_panel("Camera");
        (new GLUI_Spinner(camera_panel, "Rotate Y:", &rotY))->set_int_limits(0, 359);
        (new GLUI_Spinner(camera_panel, "Scale:", &scale))
                ->set_int_limits(1, 1000);


        filenameTextField = new GLUI_EditText( glui, "Filename:", filenamePath);
        filenameTextField->set_w(300);
        glui->add_button("Load PLY", 0, callback_load);


        glui->add_column(true);
        glui->add_button("Quit", 0, (GLUI_Update_CB)exit);

        glui->set_main_gfx_window(main_window);
        /* We register the idle callback with GLUI, *not* with GLUT */
        GLUI_Master.set_glutIdleFunc(myGlutIdle);



        glutMainLoop();

        return EXIT_SUCCESS;
}
Esempio n. 25
0
int main(int argc, char* argv[])
{
  glutInit(&argc, argv);

  GLUI *edit = GLUI_Master.create_glui("Help on GLUI Widgets", 0);
  main_window = edit->get_glut_window_id();
  GLUI_Panel *ep = new GLUI_Panel(edit,"",true);
  new GLUI_StaticText(ep,"Widget Information:");
  hah = new GLUI_List(ep,true,1,control_cb);
  hah->add_item(0,"GLUI 2.3");
  hah->add_item(1,"TextBox");
  hah->add_item(2,"Scrollbar");
  hah->add_item(3,"GLUI_String");
  hah->add_item(4,"CommandLine");
  hah->add_item(5,"Tree");
  hah->add_item(6,"List");
  hah->add_item(7,"FileBrowser");
  new GLUI_StaticText(ep,"Open Text File:");
  fb = new GLUI_FileBrowser(ep, "", false, 7, control_cb);
  fb->set_h(180);
  hah->set_h(180);
  new GLUI_Column(ep,false);

  moo = new GLUI_TextBox(ep,true,1,textbox_cb);
  moo->set_text(general);
  moo->set_h(400);
  moo->set_w(410);
  moo->disable();
  enable_textbox=0;
  new GLUI_Checkbox(ep, "Enable text box:",&enable_textbox,12,control_cb);

  tree = GLUI_Master.create_glui("Tree Test", 0);
  ep = new GLUI_Panel(tree, "Tree Controls");
  bedit = new GLUI_EditText(ep, "New Branch Name:");
  new GLUI_Checkbox(ep, "Display Numbers", &num_display);
  new GLUI_StaticText(ep, "Number format:");
  GLUI_RadioGroup *rg = new GLUI_RadioGroup(ep, &num_format);
  new GLUI_RadioButton(rg, "Level Only");
  new GLUI_RadioButton(rg, "Hierarchal");
  new GLUI_Button(ep, "Update Format", 11, control_cb);
  new GLUI_Column(ep);
  new GLUI_Button(ep, "Add Branch", 2, control_cb);
  new GLUI_Button(ep, "Del Branch", 3, control_cb);
  new GLUI_Button(ep, "Up Branch", 4, control_cb);
  new GLUI_Button(ep, "Goto Root", 5, control_cb);
  new GLUI_Column(ep);
  new GLUI_Button(ep, "Descend to Leaf", 6, control_cb);
  new GLUI_Button(ep, "Next Branch", 8, control_cb);
  new GLUI_Button(ep, "Expand All", 9, control_cb);
  new GLUI_Button(ep, "Collapse All", 10, control_cb);
  tp = new GLUI_TreePanel(tree,"Tree Test");
  tp->set_format(GLUI_TREEPANEL_ALTERNATE_COLOR |
                 GLUI_TREEPANEL_CONNECT_CHILDREN_ONLY |
                 GLUI_TREEPANEL_DISPLAY_HIERARCHY |
                 GLUI_TREEPANEL_HIERARCHY_NUMERICDOT);
  tp->set_level_color(1,1,1);
  tp->ab("foo you");
  tree->hide();

  edit->set_main_gfx_window(main_window);
  tree->set_main_gfx_window(main_window);

  glutMainLoop();
  return 0;
}
Esempio n. 26
0
void init(int* argc, char** argv)
{
    memset(keys, 0, sizeof(keys));

    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800, 600);
    mainWindow = glutCreateWindow("Qix");

    const Qix::Color FrameColor = 0xff999999;
    const Qix::Color BouncyColor = 0xffff0000;


    frameTexture = Qix::Texture::loadImage("grasstiles.dat");

    sceneTransform = Qix::Transformation(
                         Qix::Vector3(0, 0, -2),
                         Qix::Vector3(0.1, 0.1, 0.1),
                         Qix::Vector3(0, 0, 0)
                     );

    light = Qix::Light(Qix::Vector4(6, 8, 0, 4));
    light.ambient = 0xff666666;

    map.init(frameTexture);
    bouncy = Qix::Bouncy(Qix::Sphere(
                             Qix::Transformation(
                                 Qix::Vector3(0, 0, 0),
                                 Qix::Vector3(0.2, 0.2, 0.2),
                                 Qix::Vector3(0, 0, 0)
                             ),
                             BouncyColor
                         )
                        );
    bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2;

    player.init();

    prepareScene();

    // Enable depth checking.
    glEnable(GL_DEPTH_TEST);

    //glutIdleFunc(idle);
    glutTimerFunc(10, animate, 1);
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);

    GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings");

    GLUI_Panel* pan;


    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));

    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));

    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));

    mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    pan = new GLUI_Panel(mainPan, "Sphere Settings");
    pan->set_alignment(GLUI_ALIGN_LEFT);
    mainPan->set_w(500);
    new GLUI_Column(mainPan, false);
    createAngleSelector(pan, "Initial Angle", &ballAngle);
    createResetButton(pan, "Reset");

    pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE);
    new GLUI_StaticText(pan, "                                                ");
    new GLUI_Column(mainPan, false);

    pan = new GLUI_Panel(mainPan, "Other");
    new GLUI_Column(mainPan, false);
    pan->set_alignment(GLUI_ALIGN_RIGHT);
    createExitButton(pan, "Exit");


    glutIgnoreKeyRepeat(true);
    glutKeyboardFunc(keyboard);
    glutKeyboardUpFunc(release);

    glui->set_main_gfx_window(mainWindow);
    GLUI_Master.set_glutIdleFunc(idle);

    glutMainLoop();
}
Esempio n. 27
0
int main(int argc, char* argv[])
{
	atexit(onExit);

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

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitWindowPosition(50, 50);
	glutInitWindowSize(500, 500);

	main_window = glutCreateWindow("COMP 175 In Class Assignment 10");
	glutDisplayFunc(myGlutDisplay);
	glutReshapeFunc(myGlutReshape);

	/****************************************/
	/*       Set up OpenGL lighting         */
	/****************************************/

	glShadeModel(GL_SMOOTH);

	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);
	
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	static float one[] = { 1, 1, 1, 1 };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, one);


	/****************************************/
	/*       Set up OpenGL Shaders          */
	/****************************************/

	// Initialize our shader using our special shader manager class.
	myShaderManager = new shaderManager();
	
	myShaderManager->loadImage("brick.ppm",0);
	myShaderManager->loadImage("bump.ppm",1);

	//myShaderManager->initShader("shaders/Bump/bump.vert","shaders/Bump/bump.frag");
	dragonPLY = new ply("./data/dragon.ply");

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

	glEnable(GL_DEPTH_TEST);
	glPolygonOffset(1, 1);

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

	GLUI *glui = GLUI_Master.create_glui("GLUI");

	/*** Create the bottom subwindow ***/
    glui2 = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM );
    // Create a rotation widget
    GLUI_Rotation *view_rot = new GLUI_Rotation(glui2, "Objects", view_rotate );
    view_rot->set_spin( 1.0 );

    // Navigate our world
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_x =  new GLUI_Translation(glui2, "Objects X", GLUI_TRANSLATION_X, obj_pos );
    trans_x->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_y =  new GLUI_Translation( glui2, "Objects Y", GLUI_TRANSLATION_Y, &obj_pos[1] );
    trans_y->set_speed( .1 );
    new GLUI_Column( glui2, false );
    GLUI_Translation *trans_z =  new GLUI_Translation( glui2, "Objects Z", GLUI_TRANSLATION_Z, &obj_pos[2] );
    trans_z->set_speed( .1 );

	glui2->add_column(true);

	GLUI_Panel *render_panel = glui2->add_panel("Render");
	new GLUI_Checkbox(render_panel, "Wireframe", &wireframe);
	new GLUI_Checkbox(render_panel, "Filled", &filled);
	new GLUI_Checkbox(render_panel, "Grid", &grid);


	glui2->add_button("Quit", 0, (GLUI_Update_CB)exit);



	glui->set_main_gfx_window(main_window);
	/* We register the idle callback with GLUI, *not* with GLUT */
	GLUI_Master.set_glutIdleFunc(myGlutIdle);



	glutMainLoop();

	return EXIT_SUCCESS;
}
Esempio n. 28
0
int main(int argc, char* argv[])
{
  /****************************************/
  /*   Initialize GLUT and create window  */
  /****************************************/

  glutInit(&argc, argv);
  glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  glutInitWindowPosition( 50, 50 );
  glutInitWindowSize( 300, 300 );
 
  main_window = glutCreateWindow( "GLUI Example 2" );
  glutDisplayFunc( myGlutDisplay );
  glutReshapeFunc( myGlutReshape );  
  glutKeyboardFunc( myGlutKeyboard );
  glutMotionFunc( myGlutMotion );
  glutMouseFunc( myGlutMouse );

  /****************************************/
  /*       Set up 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);

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

  glEnable(GL_DEPTH_TEST);

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

  GLUI *glui = GLUI_Master.create_glui( "GLUI", 0, 400, 50 ); /* name, flags,
								 x, and y */
  new GLUI_StaticText( glui, "GLUI Example 2" );
  new GLUI_Separator( glui );
  checkbox = new GLUI_Checkbox( glui, "Wireframe", &wireframe, 1, control_cb );
  spinner  = new GLUI_Spinner( glui, "Segments:", &segments, 2, control_cb );
  spinner->set_int_limits( 3, 60 );
  edittext = new GLUI_EditText( glui, "Text:", text, 3, control_cb );
  GLUI_Panel *obj_panel = new GLUI_Panel( glui, "Object Type" );
  radio = new GLUI_RadioGroup( obj_panel,&obj,4,control_cb );
  new GLUI_RadioButton( radio, "Sphere" );
  new GLUI_RadioButton( radio, "Torus" );
  new GLUI_RadioButton( radio, "Teapot" );
  new GLUI_Button( glui, "Quit", 0,(GLUI_Update_CB)exit );
 
  glui->set_main_gfx_window( main_window );

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

  glutMainLoop();

  return EXIT_SUCCESS;
}