Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Split mesh in different parts

Discussion in 'Scripting' started by TTuPC, Apr 23, 2022.

  1. TTuPC

    TTuPC

    Joined:
    Mar 22, 2021
    Posts:
    36
    Hi!

    I've a very long mesh, and I want to slice this mesh in three differents parts, more precisely I want to cut this mesh certain values of Z and obtain three different gameObjects. How can I do?
    upload_2022-4-23_18-4-29.png
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    There's plenty of Google search results that do this kind of thing, did you try any of those?
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,757
    The general case for chopping up geometry is a process called Constructive Solid Geometry (CSG).

    Probuilder has an API for this but I haven't used it.

    Ideally you should chop it up in your modeling program first, then import the parts into Unity.
     
  4. TTuPC

    TTuPC

    Joined:
    Mar 22, 2021
    Posts:
    36
    I already seen but I can't find anything really useful.
    The idea is to take all the vertices after a given z and to create two different meshes, one with the vertices before the given z and one with the vertices after z. The problem is that I don't know how to take triangles of the selected vertices, do you have an idea?
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,757
    Yes, lots of ideas. It is super-easy to make triangles out of vertices in Unity. There is no easier engine for procedural geometry, IMNSHO.

    You can see a few dozen different examples in my MakeGeo project, ranging from a single triangle out to much more complicated stuff.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo