/** An entry-point file using render/GlutRender as a renderer, displaying the * bouncing implicit-surface defined sphere. **/ #include #include "render/GlutRender.hpp" #include "Ball.hpp" #include "FlatGround.hpp" #include "MarchingCubes.hpp" #include "GroundFlatMesh.hpp" #include "periodic_updates.hpp" int main(int argc, char** argv) { bool perlin = false; for(int pos=1; pos < argc; ++pos) { if(strcmp(argv[pos], "-perlin") == 0) perlin = true; if(strcmp(argv[pos], "-azerty") == 0) set_key_mapping(KeyMappings::azerty()); if(strcmp(argv[pos], "-qwerty") == 0) set_key_mapping(KeyMappings::qwerty()); } // Last minute switch, this code is ugly, please close your eyes until // stated otherwise. PerlinGround perlin_ground; FlatGround flat_ground; GroundFlatMesh ground_mesh(Point(0., 0., 0.), 0.05); Ground* ball_ground = nullptr; if(perlin) ball_ground = &perlin_ground; else ball_ground = &flat_ground; // You can open your eyes, now. GlutRender& render = GlutRender::get_instance(); render.init(&argc, argv, 640, 480, "Bouncing stuff"); Ball ball(Point(0, 5, 0), ball_ground, 0.55, -.5, -.7, 1, 1); ball.get_surface()->set_color(Color(1., 0., 0.)); Cuboid bbox = ball.get_surface()->max_bounding_box(); Cuboid bbox_2(Point(-20, -3, -20), Point(20,3,20)); printf("%.2lf %.2lf %.2lf | %.2lf %.2lf %.2lf\n", bbox.low(0), bbox.low(1), bbox.low(2), bbox.high(0), bbox.high(1), bbox.high(2)); render.add_surface(ball.get_surface(), bbox); if(perlin) { perlin_ground.get_surface()->set_color(Color(0.13, 0.82, 0.21)); render.add_surface(perlin_ground.get_surface(), bbox_2, false, 0.50); } else { ground_mesh.get_mesh()->set_color(Color(0.13, 0.82, 0.21)); render.add_mesh(ground_mesh.get_mesh()); } //render.follow_implicit_position(ball.get_surface()); render.set_idle_func(periodic_update); render.add_kb_handler(periodic_kb_handler); render.add_kb_up_handler(periodic_kb_up_handler); init_periodic_static(&ball, &render); render.run(); return 0; }