{"id":13678041,"url":"https://github.com/hugoscurti/mesh-cutter","last_synced_at":"2025-04-29T12:33:21.749Z","repository":{"id":47729715,"uuid":"138106933","full_name":"hugoscurti/mesh-cutter","owner":"hugoscurti","description":"Simple mesh cutting algorithm that works on simple 3d manifold objects with genus 0","archived":false,"fork":false,"pushed_at":"2019-03-23T14:33:12.000Z","size":12716,"stargazers_count":577,"open_issues_count":4,"forks_count":117,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-02T13:20:06.539Z","etag":null,"topics":["gamedev","unity"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hugoscurti.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-21T02:01:53.000Z","updated_at":"2024-07-31T20:25:06.000Z","dependencies_parsed_at":"2022-07-26T17:45:08.777Z","dependency_job_id":null,"html_url":"https://github.com/hugoscurti/mesh-cutter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoscurti%2Fmesh-cutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoscurti%2Fmesh-cutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoscurti%2Fmesh-cutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoscurti%2Fmesh-cutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugoscurti","download_url":"https://codeload.github.com/hugoscurti/mesh-cutter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224173478,"owners_count":17268118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gamedev","unity"],"created_at":"2024-08-02T13:00:49.612Z","updated_at":"2024-11-11T20:30:54.523Z","avatar_url":"https://github.com/hugoscurti.png","language":"C#","funding_links":[],"categories":["Open Source Repositories"],"sub_categories":["Meshes"],"readme":"# Mesh Cutter\n\n\u003cimg src=\"GIFs/Square.gif\" align=\"right\" width=\"150px\"\u003e\n\nA proof-of-concept Unity project for a mesh cutting algorithm. \nThis is a simple implementation of an algorithm that splits in 2 any 3d manifold objects with genus 0.\nThe split is done using a plane defined by the line drawn by the user and a depth in the same direction as the camera facing forward\n(i.e. when we draw a line, we don't see the generated plane since it's perfectly aligned with the camera and the line)\n\n\n## Implementation\n\nFor each object tagged as *sliceable*:\n\n* We create 2 new meshes : a *positive* mesh, which is on the positive side of the slice plane, and a *negative* mesh, which is on the other side.\n\n* We go through each triangle of the mesh and, if it intersects the plane, we separate it into 3 triangles : 2 on the bigger side of the cut and 1 on the other side (we assume that it can't be cut perfectly in 2 triangles).  If the triangle doesn't intersect with the plane, we simply store it in its respective mesh (positive or negative). We also keep a list of the newly created vertices, which will all lie on the boundary of the meshes.\n\n* We then create new triangles to form the boundary face (the new face generated by the cut). There is currently 2 different ways of generating the boundary face (generating a center vertex, or creating triangles fans by iterating through sorted pairs of vertices), but both of them works mostly only for a convex polygon.\n\n* Finally we create new objects for the new meshes and push them apart by a small value (indicated by the *separation* property in the MouseSlice script)\n\n\n## Examples\n\nHere are a few examples of simple shapes being cut.\n\n| Cylinder  | Refractive Sphere  | Toonlit Suzanne  |\n|---|---|---|\n|  \u003cimg src=\"GIFs/Cylinder.gif\" width=\"250px\"\u003e | \u003cimg src=\"GIFs/Sphere.gif\" width=\"250px\"\u003e | \u003cimg src=\"GIFs/Suzanne.gif\" width=\"250px\"\u003e  |\n\nNote\n* The material used for the sphere is _GlassRefractive_ from Unity's Standard Assets\n* The material used for Suzanne monkey is _ToonLit_ from Unity's Standard Assets\n* Those materials are used in the project's scenes, but are not included in this repo. If you want to experiment with them, import the following folders from the Standard Assets:\n  * Effects/GlassRefraction\n  * Effects/ToonShading\n  * Prototyping/Materials\n  * Prototyping/Textures\n\n## Future work\n\nHere are some of the things that could be worked on or improved: \n\n* Use a new submesh to add a sliced surface so that we can set a separate material for it.\n\n* Smooth-shading on the sliced boundary is not preserved since we compute  \n\n* Handling cuts on manifold objects of genus 1 and above. This would mostly imply detecting the number of boundaries made by cutting the object and associating vertices with their respective boundaries;\n\n* Handling non-convex sliced polygons on the surface generated by the slice. The algorithm used right now works mostly for convex polygons. Using a better triangulation algorithm could help (e.g. ear-clipping triangulation);\n\n* Optimize the cutting algorithm. It could be interesting to treat triangles as part of a face, such that when we cut through a face, we could recompute triangles based on the face's shape so that we get an efficient number of triangles. This would also help generate better boundaries;\n\n* Using Unity's Job System to parallelize the cutting process (since the algorithm is relatively slow);\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoscurti%2Fmesh-cutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugoscurti%2Fmesh-cutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoscurti%2Fmesh-cutter/lists"}