/
TPInterface.cpp
88 lines (65 loc) · 2.32 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
#include "TPinterface.h"
#include "LightingScene.h"
TPinterface::TPinterface(sceneGraph *graph)
{
pgraph = graph;
getCameraList();
}
void TPinterface::getCameraList()
{
vector<camera *> cams = pgraph->getCameras();
for(vector<camera *>::iterator it = cams.begin(); it != cams.end(); it++)
{
cameras.push_back((*it)->getID());
}
}
void TPinterface::initGUI()
{
pgraph = &(((LightingScene*) scene)->pgraph);
int* wire = &(((LightingScene*) scene)->wire);
int* wind = &(((LightingScene*) scene)->wind);
int * cam = &(((LightingScene*) scene)->activCam);
// Check CGFinterface.h and GLUI documentation for the types of controls available
GLUI_Panel *varPanel= addPanel("Settings:", 1);
GLUI_Panel *modepanel = addPanelToPanel(varPanel, "Mode", 1);
GLUI_RadioGroup* wireFrameGroup = addRadioGroupToPanel(modepanel,wire);
addRadioButtonToGroup(wireFrameGroup, "\tFill");
addRadioButtonToGroup(wireFrameGroup, "\tWire");
addRadioButtonToGroup(wireFrameGroup, "\tPoint");
addColumnToPanel(varPanel);
GLUI_Panel *cammodel = addPanelToPanel(varPanel, "Camera", 1);
GLUI_RadioGroup* camerasGroup = addRadioGroupToPanel(cammodel,cam);
for(int i = 0; i < cameras.size();i++)
{
addRadioButtonToGroup(camerasGroup, (char *)cameras[i].c_str());
}
addRadioButtonToGroup(camerasGroup, "Free Camera");
addColumnToPanel(varPanel);
GLUI_Panel *lightspanel = addPanelToPanel(varPanel, "Lights", 1);
for(int i = 0; i < pgraph->getLights().size();i++)
{
if (pgraph->getLights()[i].enabled)
addCheckboxToPanel(lightspanel,
(char*)pgraph->getLights()[i].id.c_str(), NULL, i)->set_int_val(
1);
else
addCheckboxToPanel(lightspanel,
(char*)pgraph->getLights()[i].id.c_str(), NULL, i)->set_int_val(
0);
}
addColumnToPanel(varPanel);
GLUI_Panel *windpanel = addPanelToPanel(varPanel, "Wind", 1);
GLUI_Spinner *spin= addSpinnerToPanel(windpanel,"wind",GLUI_SPINNER_INT,wind,11);
spin->set_int_limits(0,11,GLUI_LIMIT_WRAP);
}
void TPinterface::processGUI(GLUI_Control *ctrl)
{
if (ctrl->user_id >= 0 && ctrl->user_id <11)
if (ctrl->get_int_val() == 1) {
pgraph->getLights()[ctrl->user_id].enabled = true;
((LightingScene *) scene)->lightsVector[ctrl->user_id]->enable();
} else {
pgraph->getLights()[ctrl->user_id].enabled = false;
((LightingScene *) scene)->lightsVector[ctrl->user_id]->disable();
}
}