-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPinterface.cpp
123 lines (103 loc) · 2.79 KB
/
TPinterface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "TPinterface.h"
#include "LightingScene.h"
TPinterface::TPinterface()
{
testVar=0;
}
void TPinterface::processKeyboard(unsigned char key, int x, int y)
{
// Uncomment below if you would like to process the default keys (e.g. 's' for snapshot, 'Esc' for exiting, ...)
// CGFinterface::processKeyboard(key, x, y);
switch(key)
{
case 'i':
{
// This is an example of accessing the associated scene
// To test, create the function toggleSomething in your scene to activate/deactivate something
((LightingScene *) scene)->robot->move(0);
break;
}
case 'k':
{
((LightingScene *) scene)->robot->move(1);
break;
}
case 'j':
{
((LightingScene *) scene)->robot->rotate(0);
break;
}
case 'l':
{
((LightingScene *) scene)->robot->rotate(1);
break;
}
}
}
void TPinterface::initGUI()
{
// Check CGFinterface.h and GLUI documentation for the types of controls available
GLUI_Panel *mainPanel= addPanel("Controls", 0);
GLUI_Panel *lightPanel = addPanelToPanel(mainPanel, "Lights", 1);
GLUI_Panel *clockPanel = addPanelToPanel(mainPanel, "Clock", 1);
GLUI_Panel *robotPanel = addPanelToPanel(mainPanel, "Robot" , 1);
addCheckboxToPanel(lightPanel, "Light 0:", &(((LightingScene*) scene)->_light0), 1);
addCheckboxToPanel(lightPanel, "Light 1:", &(((LightingScene*) scene)->_light1), 2);
addCheckboxToPanel(lightPanel, "Light 2:", &(((LightingScene*) scene)->_light2), 3);
addCheckboxToPanel(lightPanel, "Light 3:", &(((LightingScene*) scene)->_light3), 4);
addColumn();
addButtonToPanel(clockPanel , "Pause/Resume", 5);
addButtonToPanel(clockPanel , "Restart", 6);
addColumn();
GLUI_Listbox* lb = addListboxToPanel(robotPanel, "", &(((LightingScene*) scene)->_textselect), 7);
lb->add_item(1, "Texture 1");
lb->add_item(2, "Texture 2");
lb->add_item(3, "Texture 3");
GLUI_RadioGroup* gbutton = addRadioGroupToPanel(robotPanel, &(((LightingScene*) scene)->_radiobutton), 8);
addRadioButtonToGroup(gbutton, "Textured");
addRadioButtonToGroup(gbutton, "WireFrame");
// You could also pass a reference to a variable from the scene class, if public
}
void TPinterface::processGUI(GLUI_Control *ctrl)
{
printf ("GUI control id: %d\n ",ctrl->user_id);
switch (ctrl->user_id)
{
case 1:
{
printf("Modifying Light 0.\n");
break;
};
case 2:
{
printf("Modifying Light 1.\n");
break;
};
case 3:
{
printf("Modifying Light 2.\n");
break;
};
case 4:
{
printf("Modifying Light 3.\n");
break;
};
case 5:
{
((LightingScene*) scene)->clock->setActive(!((LightingScene*) scene)->clock->getActive());
printf("Clock Paused/Resumed\n");
break;
};
case 6:
{
((LightingScene*) scene)->clock->resetClock();
break;
printf("Clock Reseted\n");
};
case 7:
{
printf("Texture Changed");
};
};
}