Divide a polygon across points with matching attributes

   1062   0   0
User Avatar
Member
11 posts
Joined: July 2014
Offline
I'm trying to make a system that reads in an arbitrary mesh and creates an alternating pattern of interlocking bricks on each vertical edge greater than 45 degrees. The bricks should ideally not overlap, and be as close as possible to one unit tall, two units wide, and one unit deep as the geometry allows. The bricks only actually need to be precise along the edges; internal bricks are more haphazard and will be handled separately. My priorities are, in order of most to least important, making sure each brick is geometrically sensible (faces are roughly rectangular and meet each other across the edge), making sure bricks do not overlap, making sure that each brick on a given edge is the same height, making sure that nearby edges' bricks mostly line up, and making sure each brick is the proper dimensions.

The best method I've come up with so far is to try to divide each vertical face into horizontal bands in a very deterministic way, so that the vertical edges of each band are divided evenly. Each division should encompass only points whose positions' heights round the the same integer, but the entire cut across a face won't necessarily be planar. For example, if someone feeds in a model shaped like an extruded letter U with one side slightly higher than the other side, the bricks in each side shouldn't start matching each other in height until they get closer to their meeting point at the bottom.

The way I'm trying to do this is to loop over each edge of the vertical faces, take the rounded Y value of the points' positions at each end, and then resample the edge to have a number of segments equal to the difference between them (edges smaller than a unit tall are ignored, which is fine). Then, hypothetically, I just need to cut the shape across all of the points whose y values round to the same thing. I'm just not sure how to do that last part, but I got as far as giving each point an attribute that equals its position's rounded y value. I'm also not 100% sure that's the best way to go about solving this.

The only thing I can really assume about a model being read in is that the individual faces will be easy to define. I won't have any creases over 45 degrees that start or end in the middle of an intended face without making a closed shape, and I shouldn't have any faces that overlap (though the model won't necessarily be watertight). One problematic case in particular that I foresee coming up a lot is a vertical cylinder with a box attached to the side, like a wall meeting a circular tower. The meeting point is an edge over 45 degrees, so it should get the brick border, but none of the other edges around the cylinder qualify. However, you have to completely circumnavigate the cylinder to find the connection point; if you take a point on the left edge, its corresponding point on the right edge is to the left of it.

Here's where I'm at so far:
-I have separated out the faces that are mostly horizontal and removed them.
-Each vertical face is separated.
-The edges of the vertical faces that bordered an upward-facing poly are in one group, those that bordered a downward-facing poly are in another group, and the ones that bordered another vertical face are in a third group.
-Looping through each face, I have a NURBS curve that follows each vertical edge. These nurbs curves have one and only one point per height “bucket”. That is, if you round each point's y position to the nearest integer, you will get unique results for each curve point. Left and right edge curves are in different groups. The normals of each point of the curves on a left edge point to the right on the polygon; normals on the points making up right edges point to the left. There are an equal number of right-facing points and left-facing points whose position's heights round to each integer. I just need to figure out how to turn each of those into a cutting plane that only reaches from point A to point B.

I had a prior solution where I just stuck a 4-unit-long box facing left on each right point, and facing right on each left point. All the points inside of those merged boxes got put in a group and removed. The remaining points got sorted by height per edge and separated into evens and odds. Left evens and right odds got a 2x1 rectangle, right evens and left odds got a 1x1 square. Left evens and right evens get fused, along with left and right odds. That worked beautifully for the parts that weren't narrow. For the rest, I made a rectangle from what remained on each face, chopped it into approximately 1-unit-high chunks, sorted those by height. Evens got chopped one third from the right edge, and odds got chopped one third from the left. Then I took all of those and tried to snap them to each other, and to the result from the non-narrow parts. I could never really get things to line up, unfortunately. The fracture brick faces were too misaligned to snap to each other properly, without turning the snap tolerance up so high the other bricks started going wonky.
Edited by EllyFish - Jan. 19, 2018 04:58:02
  • Quick Links