Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cutting mesh in realtime

Tags:

c#

unity3d

mesh

I want to slice a mesh object into at least five parts. I've done some research and some people on here have cloned objects when sliced and just instantiate two objects from a single slice?

I'm pretty new to Unity and C#. So any beginner tutorials on where to start or where I can read for learning how to cut mesh would be nice. Like what functions/methods should I be looking into? What methodology is behind cutting mesh?

From my understanding, I haven't seen any tutorial or asset that actually cuts triangular mesh? If there is, how is it done? What is the logic behind it? I guess I need help understanding the logic behind it and how to get started or what I should look into?

Cut mesh in realtime I mean.

EDIT:

Attempt at understanding and playing around with code:

I used the fake slicer 3.0 (http://unitycoder.com/blog/2011/08/09/fake-mesh-slicer-v3-0/) and included in the sample, they have a capsule that the slicer works on.

If I added a cube or another capsule with rigidbodies properties and collider property, the slicer (aka plane) only clones the object and doesn't slice it off. Why is that? How can I manipulate the code above to work for all kinds of objects?

I get this console error and I don't know what it means:

UnasssignedReferenceException: The variable cutplane of 'Slice_mesh3_js' has not been assigned. You probably need to assign the cutplane variable of the Slice_mesh3_js script in the inspector. 
like image 990
Kala J Avatar asked Oct 24 '13 18:10

Kala J


2 Answers

Have you tried the turbo slicer asset?

https://www.assetstore.unity3d.com/#/content/4169 There is a demo in their website.

There are ways to achieve what you want, however the noted asset could be the easiest one.

Worth looking assets for slicing, breaking apart:

  • Fracturing & Destruction https://www.assetstore.unity3d.com/#/content/9411
  • Shatter Toolkit https://www.assetstore.unity3d.com/#/content/1017

Also you can:

  1. Use your preferred modeling program and model the object in parts and with an animation slice the object as a result of certain action.
  2. Programmatically disappear the complete object and appear the slices using maybe a particle system to improve the effect.
like image 62
VicM Avatar answered Nov 06 '22 17:11

VicM


You can see new one here http://u3d.as/qSN This asset has very fast algorithms for 3D models and in comparison to its alternatives, it have much more clean code.

  • It supports asynchronous slice if you are not happy with speed. But my tests shows that it is not necessary, it is fast enough to do it in main loop.
  • It slices colliders converting them to MeshCollider-s.
  • And it is easy to customize.

enter image description here

like image 1
Stas BZ Avatar answered Nov 06 '22 16:11

Stas BZ