Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshCutter: Add inner faces. #4

Closed
wants to merge 33 commits into from
Closed

Conversation

gonnavis
Copy link
Contributor

@gonnavis gonnavis commented Mar 15, 2022

Fix: webaverse/app#2618
Demo: https://raw.githack.com/gonnavis/metaverse-utils/898006d9b6555ded898b0022e0022d4531a31e68/mesh-cut/test.html

Trying to add inner faces at cut plane:
image

Tried to think of solutions myself, such as line sweep points, but felt that there were various problems that could not be solved.
So searched and found the Delaunay triangulation algorithm, and found a repo https://github.com/mapbox/delaunator .

@gonnavis
Copy link
Contributor Author

gonnavis commented Mar 15, 2022

Successfully using delaunator to generate inner faces base on cut-edge points ( pointsInner ).
image
image

@gonnavis
Copy link
Contributor Author

gonnavis commented Mar 15, 2022

Added uv to inner faces.
Though the inner faces' uvs should be logically correct, but the result is not what wanted.
Such as these four points logically really all has uv (0.5, 0.5), but resulting the center area all sampled the white line pixel in the center of the image.
Need to try uv remapping or triplanar texture.
image

@gonnavis
Copy link
Contributor Author

gonnavis commented Mar 15, 2022

Though delaunator works very well on generate faces from points, but it can't know which triangles are outer of the original model alone, i.e., can only output Convex result.
image

So I tried to store linesInner and compare to generated lines to filter out outer triangles.
Done the first outer layer, need recur to filter out all.
image

---EDIT---
May use some existing Constrained Delaunay Triangulation solution:
https://www.mathworks.com/help/matlab/math/creating-and-editing-delaunay-triangulations.html
mapbox/delaunator#9
https://github.com/mapbox/earcut

@gonnavis
Copy link
Contributor Author

gonnavis commented Mar 15, 2022

Successfully filtered out outer triangles:
image
imageimage

Currently, still using the comparing-lines filter out method I came up with, works fine for non-cross geometries.
Todo:

  • ✔️Support arbitrary cutting plane ( currently only supporting generate inner faces of Z-axis cutting plane ) .
  • Performance: Prevent redundant codes.

May try existing Constrained Delaunay Triangulation solutions afterwards:
https://www.mathworks.com/help/matlab/math/creating-and-editing-delaunay-triangulations.html
mapbox/delaunator#9
https://github.com/mapbox/earcut

@gonnavis
Copy link
Contributor Author

gonnavis commented Mar 15, 2022

OK! Generate inner faces.
Demo: https://raw.githack.com/gonnavis/metaverse-utils/b01fa5ab6a3098c88b21dfa19b156ad2c8519c14/mesh-cut/test.html
image
image

Todo:

  • UV remapping.
  • Performance: Prevent redundant codes.

@gonnavis
Copy link
Contributor Author

This PR was originally written for the needs of Aray's OT project, but in the end Aray achieved the effect with 3D Voronoi, without using MeshCutter.

The functionality of this PR has been implemented so far, but many optimizations and tests are still needed. It can be reopened if necessary.

@gonnavis gonnavis closed this Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MeshCutter need to generate inner faces at cut plane.
1 participant