void two_tetrahedrons() { Polyhedron a; make_tetrahedron(a, Point(1.0, 0.0, 0.0), Point(2.0, 0.0, 0.0), Point(1.5, 1.0, 0.0), Point(1.5, .5, 10.0)); Polyhedron b; make_tetrahedron(b, Point(0.0, 0., .5), Point(0.0, 0.0, 1.5), Point(0.0, 1.0, 1.0), Point(10.0, .5, 1.0)); if (a.is_pure_triangle()) std::cout << "a is pure triangle" << std::endl; if (b.is_pure_triangle()) std::cout << "b is pure triangle" << std::endl; Polyhedron &biggest = a.size_of_facets() > b.size_of_facets() ? a : b; Polyhedron &smallest = a.size_of_facets() > b.size_of_facets() ? b : a; std::list<std::list<boost::tuple<Facet_handle, Facet_handle, Segment> > > polylines; { std::list<boost::tuple<Facet_handle, Facet_handle, Segment> > intersections; compute_intersections(biggest, smallest, std::back_inserter(intersections)); for (std::list<boost::tuple<Facet_handle, Facet_handle, Segment> >::iterator it = intersections.begin(); it != intersections.end(); it++) { { Halfedge_handle h = it->get<0>()->halfedge(); Triangle t(h->vertex()->point(), h->next()->vertex()->point(), h->next()->next()->vertex()->point()); assert(t.has_on(it->get<2>().source())); assert(t.has_on(it->get<2>().target())); } { Halfedge_handle h = it->get<1>()->halfedge(); Triangle t(h->vertex()->point(), h->next()->vertex()->point(), h->next()->next()->vertex()->point()); assert(t.has_on(it->get<2>().source())); assert(t.has_on(it->get<2>().target())); } } sort_polylines<Polyhedron>(biggest, smallest, intersections, polylines); } std::list<std::vector<typename Polyhedron::Halfedge_handle> > intersection_list; split_facets<Polyhedron, 0>(biggest, polylines, intersection_list); //split_facets<Polyhedron, 1>(smallest, polylines); }
/* explicit */ tetrahedron::tetrahedron() : base() { TRACE("hugh::scene::object::geometry::tetrahedron::tetrahedron"); attribute_list_.clear(); index_list_ .clear(); make_tetrahedron(attribute_list_, index_list_); compute_bounds(); compute_tangents(); }
ExperimentalApp() : GLFWApp(1280, 800, "Geometric Algorithm Development App") { glfwSwapInterval(0); igm.reset(new gui::ImGuiManager(window)); gui::make_dark_theme(); fixedTimer.start(); lights[0] = {{0, 10, -10}, {0, 0, 1}}; lights[1] = {{0, 10, 10}, {0, 1, 0}}; int width, height; glfwGetWindowSize(window, &width, &height); glViewport(0, 0, width, height); grid = RenderableGrid(1, 100, 100); cameraController.set_camera(&camera); camera.look_at({0, 2.5, -2.5}, {0, 2.0, 0}); simpleShader = make_watched_shader(shaderMonitor, "../assets/shaders/simple_vert.glsl", "assets/shaders/simple_frag.glsl"); normalDebugShader = make_watched_shader(shaderMonitor, "../assets/shaders/normal_debug_vert.glsl", "assets/shaders/normal_debug_frag.glsl"); Renderable debugAxis = Renderable(make_axis(), false, GL_LINES); debugAxis.pose = Pose(float4(0, 0, 0, 1), float3(0, 1, 0)); debugModels.push_back(std::move(debugAxis)); // Initial supershape settings supershape = Renderable(make_supershape_3d(16, 5, 7, 4, 12)); supershape.pose.position = {0, 2, -2}; // Initialize PTF stuff { std::array<float3, 4> controlPoints = {float3(0.0f, 0.0f, 0.0f), float3(0.667f, 0.25f, 0.0f), float3(1.33f, 0.25f, 0.0f), float3(2.0f, 0.0f, 0.0f)}; ptf = make_parallel_transport_frame_bezier(controlPoints, 32); for (int i = 0; i < ptf.size(); ++i) { Renderable p = Renderable(make_cube()); ptfBoxes.push_back(std::move(p)); } } // Initialize Parabolic pointer stuff { // Set up the ground plane used as a nav mesh for the parabolic pointer worldSurface = make_plane(48, 48, 96, 96); for (auto & p : worldSurface.vertices) { float4x4 model = make_rotation_matrix({1, 0, 0}, -ANVIL_PI / 2); p = transform_coord(model, p); } worldSurfaceRenderable = Renderable(worldSurface); parabolicPointer = make_parabolic_pointer(worldSurface, params); } // Initialize objects for ballistic trajectory tests { turret.source = Renderable(make_tetrahedron()); turret.source.pose = Pose({-5, 2, 5}); turret.target = Renderable(make_cube()); turret.target.pose = Pose({0, 0, 40}); turret.bullet = Renderable(make_sphere(1.0f)); } float4x4 tMat = mul(make_translation_matrix({3, 4, 5}), make_rotation_matrix({0, 0, 1}, ANVIL_PI / 2)); auto p = make_pose_from_transform_matrix(tMat); std::cout << tMat << std::endl; std::cout << p << std::endl; gl_check_error(__FILE__, __LINE__); }