Comments and answers for "Double-sided cross section ("slice")"
http://answers.unity.com/questions/935375/double-sided-cross-section-slice.html
The latest comments and answers for the question "Double-sided cross section ("slice")"Comment by Glurth
http://answers.unity.com/comments/936340/view.html
One option is to create a new mesh, dynamically, based upon your original mesh and the two clipping planes.
As you mentioned there are no Boolean operators for solids, so you will need to do it manually. This is obviously not a trivial algorithm, as Sunny mentioned, and getting it fast enough for runtime use can be hard.
Two possible ways I would do this:
For each vertex in the mesh, determine if it lies between the two planes (in model space). If so, include it in the final mesh. This would be fine, if we didn't care what the edge of the mesh looked like.
The trickier part will be triangles of the original mesh that cross a plane boundary. I would do this part by checking each EDGE (any line segment between two vertices) of each triangle:
if all triangle verticies lies between the two planes, keep the verticies, AND the triangle.
but if one vertex lies between the planes, and the other does not, we need to compute WHERE the plane intersects the edge.
Once you have the intersection (see link below) you can create a new vertex at that point. Don't forget you will need to recreate the edge triangles: any triangles the planes intersect, with two vertices inside, will need to become TWO triangles (since a truncated triangle is a quad.) Also note that any triangle that intersects the plane will have TWO edges that intersect the plane (except in rare cases- where a triangle edge lies on the plane exactly).
So lets say you have triangle ABC, and the plane intersects AB and AC at D and E respectively.
If A is between the planes: our new triangle will be ADE (B and C are replaced with the two new intersection)
If B and C lie between the planes: our two new triangles will be DBC and EBC ( A is replaced with the two new intersections
Edit: Closing the remaining two open sides can be complex or simple depending on if your shapes are concave or not. If not concave, using one vertex as a base, create a triangle to every other vertex(peacock-style). (here I'm referring to vertices your created in the previous part, that lie exactly on a plane.)
This is one of my favorite wiki posts, I think it will have all the line/plane and other math functions you need to do the above.
http://wiki.unity3d.com/index.php/3d_Math_functionsMon, 30 Mar 2015 17:37:17 GMTGlurthComment by AlwaysSunny
http://answers.unity.com/comments/936279/view.html
I'm not familiar enough with shader lore to guarantee that this cannot be done on the GPU, but I've never seen the effect before AFAIK.
Unless I'm badly mistaken, any solution is going to be non-trivial, involving a per-frame (if rot/scale/z-pos change), per-mesh boolean operation.Mon, 30 Mar 2015 16:24:36 GMTAlwaysSunnyComment by Adizx
http://answers.unity.com/comments/935852/view.html
I've also thought about using that vertices on the edges we have after clipping (maybe z-coordinate comparison and adding to array?) and bulding face from them - but I can't imagine how they should be connected, because shapes may be very complex (and thus order of them).
Hope any veteran would clarify this a bit more ;)Mon, 30 Mar 2015 07:16:12 GMTAdizxComment by AlwaysSunny
http://answers.unity.com/comments/935776/view.html
Nothing I'm aware of, shy of coding your own boolean operations. Wouldn't envy that task. This is an interesting question though.Mon, 30 Mar 2015 03:23:53 GMTAlwaysSunny