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

}
Example #2
0
void GameInterface::initGUI()
{
	int* option= &((XMLScene*) scene)->option;
	/*
	GLUI_Panel *varPanel1 = addPanel("Cameras", 1);
	int* camera = &((XMLScene*) scene)->camera;
	GLUI_Listbox *texturesListbox =addListboxToPanel(varPanel1,"Camera: ",camera,7);
	unsigned int size=((XMLScene*) scene)->file->sceneCameras.size();
	for(unsigned int i = 0;i<size;i++)
	{
	texturesListbox->add_item (i, ((XMLScene*) scene)->file->sceneCameras[i].first);
	}

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

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

}
Example #3
0
Graph::Graph()
{
	minFitness = 0.0f;
	glui = GLUI_Master.create_glui("Parameter Graph");

	GLUI_Button* close = glui->add_button("Close", 0, uiClose);
	close->user_id = (long)this;

//	glui->add_spinner("Min fitness", GLUI_SPINNER_FLOAT, &minFitness);

	GLUI_Panel *p = glui->add_panel("Graph");
	graphControl = new GraphControl();
	graphControl->owner=this;
	p->add_control(graphControl);

	mutex = SDL_CreateMutex();
}
Example #4
0
/* Resets curr_root and curr branch to TreePanel and lastChild */
void GLUI_TreePanel::resetToRoot(GLUI_Panel *new_root) 
{
  GLUI_Panel *root = this;
  if (new_root != NULL)
    root = new_root;
  curr_root = root;
  if (dynamic_cast<GLUI_Tree*>(curr_root))
    ((GLUI_Tree *)curr_root)->set_current(true);
  curr_branch = (GLUI_Tree *)root->first_child();

  /* since Trees are collapsable, we need to check the collapsed nodes
     in case the curr_root is collapsed */
  if (curr_branch == NULL && (root->collapsed_node).first_child() != NULL) {
    curr_branch = (GLUI_Tree *)(root->collapsed_node).first_child();
  }
  while (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch)) {
    curr_branch=(GLUI_Tree *)curr_branch->next();
  }
}
Example #5
0
GLUI_Panel     *GLUI::add_panel_to_panel( GLUI_Panel *parent_panel,
					  char *name, int type )
{
  GLUI_Panel *panel;
  
  panel = new GLUI_Panel;

  if ( panel ) {
    panel->set_name( name );
    panel->user_id    = -1;
    panel->int_val    = type;

    add_control( parent_panel, panel );

    return panel;
  }
  else {
    return NULL;
  }  
}
Example #6
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();
}
void initGLUI()
{
  // generate the UI

  glui = GLUI_Master.create_glui("Controls", 0, windowWidth + 10, 0);

  glui->add_spinner("Deformable object compliance:", GLUI_SPINNER_FLOAT, &deformableObjectCompliance, 0, deformableObjectCompliance_spinnerCallBack );

  glui->add_spinner("Frequency scaling:", GLUI_SPINNER_FLOAT, &frequencyScaling, 0, frequencyScaling_spinnerCallBack);

  // ******** newmark beta, gamma ********
  
  GLUI_Panel * newmark_panel =
    glui->add_panel("Newmark integrator parameters", GLUI_PANEL_EMBOSSED);
  newmark_panel->set_alignment(GLUI_ALIGN_LEFT);
  
  glui->add_checkbox_to_panel(newmark_panel, "Link Beta and Gamma", 
    &use1DNewmarkParameterFamily, 0, newmark_checkboxuse1DNewmarkParameterFamilyCallBack);

  GLUI_Spinner * newmarkBeta_spinner = 
    glui->add_spinner_to_panel(newmark_panel,"Beta", GLUI_SPINNER_FLOAT,
      &newmarkBeta, 0, newmarkBeta_spinnerCallBack);
  newmarkBeta_spinner->set_speed(0.1);

  GLUI_Spinner * newmarkGamma_spinner = 
    glui->add_spinner_to_panel(newmark_panel,"Gamma", GLUI_SPINNER_FLOAT,
      &newmarkGamma, 0, newmarkGamma_spinnerCallBack);
  newmarkGamma_spinner->set_speed(0.1);

    glui->add_checkbox_to_panel(newmark_panel,"Static solver only", &staticSolver, 0, staticSolver_checkboxCallBack);

  glui->add_checkbox_to_panel(newmark_panel, "Linear reduced model", &forceModel, 0, forceModel_checkBoxCallBack);

  // ******** damping ********

  GLUI_Panel * damping_panel =
    glui->add_panel("Tangential Rayleigh Damping", GLUI_PANEL_EMBOSSED);
  damping_panel->set_alignment(GLUI_ALIGN_LEFT);

  glui->add_spinner_to_panel(damping_panel,"Mass-proportional", GLUI_SPINNER_FLOAT,
      &dampingMassCoef, 0, rayleighMass_spinnerCallBack);

  glui->add_spinner_to_panel(damping_panel,"Stiffness-proportional", GLUI_SPINNER_FLOAT,
      &dampingStiffnessCoef, 0, rayleighStiffness_spinnerCallBack);

  glui->add_button("Stop deformations", 0, stopDeformations_buttonCallBack);

  // ******** timestep control ********

  GLUI_Panel * timeStep_panel =
    glui->add_panel("Timestep control", GLUI_PANEL_EMBOSSED);
  timeStep_panel->set_alignment(GLUI_ALIGN_LEFT);

  glui->add_checkbox_to_panel(timeStep_panel, "Sync with graphics", 
    &syncTimeStepWithGraphics, 0, syncTimeStepWithGraphics_checkboxCallBack);

  timeStep_spinner = 
    glui->add_spinner_to_panel(timeStep_panel,"Timestep [sec]", GLUI_SPINNER_FLOAT,
      &timeStep, 0, timeStep_spinnerCallBack);
  timeStep_spinner->set_alignment(GLUI_ALIGN_LEFT);

  if (syncTimeStepWithGraphics)
    timeStep_spinner->disable();

  glui->add_spinner_to_panel(timeStep_panel,"Substeps per timestep", GLUI_SPINNER_INT, &substepsPerTimeStep, 0, timeStepSubdivisions_spinnerCallBack);

  // ******* plastic deformations ********

  GLUI_Panel * plasticDeformationsPanel = glui->add_panel("Plastic deformations", GLUI_PANEL_EMBOSSED);
  plasticDeformationsPanel->set_alignment(GLUI_ALIGN_LEFT);
  glui->add_checkbox_to_panel(plasticDeformationsPanel, "Enable", &plasticDeformationsEnabled, 0, plasticDeformationsEnabled_checkboxCallBack);
  glui->add_column_to_panel(plasticDeformationsPanel, 0);
  glui->add_spinner_to_panel(plasticDeformationsPanel, "Threshold:", GLUI_SPINNER_FLOAT, &plasticThreshold, 0, plasticDeformationsEnabled_checkboxCallBack);

  // *** u = Uq ***

  renderOnGPU_checkbox = glui->add_checkbox("Compute u=Uq on GPU", &renderOnGPU, 0, renderOnGPU_checkBoxCallBack);

  glui->add_separator();

  GLUI_Panel * instructions_panel = glui->add_panel("Mouse buttons:", GLUI_PANEL_EMBOSSED);
  instructions_panel->set_alignment(GLUI_ALIGN_LEFT);
  glui->add_statictext_to_panel(instructions_panel, "Left + drag: apply force");
  glui->add_statictext_to_panel(instructions_panel, "Middle + drag: zoom in/out");
  glui->add_statictext_to_panel(instructions_panel, "Right + drag: rotate camera");
 
  glui->add_separator();

  glui->add_statictext("Jernej Barbic and Doug James");
  glui->add_statictext("Carnegie Mellon University, Cornell, 2007");

  glui->add_separator();

  glui->add_button("Exit program", 0, exit_buttonCallBack);

  Sync_GLUI();

  glui->set_main_gfx_window( windowID );
}
Example #8
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();
}