Exemplo n.º 1
0
void DemoWindow::initTWBar()
{
	glutCreateMenu(NULL);
	// Initialize AntTweakBar
    TwInit(TW_OPENGL, NULL);

	//// Set GLUT event callbacks
 //   // - Directly redirect GLUT mouse button events to AntTweakBar
 //   glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
 //   // - Directly redirect GLUT mouse motion events to AntTweakBar
 //   glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
 //   // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
 //   glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
 //   // - Directly redirect GLUT key events to AntTweakBar
 //   glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
 //   // - Directly redirect GLUT special key events to AntTweakBar
 //   glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT);
    // - Send 'glutGetModifers' function pointer to AntTweakBar;
    //   required because the GLUT key event functions do not report key modifiers states.
    TwGLUTModifiersFunc(glutGetModifiers);
	bar = TwNewBar("TweakBar");
	TwWindowSize(100, 100);
    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar.
    TwDefine(" TweakBar size='200 400' color='96 216 224' "); // change default tweak bar size and color

}
Exemplo n.º 2
0
ModelLightingClass::ModelLightingClass(string barName, bool p_quad, const XMFLOAT3 & postion):Entity(),
	Position(postion), Rotation(0.0f, 0.0f, 0.0f), Scale(1.0f, 1.0f, 1.0f), Quaternion(XMQuaternionIdentity())
{
	m_vertexBuffer = 0;
	m_indexBuffer = 0;
	m_model = 0;


	m_bar = TwNewBar(barName.c_str());

	string define = barName + " iconified=true  alpha=200";
	string group = barName + "/Rotation opened = false";
	TwDefine(define.c_str());

	TwAddVarRW(m_bar, "XRotation", TW_TYPE_FLOAT, &Rotation.x, " step=0.01 group=Rotation");
	TwAddVarRW(m_bar, "YRotation", TW_TYPE_FLOAT, &Rotation.y, " step=0.01 group=Rotation");
	TwAddVarRW(m_bar, "ZRotation", TW_TYPE_FLOAT, &Rotation.z, "min=0 max=6.28 step=0.01 group=Rotation");
	TwDefine(group.c_str());

	TwAddVarRW(m_bar, "XPosition", TW_TYPE_FLOAT, &Position.x, "  step=0.1 group=Position");
	TwAddVarRW(m_bar, "YPosition", TW_TYPE_FLOAT, &Position.y, "  step=0.1 group=Position");
	TwAddVarRW(m_bar, "ZPosition", TW_TYPE_FLOAT, &Position.z, "  step=0.1 group=Position");
	group = barName + "/Position opened = false";
	TwDefine(group.c_str());

	TwAddVarRW(m_bar, "XScale", TW_TYPE_FLOAT, &Scale.x, "  step=0.01 group=Scale");
	TwAddVarRW(m_bar, "YScale", TW_TYPE_FLOAT, &Scale.y, "  step=0.01 group=Scale");
	TwAddVarRW(m_bar, "ZScale", TW_TYPE_FLOAT, &Scale.z, "  step=0.01 group=Scale");
	group = barName + "/Scale opened = false";
	TwDefine(group.c_str());
}
Exemplo n.º 3
0
void KinectUser::showParams( bool show )
{
	if( show )
		TwDefine( "Kinect visible=true" );
	else
		TwDefine( "Kinect visible=false" );
}
Exemplo n.º 4
0
void AntTweakBarWrapper::Init()
{
	TwInit(TW_OPENGL, NULL);
	m_control_panel_bar = TwNewBar("Control Panel");
	//TwDefine(" 'Control Panel' size='200 210' position='114 10' color='255 255 255' text=dark ");
	char control_bar_pos_string [255];
    sprintf(control_bar_pos_string, "'Control Panel' position='%d 10' color='255 255 0' ", DEFAULT_SCREEN_WIDTH-210);
    TwDefine(control_bar_pos_string);

	TwAddVarRW(m_control_panel_bar, "Start Simulation", TwType(sizeof(bool)), &(g_start_simulation), " label='Start Simulation' key=s group='Debug Information' help='Toggle simulation mode.'");
	TwAddVarRW(m_control_panel_bar, "Render FP", TwType(sizeof(bool)), &(g_show_render), " label='Render FP' key=w group='Debug Information' help='Toggle render display mode.'");
	TwAddVarRW(m_control_panel_bar, "Wireframe", TwType(sizeof(bool)), &(g_show_wireframe), " label='Wireframe mode' key=w group='Debug Information' help='Toggle wireframe display mode.'");
	TwAddVarRW(m_control_panel_bar, "Edge List", TwType(sizeof(bool)), &(g_show_edgelist), " label='Edgelist mode'  group='Debug Information' help='Toggle edgelist display mode.'");
	TwAddVarRW(m_control_panel_bar, "Line Width", TW_TYPE_FLOAT, &(g_linewidth),"label='Line Width' min=0 max=100 step=0.05  help='line width' group='Debug Information'");
	TwAddVarRW(m_control_panel_bar, "Fixed Vertex", TwType(sizeof(bool)), &(g_show_fixedvertex), " label='Fixed Vertex' key=w group='Debug Information' help='Toggle fixed vertex mode.'");
	TwAddVarRW(m_control_panel_bar, "Point Size", TW_TYPE_FLOAT, &(g_pointsize),"label='Point Size' min=0 max=100 step=0.05  help='Point Size' group='Debug Information'");

	TwAddVarRW(m_control_panel_bar, "Zoom", TW_TYPE_FLOAT, &(cameraDistance),"label='Zoom Mode' min=-30 max=30 step=0.1 keyIncr=z keyDecr=Z help='zoom camera' group='Camera'");

	m_sim_bar = TwNewBar("Simulation Control");
	TwDefine("'Simulation Control' position='0 0' color='255 0 0'");

	TwEnumVal shapeEV[NUM_SIMULATION] = { {PositionBasedDynamic, "Position Based Dynamic"}, {MassSpring, "Mass Spring"}, {FiniteElement, "Finite Element"}, {FastMassSpring, "Fast Mass Spring"}, {ProjectiveDynamic, "Projective Dynamic"} };
    TwType simmethod = TwDefineEnum("simmethod", shapeEV, NUM_SIMULATION);
	TwAddVarRW(m_sim_bar, "Simulation Method", simmethod, &g_CurrentMethod, " keyIncr='<' keyDecr='>' help='Change Simulation Method.' ");
}
Exemplo n.º 5
0
SceneDialog::SceneDialog()
{
	// Create a tweak bar
    m_dialog = TwNewBar("Scene");
    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar into a DirectX11 application.' "); // Message added to the help bar.
	int barSize[2] = {200, 1060};
    TwSetParam(m_dialog, NULL, "size", TW_PARAM_INT32, 2, barSize);
	TwDefine(" Scene position='10 10' ");

	TwAddButton(m_dialog, "Load Scene", LoadAGL, this, " label='Load Scene' key=c help='Load an Agile file into the editor.' group='I/O'");
	TwAddButton(m_dialog, "Save Scene", SaveAGL, this, " label='Save Scene' key=c help='Save a scene into an Agile file.' group='I/O'");

	TwAddVarRW(m_dialog, "Rotation", TW_TYPE_QUAT4F, Scene::GetInstance()->GetQuaternionRotation(), "opened=true axisz=-z");

	TwStructMember pointMembers[] = { 
        { "X", TW_TYPE_FLOAT, offsetof(AglVector3, x), " Step=0.01 " },
        { "Y", TW_TYPE_FLOAT, offsetof(AglVector3, y), " Step=0.01 " },
		{ "Z", TW_TYPE_FLOAT, offsetof(AglVector3, z), " Step=0.01 " }};
    TwType pointType = TwDefineStruct("POINT", pointMembers, 3, sizeof(AglVector3), NULL, NULL);

	TwAddVarRW(m_dialog, "Position", pointType, Scene::GetInstance()->GetPosition(), "");

	TwAddVarRW(m_dialog, "ShowHideDiffuse", TW_TYPE_BOOLCPP, &DIFFUSEON, "group='Show/Hide'");
	TwAddVarRW(m_dialog, "ShowHideSpec", TW_TYPE_BOOLCPP, &SPECULARON, "group='Show/Hide'");
	TwAddVarRW(m_dialog, "ShowHideGlow", TW_TYPE_BOOLCPP, &GLOWON, "group='Show/Hide'");
	TwAddVarRW(m_dialog, "ShowHideNormal", TW_TYPE_BOOLCPP, &NORMALON, "group='Show/Hide'");

	m_meshDialog = new MeshDialog();
	m_materialDialog = new MaterialDialog();
	m_particleSystemDialog = new ParticleSystemDialog();
	m_mergeDialog = new MergeDialog();
}
static void setupAntTweakBar()
{
	g_bar = TwNewBar("TweakBar");
	TwDefine(" TweakBar size='320 640' "); // resize bar
	TwDefine(" GLOBAL help='Simulation control.' "); // Message added to the help bar.
	
	/*TwAddVarRW(g_bar, "TD", TW_TYPE_FLOAT, &var_TIME_DELTA,
		" label='Time delta' precision=5 min=0 max=1 step=0.01 ");*/
	
	TwAddVarRW(g_bar, "FPS", TW_TYPE_DOUBLE, &g_twVar.info_fps,
		" group=INFO label='Frame rate:' precision=1 ");

	TwAddSeparator(g_bar, "SEP0", 0);

	/*TwAddVarRW(g_bar, "ANIMATION_SPEED", TW_TYPE_FLOAT, &var_ANIMATION_SPEED,
	" group=ANIMATION label='Speed' precision=1 min=0 max=10 step=0.1 ");*/

	TwAddVarRW(g_bar, "GRAVITY", TW_TYPE_FLOAT, &g_twVar.sim_gravity,
		" group=SIMULATION label='Gravity' precision=10 min=-1 max=1 step=0.0001 ");
	
	TwAddVarRW(g_bar, "SIMULATE", TW_TYPE_BOOL8, &g_twVar.sim_enable,
		" group=SIMULATION label='Run simulation' ");

	TwAddButton(g_bar, "SIMULATION_STEP", [](void*) { g_twVar.sim_step = true; }, NULL,
		" group=SIMULATION  label='Step simulation' key=N ");

	TwAddButton(g_bar, "SIMULATION_RESET", [](void*) { g_ball->reset(false); s_model->resetAnimation(); }, NULL,
		" group=SIMULATION  label='Reset' ");

	TwAddSeparator(g_bar, "SEP1", 0);

	TwAddVarRW(g_bar, "BLEND_VERT_STIFF", TW_TYPE_BOOL8, &g_twVar.blend_useWeights,
		" group=BLEND label='Use skin weights' ");
	TwAddVarRW(g_bar, "BLEND_STIFF_MULT", TW_TYPE_FLOAT, &g_twVar.blend_multiplier,
		" group=BLEND label='Multiplier' precision=4 min=0 max=1 step=0.0001 ");

	TwAddVarRW(g_bar, "BLEND_CONST_STIFF", TW_TYPE_FLOAT, &g_twVar.constraint_stiffness,
		" group=BLEND label='Stiffness k' precision=4 min=0 max=1 step=0.0001 ");

	TwAddSeparator(g_bar, "SEP2", 0);

	TwAddVarRW(g_bar, "RENDER_FILL", TW_TYPE_BOOL8, &g_twVar.render_fill,
		" group=RENDER label='Fill' ");
	TwAddVarRW(g_bar, "RENDER_WIREFRAME", TW_TYPE_BOOL8, &g_twVar.render_wireframe,
		" group=RENDER label='Wireframe' ");
	TwAddVarRW(g_bar, "RENDER_DISTMAG", TW_TYPE_BOOL8, &g_twVar.render_distMag,
		" group=RENDER label='Distortion magnitude' ");

	TwAddVarRW(g_bar, "rec_record", TW_TYPE_BOOL8, ffmpegRec(),
		" group=RECORD label='Record' ");

	TwAddSeparator(g_bar, "SEP3", 0);

	TwAddButton(g_bar, "BALL_RESET", [](void*) { g_ball->reset(); }, NULL, " label='Throw ball' ");
	
}
Exemplo n.º 7
0
void CreateBar()
{
	TwBar *waspskeletonBar = TwNewBar("WaspSkeletonBar");
	
	TwDefine(" GLOBAL help='This is to rotate a single bone.' ");
	TwDefine(" WaspSkeletonBar size='200 400' color='96 216 224' ");
	
	CreateBarLabels(waspskeletonBar, skeletonWasp);
	
}
Exemplo n.º 8
0
void outPut::init_Bars()
{
    b_scene = TwNewBar("Scene");
    _scene3d.distance = _dimensions.x+_dimensions.y;
    _scene3d.zoom = 60;
    _scene3d.focus = coords3d<float>::retournercoords3d(_dimensions.x/2,_dimensions.y/2,0);
    //_scene3d.orientation = {0, 0, 0, 1}; // direction pointing to +x and +y
    _scene3d.orientation[0]=_scene3d.orientation[1]=_scene3d.orientation[2]=0;
    _scene3d.orientation[3]=1;
    TwAddVarRW(b_scene, "Orientation", TW_TYPE_QUAT4F, &(_scene3d.orientation),"axisx=x axisy=y axisz=z");
    TwAddVarRW(b_scene, "Distance", TW_TYPE_DOUBLE, &(_scene3d.distance),"");
    TwAddVarRW(b_scene, "Zoom", TW_TYPE_DOUBLE, &(_scene3d.zoom),"min = 5 max = 200");
    TwAddVarRW(b_scene, "x", TW_TYPE_FLOAT, &(_scene3d.focus.x), "group = 'Focus' ");
    TwAddVarRW(b_scene, "y", TW_TYPE_FLOAT, &(_scene3d.focus.y), "group = 'Focus' ");
    TwAddVarRW(b_scene, "z", TW_TYPE_FLOAT, &(_scene3d.focus.z), "group = 'Focus'");
    TwAddButton(b_scene, "Centrer", cbCenterView, this, " group = 'Focus' ");
    TwAddVarRW(b_scene, "Test de profondeur résultat", TW_TYPE_BOOLCPP,
               &(_reg.ZTEST_RESULT), "label='Z test resultat'");

    TwAddVarRW(b_scene, "Temps de calcul (ms)", TW_TYPE_INT32, &(_status.drawDelay), "min=0 max=1000");

    //_scene3d.lightDir = {1,1,-1};
    _scene3d.lightDir[0]=_scene3d.lightDir[1]=1;
    _scene3d.lightDir[2]=-1;
    //_scene3d.lightPos = {-1,-1,1,0};
    _scene3d.lightPos[0]=_scene3d.lightPos[1]=-1;
    _scene3d.lightPos[2]=1;
    _scene3d.lightPos[3]=0;
    TwAddVarRW(b_scene, "Direction", TW_TYPE_DIR3F, &(_scene3d.lightDir), "group = Lumiere" );
    TwAddVarRW(b_scene, "Directionnelle", TW_TYPE_FLOAT, &(_scene3d.lightPos[3]), "group = Lumiere min=0 max =1" );

    b_reglages = TwNewBar("Reglages");
    TwAddVarRO(b_reglages, "MAX_FPS", TW_TYPE_INT32, &(_reg.MAX_FPS), "group='Window settings'");
    TwAddButton(b_reglages, "Recalculer", recalculate, this, " group = Rendu ");
    TwAddVarRW(b_reglages, "Multiplicateur", TW_TYPE_DOUBLE, &(_reg.MULTIPLIER), "group = 'Rendu' min = 0 max = 100");
    TwType colorsType;
    colorsType = TwDefineEnum("ColorsType", NULL, 0);
    //TwAddVarRW(b_reglages, "Couleurs", colorsType, &(_reg.COLORS), " enum='0 {Réelles}, 1 {Colorisé}, 2 {Uniforme}'");
    TwAddVarRW(b_reglages, "Filaire", TW_TYPE_BOOLCPP, &(_reg.WIREFRAME), " group = Rendu ");
    TwAddVarRW(b_reglages, "Normales", TW_TYPE_BOOLCPP, &(_reg.DRAW_NORMALS), "group = 'Rendu'");
    TwAddVarRW(b_reglages, "Couleur unie", TW_TYPE_COLOR3F, &(_reg.UNIFORM_COLOR), "colormode=hls group = 'Rendu'");
    b_postprocess = TwNewBar("Post-processing");
    _effect = 0;
    TwAddVarRW(b_postprocess, "Effet", TW_TYPE_INT32, &(_effect),"max=20 keyincr = p keydecr = m");

    b_pathfind = TwNewBar("Pathfind");
    TwAddVarRW(b_pathfind, "En cours", TW_TYPE_BOOLCPP, &(_status.running), "help='Fermer le programme' key=ESC");
    TwAddVarRW(b_pathfind, "Pause", TW_TYPE_BOOLCPP, &(_status.pause), "key=t");

    TwSetTopBar(b_scene);
    TwDefine(" Reglages iconified=true ");
    TwDefine(" Pathfind iconified=true ");
    TwDefine(" Post-processing iconified=true ");
}
Exemplo n.º 9
0
void IntroOpenGl::CreateGui()
{
    m_bar = TwNewBar("IntroToOpenGL");

    TwDefine(" IntroToOpenGL position='10 10' "); // move bar to position (10, 10)
    TwDefine(" IntroToOpenGL size='430 320' "); // resize bar
    TwDefine(" IntroToOpenGL color='128 128 128' alpha=32 ");   // semi-transparent blue bar
    TwDefine(" IntroToOpenGL resizable=false "); // mybar cannot be resized


    TwAddButton(m_bar, "label_01", NULL, NULL, "label='simply opengl scene, nothing much happening'"); //show as label
    TwAddButton(m_bar, "mainMenu", Callback, this, "label='main menu'"); //show as button
}
Exemplo n.º 10
0
void APP_SpotRotate::CreateGui()
{
    m_bar = TwNewBar("SpotRotate");

    TwDefine(" SpotRotate position='10 10' "); // move bar to position (10, 10)
    TwDefine(" SpotRotate size='430 320' "); // resize bar
    TwDefine(" SpotRotate color='128 128 128' alpha=32 ");   // semi-transparent blue bar
    TwDefine(" SpotRotate resizable=false "); // mybar cannot be resized


    TwAddButton(m_bar, "label_01", NULL, NULL, "label='proof of concept for bill borded sprites with rotation'"); //show as label
    TwAddButton(m_bar, "mainMenu", Callback, this, "label='main menu'"); //show as button
}
Exemplo n.º 11
0
int createTweakBar(context_t *ctx, int scene) {
  const char me[]="createTweakBar";
  char buff[128];
  int EE;  /* we have an error */

  EE = 0;

  // NOTE: these are nice to have
  twBumpMappingModes=TwDefineEnum("BumpMappingModes", twBumpMappingModesEV, 3);
  twFilteringModes=TwDefineEnum("FilteringModes", twFilteringModesEV, 4);
  twObjects=TwDefineEnum("Objects", twObjectsEV, 10);
  twCubeMaps=TwDefineEnum("CubeMap", twCubeMapsEV, 3);
  twShaders=TwDefineEnum("Shader", twShadersEV, 3);
  
  /* Create a tweak bar for interactive parameter adjustment */
  if (!EE) EE |= !(ctx->tbar = TwNewBar(TBAR_NAME));
  /* documentation for the TwDefine parameter strings here:
     http://www.antisphere.com/Wiki/tools:anttweakbar:twbarparamsyntax */
  /* add a message to be seen in the "help" window */
  if (!EE) EE |= !TwDefine(" GLOBAL help='This description of Project 2 "
                           "has not been changed by anyone but students "
                           "are encouraged to write something descriptive "
                           "here.' ");
  /* change location where bar will be drawn, over to the right some
     to expose more of the left edge of window.  Note that we are
     exploiting the automatic compile-time concatentation of strings
     in C, which connects TBAR_NAME with the rest of the string to
     make one contiguous string */
  sprintf(buff, TBAR_NAME " position='%d %d' ",
          ctx->winSizeX - ctx->tbarSizeX - ctx->tbarMargin,
          ctx->tbarMargin);
  if (!EE) EE |= !TwDefine(buff);
  /* adjust other aspects of the bar */
  sprintf(buff, TBAR_NAME " color='0 0 0' alpha=10 size='%d %d' ",
          ctx->tbarSizeX, ctx->tbarSizeY);
  if (!EE) EE |= !TwDefine(buff);
  
  // NOTE: we broke this section out for easy update of tweak bar vars per-scene
  if (!EE) EE |= updateTweakBarVars(scene);

  /* see also:
     http://www.antisphere.com/Wiki/tools:anttweakbar:twtype
     http://www.antisphere.com/Wiki/tools:anttweakbar:twdefineenum
  */

  if (EE) {
    spotErrorAdd("%s: AntTweakBar initialization failed:\n\t%s", me, TwGetLastError());
    return 1;
  }
  return 0;
}
Exemplo n.º 12
0
void AddLight (void)
{
	Light light;
	light.position = glm::vec4 (0, 10, 0, 0);
	light.color = glm::vec4 (1, 1, 1, 1);
	light.direction = glm::vec4 (0, -1, 0, 0);
	light.spot.exponent = 2.0f;
	light.spot.angle = PCH_PI/4.0f;
	light.spot.cosine = cosf (light.spot.angle);
	light.spot.tangent = tanf (light.spot.angle);
	light.spot.penumbra_angle = light.spot.angle * 0.8f;
	light.spot.penumbra_cosine = cosf (light.spot.penumbra_angle);
	light.specular.color = glm::vec3 (1, 1, 1);
	light.attenuation = glm::vec4 (0.0f, 0.0f, 0.007f, 50.0f);
	light.CalculateFrustum ();
	r->AddLight (light);

	std::ostringstream stream;
	stream << "lights/active visible=true min=0 max=" << r->GetNumLights () - 1;
	TwDefine (stream.str ().c_str ());
	if (r->GetNumLights () == 1)
	{
		TwDefine ("lights/position visible=true");
		TwDefine ("lights/direction visible=true");
		TwDefine ("lights/color visible=true");
		TwDefine ("lights/spot visible=true");
		TwDefine ("lights/attenuation visible=true");
		TwDefine ("lights/specular visible=true");
		TwDefine ("lights/remove visible=true");
	}
}
void AudioBehaviour::setBar () {
	
	bar.init ("Configuration", 255, 510, 200, 200, 200, 100);
	bar.enable ();
	
	TwDefine (" Configuration valueswidth=80 ");
	//TwDefine (" Configuration position='750 310' ");

	// general settings
	bar.addParam ("black", &fade2black, " group='General Settings' label='Fade to black' help='general fade to black' min=0.01 max=0.99 step=0.01 ", false);
	bar.addSeparator ("separator1");
	bar.addParam ("blacktype", &fade2blackType, " group='General Settings' label='Fade to black mode' help='selects RGB or HSV fade to black type' true='HSV' false='RGB' ", false);
	bar.addSeparator ("separator1");
	
	nameStr = new char [10];
	optionStr = new char [170];

	for (int i=0; i<NUM_POINTS; i++) {
	
		SphericPointConfig& _config = sphericPoints[i]->config;

		setBarParam (i, "enable", "Point Enabled", "enable and disable point", _config.enabled);
		setBarParam (i, "audio", "Audio Enabled", "enable and disable audio input", _config.audio_enabled);
		setBarParam (i, "gain", "Gain", "input gain", -5.0, 5.0, 0.01, _config.gain);
		setBarParam (i, "filter", "Filter", "input low pass filter", 0.01, 0.99, 0.01, _config.filter);
		setBarParam (i, "huemin", "HUE min.", "minimum HUE value", -180, 360, 1, _config.hue_min);
		setBarParam (i, "huemax", "HUE max.", "maximum HUE value", 0, 540, 1, _config.hue_max);
		setBarParam (i, "decayh", "Dist. decay HUE", "amount of color change due to distance", -5.0, 5.0, 0.01, _config.distDecayH);
	    setBarParam (i, "decays", "Dist. decay Sat.", "amount of saturation change due to distance", -5.0, 5.0, 0.01, _config.distDecayS);
	    setBarParam (i, "decayv", "Dist. decay Value", "amount of bright change due to distance (size)", -5.0, 5.0, 0.01, _config.distDecayV);
	    setBarParam (i, "blend", "Blend", "blend factor for this point", 0.01, 1.0, 0.01, _config.blendFactor);
	    setBarParam (i, "movstep", "Movement Speed", "actually a step value for the noise signal which controls the position", 0.0, 0.1, 0.0001, _config.movNoiseStep);
	    setBarParam (i, "huestep", "Color change Speed ", "actually a step value for the noise signal which controls HUE", 0.0, 0.1, 0.0001, _config.hueNoiseStep);
		setBarParam (i, "sat", "Saturation", "saturation of the point", 0.0, 1.0, 0.01, sphericPoints[i]->color.S);
		
		// add separator
		sprintf (nameStr, "%i", i);
		bar.addSeparator (nameStr);
		
		// set group closed (all but first)
 		if (i==0) {continue;} 
 		sprintf (optionStr, " Configuration/'Spheric Point / Band %i' opened=false ", i);
		TwDefine (optionStr);
	
	}

	delete nameStr, optionStr;
	
}
Exemplo n.º 14
0
void TweakDemEditor::updateBar(TwBar *bar)
{
    EditorHandler *e = dynamic_cast<EditorHandler*>(eventHandler.get());
    if (e == NULL) {
        return;
    }

    // Adding the list of edited graphs
    TwEnumVal *editModes= new TwEnumVal[2];
    editModes[0].Value = ADD;
    editModes[0].Label = "ADD";
    editModes[1].Value = MAX;
    editModes[1].Label = "MAX";

    TwType editType = TwDefineEnum("EditType", editModes, 2);
    TwAddVarCB(bar, "EditMode", editType, SetDemEditModeCallback, GetDemEditModeCallback, NULL, " label='Edit Mode' group='DemEditor' key='e' ");

    TwAddVarRW(bar, "demBrushRadius", TW_TYPE_FLOAT, &(e->relativeRadius), " group=DemEditor label='Brush Radius' help='Size of the Dem Editor Brush' min=0.0 step=0.01 ");
    TwAddVarRW(bar, "demBrushColor", TW_TYPE_FLOAT, &(e->brushColor[0]), " group=DemEditor label='Brush altitude' help='Altitude applied to the texture' step='0.1' ");
    TwAddButton(bar, "demReset", ResetDemCB, NULL, " group=DemEditor label='Reset' help='Cancels all editing operations performed on active editors' ");
    char def[200];
    sprintf(def, "%s/DemEditor label='Dem Edition'", TwGetBarName(bar));
        char name[20];
    TwDefine(def);

    set<string> groupNames;
    for (int i = 0; i < e->getEditorCount(); i++) {
        string n = e->getEditor(i)->getGroup();
        if (groupNames.find(n) == groupNames.end()) {
            groupNames.insert(n);
            sprintf(name, "demEditorGroup%d", i);
            sprintf(def, " group=%s label='Activate %s' help='Activate or Deactivate the selected Editor' ", n.c_str(), n.c_str());
            TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetDemEditorGroupStateCallback, GetDemEditorGroupStateCallback, e->getEditor(i), def);

            sprintf(def, " group=%s ", n.c_str());
            TwAddSeparator(bar, NULL, def);

            sprintf(def, "%s/%s label='%s' group=DemEditor ", TwGetBarName(bar), n.c_str(), n.c_str());
            TwDefine(def);
        }
    }

    for (int i = 0; i < e->getEditorCount(); i++) {
        sprintf(name, "DemEditor%d", i);
        sprintf(def, " group=%s label='%s' help='Activate or Deactivate the selected Editor' ", e->getEditor(i)->getName().c_str(), e->getEditor(i)->getName().c_str());
        TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetDemEditorStateCallback, GetDemEditorStateCallback, e->getEditor(i), def);
    }
    delete[] editModes;
}
Exemplo n.º 15
0
void toolBoxSetup()
{
    TwBar *bar = TwNewBar("Info & Options");
    TwDefine(" GLOBAL help='PRT Simple Example' ");
    TwDefine(" 'Info & Options' size='200 200' color='96 216 224' ");

    TwAddSeparator(bar, "cam separator", "group='Camera'");

    TwAddVarRW(bar, "Speed", TW_TYPE_FLOAT, &camSpeed, "group='Camera'");
    TwAddVarRW(bar, "PosX", TW_TYPE_FLOAT, &g_Camera->m_Position.x, "group='Camera'");
    TwAddVarRW(bar, "PosY", TW_TYPE_FLOAT, &g_Camera->m_Position.y, "group='Camera'");
    TwAddVarRW(bar, "PosZ", TW_TYPE_FLOAT, &g_Camera->m_Position.z, "group='Camera'");
    TwAddVarRW(bar, "Pitch", TW_TYPE_FLOAT, &g_Camera->m_PitchDegrees, "group='Camera'");
    TwAddVarRW(bar, "Heading", TW_TYPE_FLOAT, &g_Camera->m_HeadingDegrees, "group='Camera'");
}
Exemplo n.º 16
0
// Callback function to create a bar with a given title
void TW_CALL CreateBarCB(void *clientData)
{
    const std::string *title = (const std::string *)(clientData);

    // Create a unique bar name
    int barIndex = (int)g_BarTitles.size();
    std::stringstream name;
    name << "bar_" << barIndex;

    g_BarTitles.push_back(*title);

    // Create bar
    TwBar *bar = TwNewBar(name.str().c_str());
    TwAddButton(bar, "Info", NULL, NULL, " label='std::string variable:' ");

    // Set bar label (ie. the title)
    std::stringstream def;
    def << name.str() << " label=`" << *title << "` ";
    TwDefine(def.str().c_str());

    // Cast barNum as void* to use it as clientData 
    // (doing so it could be directly sent through the get/set callbacks)
    void *barIndexAsVoidPtr = *(void **)&barIndex;

    // Add a std::string variable to the bar to edit its title,
    // The variable will be accessed through callbacks
    TwAddVarCB(bar, "EditTitle", TW_TYPE_STDSTRING, SetBarTitleCB, GetBarTitleCB, barIndexAsVoidPtr, 
               " label='Edit bar title' help='Edit this string to change the tweak bar title.' ");
}
Exemplo n.º 17
0
BezierSceneObject::BezierSceneObject(string name, bool quad, const XMFLOAT3 & pos, ID3D11Device* device,  HWND hwnd)
{
	m_model = new ModelLightingClass(name, quad, pos);
	m_quadInvoker = new QuadInvoker;
	m_dataStruct = new BasePartition::clientDataStruct;

	m_model->BuildQuadPatch( device);
	updateIncrement = 0.0f;
	m_model->SetScale(XMFLOAT3(0.1f, 0.5f, 0.5f));

	m_quadInvoker->InitializeVertexShader(device, hwnd, L"../Engine/BézierVS.hlsl", "BezierVertexShader", false);
	m_quadInvoker->InitializeShaderProgram(device, hwnd, L"../Engine/BézierHS.hlsl", "BezierHullShader","hs_5_0");
	m_quadInvoker->InitializeShaderProgram(device, hwnd, L"../Engine/BézierDS.hlsl", "BezierDomainShader","ds_5_0");
	m_quadInvoker->InitializeShaderProgram(device, hwnd, L"../Engine/BézierPS.hlsl", "BezierPixelShader","ps_5_0");
	m_quadInvoker->InitializeCBuffer(device, "matrixBuffer", sizeof(QuadInvoker::MatrixBufferType));
	m_quadInvoker->InitializeCBuffer(device, "tessBuffer", sizeof(QuadInvoker::TessellationBufferType));
	m_quadInvoker->InitializeCBuffer(device, "LightBuffer", sizeof(QuadInvoker::LightBufferType));
	m_quadInvoker->InitializeSampler(device, "heightSampler");

	m_model->AddModelTweakVar(20.0f , "TessFactor", " step=0.01 group=Bézier");
	m_model->AddModelTweakVar(8.0f , "AmpIncrement", " step=0.01 group=Bézier");
	m_model->AddModelTweakVar(1.0f , "timeMod", " step=0.001 group=Bézier");
	m_model->AddModel3FloatTweakVar(XMFLOAT3(-15.0f, 0.0f, 15.0f), "modifier1", "step=0.01 group=BézierControlGroup1");
	string tempName = name + "/BézierControlGroup1 group=Bézier opened=false";
	TwDefine(tempName.c_str());

	m_dataStruct->m_dev = device;
	m_dataStruct->m_h = hwnd;
	m_dataStruct->m_q = m_quadInvoker;

	TwAddButton(m_model->getBar() ,"FractionalEven", &BezierSceneObject::FractionalEven, m_dataStruct, "" );
	TwAddButton(m_model->getBar() ,"FractionalOdd", &BezierSceneObject::FractionalOdd, m_dataStruct, "" );
	TwAddButton(m_model->getBar() ,"FractionalInt", &BezierSceneObject::Integer, m_dataStruct, "" );

}
Exemplo n.º 18
0
Gui::Gui(Scene& scene,
         Game& game,
         Camera& camera,
         Input& input,
         Timer& timer) :
    m_game(game),
    m_camera(camera),
    m_scene(scene),
    m_timer(timer)
{
    TwInit(TW_OPENGL_CORE, nullptr);
    TwWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);

    const std::string barname = "GraphicsTweaker";
    m_tweakbar = TwNewBar(barname.c_str());
    m_tweaker = std::make_unique<Tweaker>(m_tweakbar);
    
    const int border = 10;
    std::ostringstream stream;
    stream << barname << " label='Graphics Tweaker' " 
        << "position='" << border << " " << border << "' "
        << "size='250 " << WINDOW_HEIGHT-border*2 << "' "
        << "alpha=180 text=light valueswidth=80 color='0 0 0' "
        << "refresh=0.05 iconified=false resizable=true "
        << "fontsize=2 fontresizable=false ";
    TwDefine(stream.str().c_str());

    FillTweakBar();

    auto AddKeyCallback = [&input](unsigned int key, unsigned int code)
    {
        input.AddCallback(key, false, [code]()
        { 
            TwKeyPressed(code, 0);
        });
    };

    // Keys required for modifying entries in the tweak bar
    AddKeyCallback(GLFW_KEY_0, '0');
    AddKeyCallback(GLFW_KEY_1, '1');
    AddKeyCallback(GLFW_KEY_2, '2');
    AddKeyCallback(GLFW_KEY_3, '3');
    AddKeyCallback(GLFW_KEY_4, '4');
    AddKeyCallback(GLFW_KEY_5, '5');
    AddKeyCallback(GLFW_KEY_6, '6');
    AddKeyCallback(GLFW_KEY_7, '7');
    AddKeyCallback(GLFW_KEY_8, '8');
    AddKeyCallback(GLFW_KEY_9, '9');
    AddKeyCallback(GLFW_KEY_PERIOD, '.');
    AddKeyCallback(GLFW_KEY_MINUS, '-');
    AddKeyCallback(GLFW_KEY_ENTER, TW_KEY_RETURN);
    AddKeyCallback(GLFW_KEY_LEFT, TW_KEY_LEFT);
    AddKeyCallback(GLFW_KEY_RIGHT, TW_KEY_RIGHT);
    AddKeyCallback(GLFW_KEY_TAB, TW_KEY_TAB);
    AddKeyCallback(GLFW_KEY_END, TW_KEY_END);
    AddKeyCallback(GLFW_KEY_HOME, TW_KEY_HOME);
    AddKeyCallback(GLFW_KEY_BACKSPACE, TW_KEY_BACKSPACE);

    LogInfo("GUI: Tweak bar initialised");
}
Exemplo n.º 19
0
void TW_CALL SetAutoRotateCB(const void *value, void *clientData)
{

	g_AutoRotate = *(const int *)value;
	if (g_AutoRotate != 0)
	{
		g_RotateTime = GetTimeMs();
		g_RotateStart[0] = g_Rotation[0];
		g_RotateStart[1] = g_Rotation[1];
		g_RotateStart[2] = g_Rotation[2];
		g_RotateStart[3] = g_Rotation[3];
		TwDefine(" TweakBar/ObjRotation readonly ");
	}
	else
		TwDefine(" TweakBar/ObjRotation readwrite ");
}
void SSAO::BuildUI() {
	TwInit(TW_DIRECT3D11, _device);
	TwWindowSize(_screenWidth, _screenHeight);
	_bar = TwNewBar("AmbientOcclusion");
	TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar into a DirectX11 application.' "); // Message added to the help bar.
	int barSize[2] = {300, 375};
	TwSetParam(_bar, NULL, "size", TW_PARAM_INT32, 2, barSize);

	TwAddVarCB(_bar, "Rad", TW_TYPE_FLOAT, SSAO::SetRad, SSAO::GetRad, this, "group=ShaderParams min=0 max=20 step=0.001 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "TotalStr", TW_TYPE_FLOAT, SSAO::SetTotStr, SSAO::GetTotStr, this, "group=ShaderParams min=0 max=50 step=0.1 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Strength", TW_TYPE_FLOAT, SSAO::SetStrength, SSAO::GetStrength, this, "group=ShaderParams min=0.1 max=100 step=0.1 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Offset", TW_TYPE_FLOAT, SSAO::SetOffset, SSAO::GetOffset, this, "group=ShaderParams min=0 max=100 step=0.5 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "Falloff", TW_TYPE_FLOAT, SSAO::SetFalloff, SSAO::GetFalloff, this, "group=ShaderParams min=0 max=0.01 step=0.00001 keyincr=+ keydecr=-");
	TwAddVarCB(_bar, "BlurSize", TW_TYPE_FLOAT, SSAO::SetBlur, SSAO::GetBlur, this, "group=ShaderParams min=1 max=16 step=1 keyincr=+ keydecr=-");
	TwAddButton(_bar, "Reset", SSAO::ResetButton, this, "");
	TwAddButton(_bar, "ShowDebug", SSAO::ShowDebug, this, "");

	TwEnumVal* a = new TwEnumVal[3];
	a[0].Value = 0; a[0].Label = "buddha";
	a[1].Value = 1; a[1].Label = "hairball";
	a[2].Value = 2; a[2].Label = "sib";
	_index = 0;

	TwType actMesh = TwDefineEnum("mesh", a, 3);

	TwAddVarCB(_bar, "ActiveVol", actMesh, SSAO::SetMesh, SSAO::GetMesh, this, 
		" group='Mesh' keyIncr=Backspace keyDecr=SHIFT+Backspace help='Stop or change the rotation mode.' ");

}
Exemplo n.º 21
0
int main(int args, char **argv)
{
  glutInit(&args, argv);
  glutInitWindowSize(800, 600);
  glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
  glutCreateWindow("simple vertex shader");

  TwInit(TW_OPENGL, NULL);
  TwBar *bar = TwNewBar("myBar");
  TwDefine("myBar size='200 400' color = '96 216 224'");

  TwAddVarRW(bar, "ObjectRotate", TW_TYPE_QUAT4F, &g_Rotate, "label='Object Rotation' opened=true");
  TwAddVarRW(bar, "LightDir", TW_TYPE_DIR3F, &g_lightPos, "label='light Pos' opened=true");
  glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
  glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
  TwGLUTModifiersFunc(glutGetModifiers);
  glutDisplayFunc(RenderScene);
  glutReshapeFunc(ChangeSize);
  SetupRC();
  glutMainLoop();
  Terminate();
  return 0;
}
Exemplo n.º 22
0
void RotationsViewer::initializeGui()
{
    glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
    TwGLUTModifiersFunc(glutGetModifiers);
    TwInit(TW_OPENGL, NULL);
    TwWindowSize(mWindowWidth, mWindowHeight);

    TwCopyStdStringToClientFunc(onCopyStdStringToClient);

    mDemoBar = TwNewBar("Demo controls");
    TwDefine(" 'Demo controls' size='200 175' position='5 5' iconified=false fontresizable=false alpha=200");

    TwEnumVal modeTypeEV[] = { { DEMO1, "Convert" }, { DEMO2, "Curve" } };
    modeType = TwDefineEnum("ModeType", modeTypeEV, 2);
    TwAddVarRW(mDemoBar, "Demo", modeType, &mMode, NULL);

    TwAddVarRW(mDemoBar, "X Angle", TW_TYPE_DOUBLE, &mXAngle, " group='Convert params' ");
    TwAddVarRW(mDemoBar, "Y Angle", TW_TYPE_DOUBLE, &mYAngle, " group='Convert params' ");
    TwAddVarRW(mDemoBar, "Z Angle", TW_TYPE_DOUBLE, &mZAngle, " group='Convert params' ");
    TwEnumVal rooTypeEV[] = { { XYZ, "XYZ" }, { XZY, "XZY" }, { YXZ, "YXZ" }, { YZX, "YZX" }, { ZXY, "ZXY" }, { ZYX, "ZYX" } };
    rooType = TwDefineEnum("RooType", rooTypeEV, 6);
    TwAddVarRW(mDemoBar, "Rot Order", rooType, &mRotOrder, " group='Convert params' ");

    TwEnumVal splineTypeEV[] = { { ASplineQuat::LINEAR, "Linear" }, { ASplineQuat::CUBIC, "Cubic" } };
    splineType = TwDefineEnum("SplineType", splineTypeEV, 2);
    TwAddVarCB(mDemoBar, "Spline type", splineType, onSetStyleCb, onGetStyleCb, this, " group='Curve params'");
}
Exemplo n.º 23
0
/** Initializes GUI - only AntweakBar menu creation */
void initGUI()
{
    // Initialize AntTweakBar GUI
    if (!TwInit(TW_OPENGL, NULL))
    {
        assert(0);
    }

    TwWindowSize(g_WindowWidth, g_WindowHeight);
    TwBar *controlBar = TwNewBar("Controls");
    TwDefine("Controls position='10 10' size='200 300' refresh=0.1  color='130 140 150'");
	
	TwAddVarCB(controlBar, "gpu", TW_TYPE_BOOLCPP, cbSetGPUUsage, cbGetGPUUsage, NULL, " group='CUDA' label='Compute on:' true='GPU' false='CPU' ");
	//TwAddVarRW(controlBar, "restart", TW_TYPE_BOOLCPP, &g_initData, " group='PROGRAM' label='Restart: ' true='' false='restart' ");
    
    TwAddVarRW(controlBar, "melt", TW_TYPE_BOOLCPP, &g_melt, " group='Render' label='Melt' key=m help='Start melting' ");
	TwAddVarRW(controlBar, "wiremode", TW_TYPE_BOOLCPP, &g_WireMode, " group='Render' label='Wire mode' key=w help='Toggle wire mode.' ");
    TwAddVarRW(controlBar, "march", TW_TYPE_BOOLCPP, &g_useMarchingCubes, " group='Render' label='March. Cubes' help='Toggle marching cubes.' ");
    
    TwAddVarRW(controlBar, "auto-rotation", TW_TYPE_BOOLCPP, &g_SceneRotEnabled, " group='Scene' label='rotation' key=r help='Toggle scene rotation.' ");
    TwAddVarRW(controlBar, "Translate", TW_TYPE_FLOAT, &g_SceneTraZ, " group='Scene' label='translate' min=1 max=1000 step=10 keyIncr=t keyDecr=T help='Scene translation.' ");
    TwAddVarRW(controlBar, "SceneRotation", TW_TYPE_QUAT4F, &g_SceneRot, " group='Scene' label='rotation' open help='Toggle scene orientation.' ");
	
	TwAddVarRO(controlBar, "fps", TW_TYPE_FLOAT, &g_fps, " group='INFO' label='Current fps' ");
	TwAddVarRO(controlBar, "ice", TW_TYPE_FLOAT, &g_iceParticles, " group='INFO' label='Ice particles' ");
	
}
void initGUI() {
    // Initialize AntTweakBar GUI
    if (!TwInit(TW_OPENGL, NULL))
    {
        assert(0);
    }

    TwWindowSize(g_WindowWidth, g_WindowHeight);
    TwBar *controlBar = TwNewBar("Controls");
    TwDefine(" Controls position='10 10' size='200 320' refresh=0.1 ");

    TwAddVarCB(controlBar, "use_shaders", TW_TYPE_BOOLCPP, cbSetShaderStatus, cbGetShaderStatus, NULL, " label='shaders' key=s help='Turn programmable pipeline on/off.' ");

    // Shader panel setup
    TwAddVarRW(controlBar, "vs", TW_TYPE_BOOLCPP, &g_UseVertexShader, " group='Shaders' label='vertex' key=v help='Toggle vertex shader.' ");
    TwAddVarRW(controlBar, "gs", TW_TYPE_BOOLCPP, &g_UseGeometryShader, " group='Shaders' label='geometry' key=g help='Toggle geometry shader.' ");
    TwAddVarRW(controlBar, "fs", TW_TYPE_BOOLCPP, &g_UseFragmentShader, " group='Shaders' label='fragment' key=f help='Toggle fragment shader.' ");
    TwAddButton(controlBar, "build", cbCompileShaderProgram, NULL, " group='Shaders' label='build' key=b help='Build shader program.' ");
	//TwDefine( " Controls/Shaders readonly=true "); 

    // Render panel setup
    TwAddVarRW(controlBar, "wiremode", TW_TYPE_BOOLCPP, &g_WireMode, " group='Render' label='wire mode' key=w help='Toggle wire mode.' ");
    TwAddVarRW(controlBar, "face_culling", TW_TYPE_BOOLCPP, &g_FaceCulling, " group=Render label='face culling' key=c help='Toggle face culling.' ");

    // Scene panel setup
    TwEnumVal geometry_type[] = { 
        { ELEPHANT_GEOMETRY    , "Elephant"},
        { CUBE_GEOMETRY        , "Cube"    },
    };
    TwType geom_type = TwDefineEnum("Model", geometry_type, NUM_GEOMETRY_TYPES);
    TwAddVarRW(controlBar, "model", geom_type, &g_GeometryType, " group='Scene' keyIncr=Space help='Change model.' ");
    TwAddVarRW(controlBar, "auto-rotation", TW_TYPE_BOOLCPP, &g_SceneRotEnabled, " group='Scene' label='rotation' key=r help='Toggle scene rotation.' ");
    TwAddVarRW(controlBar, "Translate", TW_TYPE_FLOAT, &g_SceneTraZ, " group='Scene' label='translate' min=1 max=1000 step=0.5 keyIncr=t keyDecr=T help='Scene translation.' ");
    TwAddVarRW(controlBar, "SceneRotation", TW_TYPE_QUAT4F, &g_SceneRot, " group='Scene' label='rotation' open help='Toggle scene orientation.' ");
}
Exemplo n.º 25
0
fractal_t::fractal_t()
    : pos_(0.5, 0), scale_factor_(1)
{
#ifdef USE_CORE_OPENGL
   TwInit(TW_OPENGL_CORE, NULL);
#else
   TwInit(TW_OPENGL, NULL);
#endif
   // Определение "контролов" GUI
   TwBar *bar = TwNewBar("Parameters");
   TwDefine(" Parameters size='300 50' color='70 100 120' valueswidth=220 iconpos=topleft");

   TwAddButton(bar, "Fullscreen toggle", toggle_fullscreen_callback, NULL,
               " label='Toggle fullscreen mode' key=f");

   // Создание шейдеров
   vs_ = create_shader(GL_VERTEX_SHADER  , "shaders//fractal.glslvs");
   fs_ = create_shader(GL_FRAGMENT_SHADER, "shaders//fractal.glslfs");
   // Создание программы путём линковки шейдерова
   program_ = create_program(vs_, fs_);
   // Создание буфера с вершинными данными
   init_buffer();
   // Создание VAO
   init_vertex_array();
}
Exemplo n.º 26
0
void PezInitialize()
{
    TweakBar = TwNewBar("TweakBar");
    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar.
    TwDefine(" TweakBar size='200 400' color='96 216 224' "); // change default tweak bar size and color

    TwAddVarRW(TweakBar, "Theta", TW_TYPE_FLOAT, &Scene.Theta, " min=0.01 max=6.28 step=0.01 ");
    TwAddVarRW(TweakBar, "TargetVector", TW_TYPE_DIR3F, &TargetVector, " ");
    TwAddVarRW(TweakBar, "TargetScale", TW_TYPE_FLOAT, &TargetScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "EyeVector", TW_TYPE_DIR3F, &EyeVector, " ");
    TwAddVarRW(TweakBar, "EyeScale", TW_TYPE_FLOAT, &EyeScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "YScale", TW_TYPE_FLOAT, &YScale, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "YOffset", TW_TYPE_FLOAT, &YOffset, " min=0.01 max=10.00 step=0.01 ");
    TwAddVarRW(TweakBar, "TessLevel", TW_TYPE_FLOAT, &TessLevel, " min=1.0 max=10.00 step=0.01 ");
    TwAddButton(TweakBar, "Lookup AO", LookupAoCallback, 0, "");
    TwAddVarRW(TweakBar, "Show AO", TW_TYPE_BOOL8, &ShowAO, "");

    PezConfig cfg = PezGetConfig();

    pezAddPath("../Cover/PostTess/", ".glsl");
    Scene.DisplayProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Display");
    Scene.FloorProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Floor");
    Scene.OffscreenProgram = LoadProgram("PostTess.VS", "PostTess.TessControl", "PostTess.TessEval", 0, "PostTess.Offscreen");
    Scene.QuadProgram = LoadProgram("PostTess.Quad.VS", 0, 0, 0, "PostTess.Quad.FS");
    Scene.Theta = 2.36f;

    Scene.Surfaces = CreateSurfaces(cfg.Width, cfg.Height, 4, 3);
    GLenum err = glGetError();
    pezCheck(err == GL_NO_ERROR, "OpenGL error.\n");

    Scene.QuadVao = CreateQuad();

    ReadVerts("../Cover/PreTess/City.dat");
    glEnable(GL_DEPTH_TEST);
    glClearColor(0, 0, 0, 0);

    glGenTextures(1, &Scene.CompositeTexture);
    glBindTexture(GL_TEXTURE_2D, Scene.CompositeTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, cfg.Width, cfg.Height, GL_FALSE, GL_RGBA, GL_FLOAT, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    err = glGetError();
    pezCheck(err == GL_NO_ERROR, "OpenGL error.\n");
}
void RTweakBar::AddIntRW(const char* table, int* value, const char* name, float min, float max, float step)
{
	if(!GetBarByName(table))
		return;

	TwAddVarRW(GetBarByName(table), name, TwType::TW_TYPE_INT32, value, nullptr);
	TwDefine((std::string(table) + "/" + std::string(name) + " min=" + std::to_string(min) + " max=" + std::to_string(max) + " step=" + std::to_string(step)).c_str());
}
Exemplo n.º 28
0
InterfaceGl::InterfaceGl( const std::string &title, const Vec2i &size, const ColorA color )
{
    initAntGl();
    mBar = shared_ptr<TwBar>( TwNewBar( title.c_str() ), TwDeleteBar );
    char optionsStr[1024];
    sprintf( optionsStr, "%s size='%d %d' color='%d %d %d' alpha=%d", title.c_str(), size.x, size.y, (int)(color.r * 255), (int)(color.g * 255), (int)(color.b * 255), (int)(color.a * 255) );
    TwDefine( optionsStr );
}
Exemplo n.º 29
0
void InterfaceGl::setOptions( const std::string &name, const std::string &optionsStr )
{
	std::string target = "`" + (std::string)TwGetBarName( mBar.get() ) + "`";
	if( !( name.empty() ) )
		target += "/`" + name + "`";

	TwDefine( ( target + " " + optionsStr ).c_str() );
}
Exemplo n.º 30
0
void MaterialDialog::setMaterial(int pIndex)
{
	if (m_dialog)
		TwDeleteBar(m_dialog);
	// Create a tweak bar
	m_dialog = TwNewBar("Material");
	int barSize[2] = {200, 1060};
	TwDefine(" Material position='1710 10'  ");
	TwSetParam(m_dialog, NULL, "size", TW_PARAM_INT32, 2, barSize);

	m_material = Scene::GetInstance()->GetMaterial(pIndex);

	TwAddVarCB(m_dialog, "MaterialName", TW_TYPE_CDSTRING, SetName, GetName, (void*)this, " label='Name: '");
	TwAddVarRW(m_dialog, "Ambient", TW_TYPE_COLOR3F, (void*)&m_material->ambient, " help='Light color.' group='Properties'");
	TwAddVarRW(m_dialog, "Diffuse", TW_TYPE_COLOR3F, (void*)&m_material->diffuse, " help='Light color.' group='Properties'");
	TwAddVarRW(m_dialog, "Specular", TW_TYPE_COLOR3F, (void*)&m_material->specular, " help='Light color.' group='Properties'");
	TwAddVarRW(m_dialog, "Emissive", TW_TYPE_COLOR3F, (void*)&m_material->emissive, " help='Light color.' group='Properties'");

	TwAddVarRW(m_dialog, "Opacity", TW_TYPE_FLOAT, (void*)&m_material->opacity, " help='Light color.' group='Properties' min=0.0 max=1.0 step=0.01");
	TwAddVarRW(m_dialog, "Reflectivity", TW_TYPE_FLOAT, (void*)&m_material->reflectivity, " help='Light color.' group='Properties' min=0.0 max=1.0 step=0.01");
	TwAddVarRW(m_dialog, "Shininess", TW_TYPE_FLOAT, (void*)&m_material->shininess, " help='Light color.' group='Properties' min=0.0 max=100.0 step=1.0");
	TwAddVarRW(m_dialog, "Texture Scale", TW_TYPE_FLOAT, (void*)&m_material->textureScale, " help='Light color.' group='Properties' min=0.0 max=10.0 step=0.01");

	TwAddButton(m_dialog, "Load Diffuse Texture", LoadDiffuse, this, " label='Diffuse Texture' key=c help='Load an Agile file into the editor.' group='Load'");
	TwAddButton(m_dialog, "Load Specular Texture", LoadSpecular, this, " label='Specular Texture' key=c help='Load an Agile file into the editor.' group='Load'");
	TwAddButton(m_dialog, "Load Glow Texture", LoadGlow, this, " label='Glow Texture' key=c help='Load an Agile file into the editor.' group='Load'");
	TwAddButton(m_dialog, "Load Normal Texture", LoadNormal, this, " label='Normal Texture' key=c help='Load an Agile file into the editor.' group='Load'");
	TwAddButton(m_dialog, "Load Displacement Texture", LoadDisplacement, this, " label='Displacement Texture' key=c help='Load an Agile file into the editor.' group='Load'");
	TwAddButton(m_dialog, "Load Gradient Texture", LoadGradient, this, " label='Gradient Texture' key=c help='Load an Agile file into the editor.' group='Load'");

	TwStructMember tessMembers[] = { 
		{ "Edge1", TW_TYPE_FLOAT, offsetof(AglVector4, x), " Step=0.1 min=1.0 max=64.0" },
		{ "Edge2", TW_TYPE_FLOAT, offsetof(AglVector4, y), " Step=0.1 min=1.0 max=64.0" },
		{ "Edge3", TW_TYPE_FLOAT, offsetof(AglVector4, z), " Step=0.1 min=1.0 max=64.0" },
		{ "Internal", TW_TYPE_FLOAT, offsetof(AglVector4, w), " Step=0.1 min=1.0 max=64.0" }};
	TwType tessType = TwDefineStruct("TESSELATIONFACTORS", tessMembers, 4, sizeof(AglVector4), NULL, NULL);

	TwAddVarRW(m_dialog, "Tess", tessType, &m_material->tesselationFactor, " group='Properties' ");
	TwAddVarRW(m_dialog, "Displacement", TW_TYPE_FLOAT, (void*)&m_material->displacement, " group='Properties' min=0.0 max=10.0 step=0.01");

	TwAddButton(m_dialog, "Add Layer", AddLayer, this, " label='Add Layer' key=c help='Load an Agile file into the editor.' group='Gradient Mapping'");

	TwAddButton(m_dialog, "Delete", Delete, this, "");


	if (m_material->gradientDataIndex >= 0)
	{
		AglGradient* g = Scene::GetInstance()->GetGradient(m_material->gradientDataIndex);
		vector<AglGradientMaterial*> layers = g->getLayers();
		for (unsigned int i = 0; i < layers.size(); i++)
		{
			AddLayer(g, layers[i], i);
		}
	}


	show();
}