Search Unity

Question How to create a grid of points on a complex mesh

Discussion in 'Scripting' started by Michelle_Ca, Feb 28, 2023.

  1. Michelle_Ca

    Michelle_Ca

    Joined:
    Aug 19, 2019
    Posts:
    113
    I have a mesh and i want to generate a list of Points on a mesh so that all points are placed on the surface of the mesh or very close to it,
    At the same time, the points should be at distance (X) from each other and this distance can be in range like ( X < 1 && X > 0.9f)
    These points will be used within an algorithm to find the shortest distance later to move objects on the mesh surface

    something like this:

     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,913
    Voxelization is your friend.

    If needed, you can take the resulting surface voxels and project them to the closest point in the mesh. This allows you to get them as close as you need to the actual geometry and orient them properly using mesh normals.
     
    Michelle_Ca and Kurt-Dekker like this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,656
    If you have a mesh then you want subdivision.

    There are many strategies for subdivision, each producing different results.

    If your mesh is irregularly spaced and you want regular spacing, you may need to remesh it as well, either before or possibly after subdividing it.

    Once you subdivide it you may even want to decimate it to fix it further.

    None of these functions are available in Unity.

    All of these functions are present in most 3D packages, such as Blender3D, and various algorithms for doing it can be found in various forms on the interwebs.
     
    Michelle_Ca likes this.
  4. Michelle_Ca

    Michelle_Ca

    Joined:
    Aug 19, 2019
    Posts:
    113
    Seems like a good idea to start with thank you!

    the mesh will be created processually during the game, so I need a solution inside Unity, thank you!
     
  5. aleksandrekazakhishvili

    aleksandrekazakhishvili

    Joined:
    Nov 2, 2020
    Posts:
    1