#include "ik.h" #include "Utils.h" #include "viewer.h" #include "RunButton.h" #include "Utils.h" // init an input but's label align and assign init val void init_int_input_button(Fl_Int_Input *b, int align, int init_val) { char s_val[10]; _itoa(init_val, s_val, 10); b->align(align); b->when(FL_WHEN_ENTER_KEY); // call back on enter b->value(s_val); } void quitCB(Fl_Menu_*mbar, Panel* wind) { wind->del_all(); exit(0); } // the main routine makes the window, and then runs an even loop // until the window is closed int main() { int w, h, gl_w, gl_h, x0, x1, x2, x3, x4, x5, x6, x2_5; int y0, y1, y2, y3, y4, y5; Panel* wind; Gl_Win *gl; Fl_Menu_Bar* mbar; w = 780; h = 650; gl_w = 580; gl_h = 450; x0 = 10; x1 = x0 + 130; x2 = x1 + 120; x2_5 = x2 + 60; x3 = x0+gl_w - 50; x4 = gl_w + 30; // col rt of glwin x5 = x4 + 20; x6 = 920; y0 = 30; y1 = y0 + 30; y2 = y0+ gl_h + 10; // row below glwin y3 = y2 + 50; // row below y2 y4 = y3 + 30; // row below y3 y5 = y4 + 30; wind = new Panel(100,100,w,h); Fl_Group::current()->resizable(wind); wind->begin(); // put widgets inside of the window wind->gl = new Gl_Win(x0,y0,gl_w, gl_h); gl = wind->gl; Fl_Menu_Item file_menu[] = { {" ", 0, 0, 0, FL_SUBMENU }, {0}, { "&File", 0, 0, 0, FL_SUBMENU }, {"Open BVH File", FL_ALT+'b', (Fl_Callback*)in_bvhCB, wind, 0, 0, 0, 14, 0}, {"Save Quat Motion", FL_ALT+'s', (Fl_Callback*)out_qbvhCB, wind, 0, 0, 0, 14, 0}, {"Open QBVH File", FL_ALT+'q', (Fl_Callback*)in_qbvhCB, wind, 0, 0, 0, 14, 0}, {"", 0, 0, 0, 0, 0, 0, 14, 0}, {"Quit", FL_ALT+'x', (Fl_Callback*)quitCB, wind, 0, 0, 0, 14, 0}, {0}, { "&Marker", 0, 0, 0, FL_SUBMENU }, { "Load Marker Request", 0, (Fl_Callback*)in_marker_fileCB, gl }, { "Export Markers", 0, (Fl_Callback*)out_marker_fileCB, gl }, {0}, {0} }; mbar = new Fl_Menu_Bar(0, 0, w, 25); mbar->menu(file_menu); RunSlider* rt = new RunSlider(gl, gl->frame_cnt, x1, y2, x0+gl_w-x1,30); gl->timeS = rt; gl->runBut = new RunButton(rt,x0, y2, 80,30, gl->frame_time, gl->play_mode); wind->play_modeB = new Fl_Round_Button(x5, y4+20, 50, 30, "Real Time"); wind->play_modeB->value(gl->play_mode); wind->play_modeB->labelsize(12); wind->cameraB = new Fl_Round_Button(x5, y4+50, 50, 30, "camera follow"); wind->cameraB->value(0); // static camera init wind->cameraB->labelsize(12); // auto key eveyr nth frame wind->key_nthB = new Fl_Int_Input(x0, y3, 40, 20, "key nth"); wind->key_nthB->labelsize(11); init_int_input_button(wind->key_nthB, FL_ALIGN_RIGHT, 0); // manually key this frame wind->key_addB = new Fl_Round_Button(x0, y4, 50, 30, "key this frame"); wind->key_addB->labelsize(11); // manually un-key this frame wind->key_rmvB = new Fl_Round_Button(x0, y4+30, 50, 30, "Del this key" ); wind->key_rmvB->labelsize(11); // print all keys wind->key_printB = new Fl_Round_Button(x1, y4, 50, 30, "Display keys"); // clear all keys wind->key_clearB = new Fl_Round_Button(x1, y4+30, 50, 30, "clear ALL keys"); // user specify which frame to start interp/show wind->beginB = new Fl_Int_Input(x1, y3, 50, 25, "Start Frame"); init_int_input_button(wind->beginB, FL_ALIGN_TOP, gl->begin); // last frame to be shown wind->endB = new Fl_Int_Input(x3, y3, 50, 25, "End"); init_int_input_button(wind->endB, FL_ALIGN_TOP, gl->end); // light wind->lightB = new Fl_Light_Button(x3, y4, 50, 25, "light"); wind->lightB->value(1); // draw floor wind->floorB = new Fl_Light_Button(x3, y4+30, 50, 25, "floor"); wind->floorB->value(1); // endsite selection gl->endsite_browser = new Fl_Multi_Browser(x2_5, y3, 170, 80, "Trace endsites"); gl->endsite_browser->align(FL_ALIGN_TOP); // Euler interp options Fl_Hold_Browser *euler_browser = new Fl_Hold_Browser(x5, y1, 100, 80, "Euler Interp"); wind->euler_browser = euler_browser; euler_browser->align(FL_ALIGN_TOP); euler_browser->add("Hide", 0); euler_browser->add("None", 0); euler_browser->add("Linear", 0); euler_browser->add("Cardinal", 0); euler_browser->value(1); // Quaternion interp options Fl_Hold_Browser *quat_browser = new Fl_Hold_Browser(x5, y1+120, 100, 80, "Quat Interp"); wind->quat_browser = quat_browser; quat_browser->align(FL_ALIGN_TOP); quat_browser->add("Hide", 0); quat_browser->add("None", 0); quat_browser->add("Slerp", 0); quat_browser->add("Quat Berzier", 0); quat_browser->value(2); // Expmap interp options Fl_Hold_Browser *emap_browser = new Fl_Hold_Browser(x5, y1+240, 100, 80, "emap Interp"); wind->emap_browser = emap_browser; emap_browser->align(FL_ALIGN_TOP); emap_browser->add("Hide", 0); emap_browser->add("None", 0); emap_browser->add("Slerp", 0); emap_browser->add("Linear", 0); emap_browser->value(1); Fl_Hold_Browser *marker_type_browser = new Fl_Hold_Browser(x5, y1+360, 100, 60, "marker type"); wind->marker_type_browser = marker_type_browser; marker_type_browser->align(FL_ALIGN_TOP); marker_type_browser->add("EULER", 0); marker_type_browser->add("QUAT", 0); marker_type_browser->add("EXPMAP", 0); marker_type_browser->value(2); Fl_Value_Slider *springS = new Fl_Value_Slider(x5-20, y2+10, 140, 20, "IK Spring"); springS->range(0.0, 1.0); springS->value(0); springS->step(0.05); springS->labelsize(10); springS->align(FL_ALIGN_TOP); springS->type(5); // horizontal, "nice" springS->when(FL_WHEN_CHANGED); // update whenever it changes Fl_Value_Slider *dampS = new Fl_Value_Slider(x5-20, y3, 140, 20, "IK damp"); dampS->range(0.0, 1.0); dampS->value(0.5); dampS->step(0.05); dampS->labelsize(10); dampS->align(FL_ALIGN_TOP); dampS->type(5); // horizontal, "nice" dampS->when(FL_WHEN_CHANGED); // update whenever it changes Fl_Value_Slider *sensitiveS = new Fl_Value_Slider(x5-20, y3+30, 140, 20, "IK factor"); sensitiveS->range(0.0, 1.0); sensitiveS->value(0.025); sensitiveS->step(0.05); sensitiveS->labelsize(10); sensitiveS->align(FL_ALIGN_TOP); sensitiveS->type(5); // horizontal, "nice" sensitiveS->when(FL_WHEN_CHANGED); // update whenever it changes gl->timeS->callback((Fl_Callback*)runSliderCB, wind); gl->runBut->callback((Fl_Callback *)runCB, gl); wind->play_modeB->callback((Fl_Callback *)play_modeCB, gl); wind->cameraB->callback((Fl_Callback *)cameraCB, gl); wind->key_nthB->callback((Fl_Callback*)key_nthCB, wind); wind->key_addB->callback((Fl_Callback*)key_addCB, wind); wind->key_rmvB->callback((Fl_Callback*)key_rmvCB, wind); wind->key_clearB->callback((Fl_Callback*)key_clearCB, wind); wind->key_printB->callback((Fl_Callback*)key_printCB, gl); wind->beginB->callback((Fl_Callback*)beginCB, gl); wind->endB->callback((Fl_Callback*)endCB, gl); wind->lightB->callback((Fl_Callback*)lightCB, gl); wind->floorB->callback((Fl_Callback*)floorCB, gl); euler_browser->callback((Fl_Callback *)euler_browserCB, gl); quat_browser->callback((Fl_Callback *)quat_browserCB, gl); emap_browser->callback((Fl_Callback *)emap_browserCB, gl); marker_type_browser->callback((Fl_Callback *)marker_rotType_browserCB, gl); gl->endsite_browser->callback((Fl_Callback *)marker_sel_browserCB, gl); springS->callback((Fl_Callback *)ik_springCB, gl); dampS->callback((Fl_Callback *)ik_dampCB, gl); sensitiveS->callback((Fl_Callback *)ik_sensitiveCB, gl); wind->end(); // so i don't have to open file all the time // gl->read_input_file ("dance01.bvh", wind, BVH); // wind->label("GL Motion Capture: dance01.bvh"); wind->show(); // this actually opens the window Fl::run(); delete wind; return 1; }