//! This function creates all the GLUI gui elements
void create_glui_ui(void)
{
  GLUI *glui = GLUI_Master.create_glui_subwindow( main_window, GLUI_SUBWINDOW_BOTTOM );
  
  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_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 );
  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 );
  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 );
}
//############################################ Menu window functions ###############################################
void init_menu()
{
	GLUI_Master.close_all();						// Closes the previous windows
	GLUI *glui = GLUI_Master.create_glui( "RMS v1.0");
	glui->add_column(true);							// Adds a column separator
  	glui->add_statictext("WELCOME!");
  	glui->add_separator();							// Adds horizontal separator
  	glui->add_button("NEW USER",SET_NEW_USER,(GLUI_Update_CB)switcher_function);	// Adds a button 
  	glui->add_separator();
  	glui->add_button("OLD USER",SET_OLD_USER, (GLUI_Update_CB)switcher_function);
  	glui->add_separator();
  	glui->add_button("Quit",ERROR_CHECK,(GLUI_Update_CB)exit);
  	glui->add_separator();
  	glui->add_column(true);
}
/**
The callback function for the buttons in the GLUI window.
@param  button the id of the button calling this callback function.
*/
void MyButtons(int button) {
	switch (button) {
	case(0) :
		Framework::instance()->setUpPointsAndVectors(); 
		Framework::instance()->spinVecMin = Framework::instance()->GetVectorMin();
		Framework::instance()->spinVecMax = Framework::instance()->GetVectorMax();
		break;
	case(1) : {
		printf("Entering Input\n");
		std::string input = Framework::instance()->VectorDefinerString;
		if ((int)strlen(Framework::instance()->VectorDefinerString) != 0) {
			if (PathFileExists(input.c_str()) || input.find("<", 0) != std::string::npos) {
				Framework::instance()->VectorInput = Framework::instance()->VectorDefinerString;
			}else {
				std::cout << "Either input existing file, or use the vector form <I(x,y,z),J(x,y,z),K(x,y,z)>"<<std::endl;
			}
		}
		input = Framework::instance()->SpaceDefinerString;
		if ((int)strlen(Framework::instance()->SpaceDefinerString) != 0 && input.find("<", 0) != std::string::npos) {
			Framework::instance()->SpaceInput = Framework::instance()->SpaceDefinerString;
		}
		else {
			std::cout << "Please use the vector form <I(x,y,z),J(x,y,z),K(x,y,z)>" << std::endl;
		}
		Framework::instance()->setUpPointsAndVectors();
		Framework::instance()->spinVecMin = Framework::instance()->GetVectorMin();
		Framework::instance()->spinVecMax = Framework::instance()->GetVectorMax();
		break;
	}
	case(2) :
		printf(".obj file saved");
		break;
	case(3) :
		GLUI* fileselectglui = GLUI_Master.create_glui("Select a File!");
		gluiFileBrowser = new GLUI_FileBrowser(fileselectglui, "File Selector",1,10, ((GLUI_Update_CB)GetFilePlease));
		fileselectglui->add_statictext("Select a CSV File");
		gluiFileBrowser->set_allow_change_dir(true);
		//Framework::instance()->VectorInput = (char*)gfb.get_file();
		//printf("%s\n", Framework::instance()->VectorInput);
		break;
	}
}
示例#4
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);


}
/**
 * @brief UI設定関数
 */
void setGlui(void)
{
  /* GLUIコントローラーの設定 */
  GLUI * glui = GLUI_Master.create_glui("Control Panel", 0);

  /* スリットサイズのテキストボックス追加 */
  GLUI_EditText * editSlitWidth = new GLUI_EditText(glui, "Slit width (cm)", &slitWidth, NULL, inputChangeSlitWidth);
  // 限界値とその処理
  //editSlitWidth->set_float_limits(0.0, 1.0, GLUI_LIMIT_CLAMP);
  // 初期値
  editSlitWidth->set_float_val(0.3);

  /* 移動スピードのテキストボックス追加 */
  GLUI_EditText * editSlitSpeed = new GLUI_EditText(glui, "Slit speed (cm)/s", &slitSpeed, NULL, inputChangeSlitSpeed);
  //editSlitSpeed->set_float_limits(0.0, 1.0, GLUI_LIMIT_CLAMP);
  editSlitSpeed->set_float_val(18000);

  // 仕切り線
  glui->add_separator();

  /* モード変更用のラジオボタン */
  // テキスト
  glui->add_statictext("Move select");
  GLUI_RadioGroup * mode_radio = new GLUI_RadioGroup(glui, &mode);
  // モード変更の項目設定
  glui->add_radiobutton_to_group(mode_radio, "Slit Move");
  glui->add_radiobutton_to_group(mode_radio, "Image Move");

  // 仕切り線
  glui->add_separator();

  // スリット色変え
  GLUI_RadioGroup * slit_mode_radio = new GLUI_RadioGroup(glui, &slitColor);
  glui->add_radiobutton_to_group(slit_mode_radio, "Black");
  glui->add_radiobutton_to_group(slit_mode_radio, "White");

  glui->add_separator();

  // 反復ボタン
  new GLUI_Checkbox(glui, "Repetition", &repetition);

  glui->add_separator();

  /* 画像変更のラジオボタン */
  glui->add_statictext("Image select");
  GLUI_RadioGroup * imageMode_radio = new GLUI_RadioGroup(glui, &ImageMode);
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Line drowing black");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Line drowing white");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - Black");
  glui->add_radiobutton_to_group(imageMode_radio, "Dromedary camel - White");

  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Line drowing black");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Line drowing white");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - Black");
  glui->add_radiobutton_to_group(imageMode_radio, "Bactrian camel - White");

  glui->add_radiobutton_to_group(imageMode_radio, "Momotaro");

  glui->add_radiobutton_to_group(imageMode_radio, "Circle");
  glui->add_radiobutton_to_group(imageMode_radio, "Square");
  glui->add_radiobutton_to_group(imageMode_radio, "triangle");

  // 仕切り線
  glui->add_separator();

  /* exitボタン */
  glui->add_button("Exit", 0, gluiCallBack);

  // idlezコールバック関数はGLUIで登録
  GLUI_Master.set_glutIdleFunc(NULL);
}
示例#6
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;
}