Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Make a cube grid along the mesh of the model, the size of them
- being inverse proportion of vertex density times a constant
- (resolution chosen by user)
- 0 < t < number of threads
- Choose t of the cubes, lock them as a in-use resource, assign them
- to a cube from the grid and project
- it to the mesh in a way that you get a single plane.
- In the first iteration the grid can be moved to match better the first
- created plane
- Now starts a loop that can be multithreaded:
- For every edge of the original mesh that intercepts the plane,
- get the vector of the edge, and record it.
- If two vertex have no direct path trough the plane:
- split the cube into smaller cubes, leaving the non-connected sub-groups
- in these smaller cubes, and leave those cubes for later iterations
- My approach would be to hash the xyz direction of the vector into a hashmap/array
- of 6 pre-defined groups (+x, -x, +y, -y, +z, -z) and make the
- arithmetic mean of the vectors that land in each position.
- Once done, for each non-connected edge of the final mesh's edges,
- check every neighbour voxel:
- If it already has a face:
- If the angle between the calculated vector and the ocupied face's closest
- edge is big enough (i guess greater than around -20º):
- extrude a new face
- If the angle is not too big (i guess less than around 20º):
- connect the adjacent edges
- Otherwise:
- If the distance between the edges is too small:
- merge them at center
- Otherwise:
- create a new face from the two edges
- Otherwise, if there is no face nearby:
- Extrude the face
- Once you have a face created:
- unlock the in-use cube
- lock the nearest cube
- assign the new created face to that nearest cube
Advertisement
Add Comment
Please, Sign In to add comment