Search Unity

Real Time Mesh Slicing Demo

Discussion in 'Works In Progress - Archive' started by ZAxisTechnology, Sep 24, 2015.

  1. ZAxisTechnology

    ZAxisTechnology

    Joined:
    Sep 12, 2014
    Posts:
    68
    Hey guys, Ive been working on an algorithm to allow slicing of a mesh about a plane in real time. So far Ive got it working on (locally) convex meshes while preserving the UVs of each sliced piece. The normals get messed up so the mesh becomes flat shaded but other than that its working fairly quickly. Ive tested it on meshes with about 1K triangles and it runs in about 0.1 seconds. It still needs some work as slicing the same object multiple times occasionally produces weird results so Im looking for any other programmers who are interested to help out and hopefully produce a robust free asset. I cooked up a simple webplayer demo which is essentially a 3D fruit ninja:
    Objects are shot towards you and you can cut them as many times as you can at any angle you want with the provided katana. I would love to hear any feedback and if you are interested in contributing, post here or message me and I can provide you with the source code/unity package!

    WebPlayer Demo Link:
    https://googledrive.com/host/0B8tMCDVu_lmuWWVzTk1FN21BMlk/Slicing_Demo.html

    PS: This is my first time building to the webplayer so i dont think itll work on Chrome.
     
    dibdab, imtrobin and mgear like this.
  2. mohoyoyo

    mohoyoyo

    Joined:
    Apr 14, 2015
    Posts:
    9
    I saw you in another post saying that you were going to share the code with the comunity in order to improve it. Where is it?
    Sadly Chrome doesnt give support anymore, but it works perfectly in Firefox and Internet Explorer.
    Thanks a lot,
    regards
     
  3. ZAxisTechnology

    ZAxisTechnology

    Joined:
    Sep 12, 2014
    Posts:
    68
    If youre interested in contributing just send me a message and ill export a package for you!
    I didnt get many/any replies on these threads so I wasnt sure people were interested. If you are please shoot me a PM and well coordinate
     
    toudji likes this.
  4. Tactical_Beard

    Tactical_Beard

    Joined:
    May 20, 2014
    Posts:
    9
    I found this working script, it's not as suave as your sword ;) but it might help you get the normals right.

    Script link
    http://blinded-am-me.tumblr.com/post/129013886863/simple-mesh-cutting-script-i-made-one-line-call
    Line 172 “right side” needs to be "right side".

    Calling his function.
    Code (CSharp):
    1. public Material capMaterial;
    2.    public GameObject Cutter;
    3. public GameObject ObjectToBeCut;
    4.    GameObject[] pieces = MeshCut.Cut(ObjectToBeCut, Cutter.transform.position, transform.right, capMaterial);
    5.     if (!pieces[1].GetComponent<Rigidbody>()) { pieces[1].GetComponent<Rigidbody>(); Destroy(pieces[1], 1); }//destroys rightside piece
     
    RavenOfCode likes this.
  5. tkamruzzaman

    tkamruzzaman

    Joined:
    Jun 28, 2015
    Posts:
    8
    It's creating way too much garbage after 5-6 slice. Good for demo, not for real use. Screenshot_3.png
     
    manpower13 likes this.
  6. zoorrax

    zoorrax

    Joined:
    Mar 28, 2017
    Posts:
    1
    it didnt worked for me. #tactical beard i downloaded your code from github. and it's not showing any error.
     
  7. janiIkram

    janiIkram

    Joined:
    Sep 22, 2018
    Posts:
    1
    the link is down it's not working