//*************************** File main.c **************************** #include #include #include "../Shape3d/application3.h" #include "../Shape2d/polygon.h" #include "../Shape2d/const.h" #include "../Shape3d/tmesh.h" #include "../Shape2d/scene.h" #include "../Shape3d/rgb.h" #include "../Shape3d/point3.h" #include "../Shape2d/line.h" #include "../Xglib/xglib.h" void main() { application3_t ap(-10,10,-10,10,-10,40,10,0.1); mouse_t mouse(ap.wv) ; light_t * light = new light_t( // ambient light point3_t(0,0,0) , rgb_t(0.4,0.4,0.4) , new light_t( // point light point3_t(10,10,-5), rgb_t(.7,0.6454,0.56) , new light_t( point3_t(-10,0,-2), rgb_t(0.454,0.475,0.504), 0 ))) ; // nice yellowish light source: .7/.6454/.56 // nice bluish light source 230/242/255 scene3_t scene3(&ap.wv,light); { tmesh_t t; t.read("window.data"); t.roty(90); t.translate(point3_t(0, 0, 5)); scene3 += t; } { tmesh_t t; t.read("hexahedron.data"); t.translate(point3_t(-5, 0, 4.134)); scene3 += t; } point_t p; int single_step = 1; int button; int iter=0; for (;;) { // now display scene3.solid(); flush(); iter++; micro_sleep(200000); if (single_step) { single_step = 0; draw_string(0,10,"Press LEFT BUTTON to continue; MIDDLE BUTTON to single step; RIGHT BUTTON to exit"); button = mouse.wait_button_down(p); if (button == 2) single_step = 1; if (button == 3) break; } else { button = mouse.check_button_down(p); if (button) single_step = 1; } setfr(0); // clear screen to gray if (iter <= 10) { // In 10 iterations, this will move us to (-15,0,5) in the // original coordinate system scene3.viewtrans(point3_t(0.7821723252011543, 0, 0.061558297024310704), point3_t(0, 0, 5), point3_t(0, 1, 0)); } else { scene3.viewtrans(point3_t(0, 0, 1), point3_t(0, 0, 5), point3_t(0, 1, 0)); } } }