Happy Friday!! I have a problem that I am unsure about how to proceed. I am using a line renderer to draw lines on a wall. After the lines are drawn I collect all the points and create a mesh from the points. The issue is that I only want to create a mesh if the collection of verts make up an enclosed shape.
Does anyone have any tis on how I could approach this?
can user draw any kind of complex shapes and in 3d also?
as in, easy: if can only create 4 points on that flat wall surface.
difficult: create any shapes & forms in full 3d with unlimited points
1 and 3 are closed shapes but have positive and negative area while 2 is not closed, but does enclose an area. Just the fact that a polygon is closed, does not necessarily mean it’s a “nice” shape.
So if you have already the ordered poly-line data, it depends on what kind of shapes you want to detect. What if the drawn and closed polyline encloses more than one area like on figure 1 and 3?
Getting clean results is kinda tricky. Though it depends on what kind of shapes you want allow. Only convex shapes or also concave? All of my examples are convex. The shapes mgear has drawn are also concave (except the cube like). So it depends on what behaviour you want, in which cases it should refuse a shape and what conditions should apply.
Some time ago someone asked about detecting shapes in an image and I wrote a quite simple shape detection algorithm. Since you already have the polyline that’s probably irrelevant. Though it may give you some ideas? Detecting intersections between lines is not that hard, however the question is what do you do, if there are intersections? If your shapes are drawn by a free-hand tool, the first step would be to simplify and reduce the number of edges where possible to avoid too narrow corner cases.
It’s still not clear if this is a pure 2d question or if you plan to create a 3d object out of your polyline. Though painting in 3d isn’t really a thing.
When we talk about drawing shapes I always have to think about games like max and the magic marker which was made with Unity btw. It would help if you can give more details what you actually want to do and what you need those shapes for.
To detect shapes. Collect shape data and analyse the patterns
does it contain an intersect? No, but does it contain more verts nearer to its Center of origin than it does nearer its extents? Yes. Well it must have a complex interior structure that doesn’t intersect
Show diagrams of the type of results you want collected
After watching the video I notice that on click they place a polygon shape and then as they draw, they create a new one and combine shapes that overlap. Maybe after combining the overlapped shapes they do an additional pass that creates a single shape out of all the points which closes any holes.
Anyone have any insight that could help keep me from going down a rabbit hole?
I notice that on click they place a polygon shape and then as they draw, they create a new one and combine shapes that overlap. Maybe after combining the overlapped shapes they do an additional pass that creates a single shape out of all the points which closes any holes.
it looks like there is grid there,
and then just floodfill the areas… and maybe like 2d marching squares?
(although could just create mesh from those flood filler areas too)