Split Mesh with decal?

I have a mesh topology (a google map) with the sattelite picture as a “decal” on the ground. The map is too big for Unity so I need to split it into smaller bits, but then the “ground” picture (the decal) is clipped and removed on one side of the cut.

What would be the simplest way to cut a 8 square km map into 8 or 80 smaller pieces while keeping the correct bit of the “decal” on each piece? (assuming that the full size decal picture cannot be projected onto the splitted multi-mesh)

// Rolf

When I split a mesh that has a decal on the decal stays on each part after using SplitMeshWithCurve.

Or is it not a decal, but just a texture with image in diffuse channel?

Yes, thanks, that seems (to be supposed) to work. Got less than optimal results though.

I guess there are conflicts with coincident vertices going on there. Will try to identify those with Grasshopper and perhap move any conflict lines…

// Rolf

Or orient the underlying grid with the image if you’re going to go split diagonally anyway?

I had the same problem with split misses in a first attempt in which the picture was aligned with the grid. It will be useful in Unity to have it oriented this way though.

// Rolf

I think there are some mesh splitting improvements in v7 WIP, @piac probably can tell.

Yes we are rewriting the mesh intersector from the ground up. Only _MeshIntersect is wired to the new code for the time being. _Split will probably come next.

Yes, I tried Split with WIP but got similar results, or perhaps “randomly” similar results as R6:

Fig 1. Split with WIP:

This bad behaviour doesn’t seem to depend on coincindent mesh vertices though, since I just tried to make a C# script in GH which checked Planes[i].ClosestPoint(mesh.Vertices[j]) for vertical (split) planes constructed with the pictured lines. No coincoindent vertices even within 0.1 mm was found when testing against these Planes :

private void RunScript(Mesh M, List<Plane> P, ref object M2, ref object Hits)
{
  var mesh = M.DuplicateMesh();
  var vertices = mesh.Vertices;
  var planes = P;
  var hits = 0;
  var tolerance = 0.1;
  for (int i = 0; i < planes.Count; i++)
  {
    for (int j = 2; j < mesh.Vertices.Count; j++)
    {
      var cp = planes[i].ClosestPoint(vertices[j]);
      var distance = cp.DistanceTo(vertices[j]);
      if (distance >= 0 && distance < tolerance)
      {
        var v = mesh.Vertices[j];
        v.X += 0.1f;
        v.Y += 0.1f;
        mesh.Vertices[j] = v;
        hits++;
      }
    }
  }
  
  M2 = mesh;
  Hits = hits;
}

Do you have any hints about what exact problem to look out for which is causing the failing splits?

// Rolf

Not for now, sorry. Only once the new code is wired in, I will be able to pinpoint the new bugs. The previous code is entirely replaced. Do you think you could send me the sample mesh?

WIP means work in progress. There is no guarantee right now that this work will ship with V7. It’s a long-term goal to switch to more robust intersection code.

@RIL, @piac, @nathanletwory,

I split my difficult meshes with the attached Python script. It asks you to input a closed curve which is then used to split the mesh. Or you can create some closed curves ahead of time and then Select those curves to split the mesh.

This script splits all my meshes in cases where Rhino fails. The script also supports trimming the mesh, making a hole it in or shifting the mesh inside the boundary curve. You can have dozens of non-overlapping closed curves to define where the operation (trim, hole, pit, split) takes place.

The script is mostly finished but still needs some documentation cleanup. Also the DLL for speeding up mesh volume calculation is not included here (the program will automatically run without the DLL).

Regards,
Terry.


TrimMeshMultipleCurves.py (233.0 KB)

Thank you Terry for chiming in.

In my case I have only straight lines (115 lines) which I use to split the mesh into smaller squares.

// Rolf

I will think about how to modify the script for your case. You can still use it to do what you want but it will take many steps:
(1) Do horizontal splitting with multiple rectangles that replace the horizontal straight lines. All the splits can be done at one time.
(2) Take each split mesh on layers Split One and Split Two one at a time and move it to layer Start Mesh. Then split with vertical rectangles that replace the vertical straight lines.
(3) Repeat

I would appreciate it if you could try step 1 in order to provide me with some feedback on the script. Are you on a Windows or Mac system? If on Mac, does the form look like above?

Regards,
Terry.

Hi again @Terry_Chappell,
I generated two sets of split lines (one set shown in the picture below) but I can’t select any closed curves (when I click or window select then nothing is selected) and I see only a button “Done”, which feels a little early to click at this point :slight_smile: ).

1 mesh found with 587,423 faces, 499,866 vertices, 0 vertex colors and 499,866 
texture coordinates. It has been moved to layer Start Mesh.

The script found a mesh without me hinting which mesh to split. That was a bit scary, so I tried to lock all meshes but it still moved one of them… Anyway, since I could not select any split lines I can’t proceed.

I’m using Windows.

// Rolf

Rolf,

When the script is started, it allows only 1 visible mesh to be present. If this is the case, then it moves this mesh to the Start Mesh layer so the mesh cannot get damaged. Any operations on the mesh are stored on new layers, like Trimmed, or Split One, Split Two, etc. The Start Mesh is never changed by the script. Here is an example of splitting a mesh with horizontal closed curves that I arrayed over the mesh.

The starting mesh with closed curves for splitting:
Before%20Split
The mesh after splitting:
SplitOneTwo
The mesh on layer Split One:
Split%20One
The mesh on layer Split Two:
Split%20One

The script only accepts closed curves at this point. Not lines. Once the curves are selected, you push the Trim Mesh button (which is labeled incorrectly as it should say Split Mesh. I will fix this in the script). Then the mesh is split and the pieces are put on layers Split One (for the main part of the mesh outside the curve) and Split Two (for the part of the mesh inside the closed curve).

What is the final shape you are trying to achieve? The lines you showed would create narrow strips if done by Rhino’s Mesh Tools -> Split Mesh. Is this what you want?

I am also very interested in how the decal behaves when you split the mesh with this script. Can you try selecting Enter, press the Trim Mesh button and then draw a closed curve over the mesh when prompted to see what happens to the decal on the split pieces? After the split, the entire mesh will still be displayed because the two layers with the split pieces have been turned on (Split One and Split Two). The Start Mesh layer has been turned off.

The script has tooltips for most buttons. Just hover the cursor over a field on the form for a sec to see information about the field.

Regards,
Terry.

[quote=“Terry_Chappell, post:14, topic:82591”]
Once the curves are selected, …[/quote]
Unfortunately I can’t select anu of the closed curves (when I click on them while the dialog is open the mouse picks on stone - no selection is made)

I have two sets of these curves. The other set is meant to cut the strips into (quadratic) squares. Yes, I only want smaller squares, like when I tried splitting with Rhino which is shown in earlier posts in this thread.

Hm. Now I noticed that I can pre-select both the mesh and the curves BEFORE I start the script. But Rhino crashes when I press “Trim Mesh”.

As shown here, I have two sets of closed curves. I would first slice the mesh one way, and then the other way.

If Rhino doesn’t crash todally I get this error message when pressing Trim Mesh:
bild

It seems it has a problem with the Picture.

// Rolf

I can fix this. My system has the pictures so I did not see this problem. Give me a few minutes.

I fixed the Picture problem and the Trim Mesh button not saying Split Mesh. The new script has been updated in my first post to this thread.

To use the script the order of operations is:
Chose settings on form:

Operation
Trim, Hole, Pit, or Split
BoundaryCurve
Enter, Select or Reuse (this option only shows if a curve is on layer Corners)

Then press the Split Mesh button.
If Enter was selected, you will be prompted to enter one closed curve.
If Select was selected, you will be prompted to select closed curves in the document.
If Reuse was selected, the existing curves on layer Corners will be used.
After this step is complete, the mesh will be split.

One way to avoid having to select multiple curves is to put them on layer Corners ahead of the time.
Then when you bring up the form, the Reuse option will appear and you can select that before you press the Split Mesh button.

I think I now understand the shapes you are trying to achieve from your previous posts. You want to make hundreds of tiny squares from the mesh. You want a piece of the mesh inside each of the green squares, right? I am thinking about how to do this with the script. Half of the splitting you can do already by putting an array of rectangular closed curves on layer Corners that are the width of a square side and long enough to pass completely over the mesh. This is what I showed in my example above. The rectangles do not touch or overlap. The space between them is the same as their width.

For the second half of the spltting, you could rotate the closed curves on the corners layer and then use those to split the mesh again after I modify the script to loop thru all the meshes. I will work on this if you would like to give it a try.

I really appreciate you trying out my new script. It is hard for me to figure out what improvements are needed to make it easy for others to use and has enough functionality to be useful. So your feedback is really helpful here. I wrote it because I cannot get Rhino to trim or split my larger meshes without errors. And when it works, which it does 99% of the time for my meshes, it is much faster.

Regards,
Terry.

Yes.

Yup, this is what the rectangles in the picture are for. Two sets, one set for Splitting horizontally, and one set for vertical Splits of the slices.

True. This is why I made two sets to be used separately in batch (so they don’t cross over each other).

No need for that. The second set (dark curves) of curves takes care of the other direction as shown in the picture :
bild

// Rolf

Oh I just figured out the last piece of this puzzle for me. The funny angled shaped under the lower intersection of the 2 sets of curves is the mesh.

Do not make the closed curves the way you show for this script as I do not think they will work. Do this instead:


It works on my mesh when I select just the vertical rectangles:

Can you try this out for one of the directions on your mesh to see if it works?

Regards,
Terry.

Yes, I will. But I did as you told me - I made “closed curves”. :wink:

But OK, now I will try “closed curves that leaves the mesh and comes back in again -kindof curves”

// Rolf