Search Unity

Mesh - Extraction

Discussion in 'Scripting' started by josephsaade, Sep 23, 2019.

  1. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
    Trying to find a way to implement something like "Drawing in sand" or "Peeling". Basically reconstructing geometry from a mesh into a sub mesh based on user clicks.

    My first naive implementation seems very slow, any ideas?
     
    Last edited: Sep 26, 2019
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    768
    From the images i assume they are not actually modifying the mesh, but simply changing the textures and then creating another object that looks like the peeled outer layer, depending on the peel progress. So to reproduce it i would divide it into two steps to look into.
    1.) Changing the texture / uvs for some area on the mesh, which you can then do for where the player peeled the fruit.
    2.) Depends on how accurately you want to fake the peeled layer object. The easiest way would probably be to create some variety of peeled objects and then make them partly visible using a shader (as well as rotating them accordingly) to look like it was peeled off the fruit.

    There is probably a thousand ways to do this, depending on the performance and accuracy requirements, as well as the complexity you can handle to implement.
     
    Kurt-Dekker likes this.
  3. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
    Thanks for the reply. I think you need to play it.

    I tried DepthMasking (but I am sure this is not what they are using). I am not sure I can change uv textures to make them transparent (where the user cuts). But I used RayCast to find triangleIndex and I would be able to cut a circle (or just one triangle for now) but this means that each model contains a huge number of tris.
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,853
    i'd probably try using high resolution mesh,
    then player would paint into that texture,
    and that texture would used as a vertex offset to push vertices back,
    and maybe also as a color mask to reveal the inner fruit texture..

    some video here from that game
     
  5. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
  6. josephsaade

    josephsaade

    Joined:
    Apr 18, 2016
    Posts:
    46
    Just watched


    Basically it is done with polygon subs-traction and recalculating colliders. So they are actually removing polygons like I was initially trying.
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    4,968
    Hey you shouldn't as a general rule be removing posts wholesale. It sorta ruins the entire history of the thread. This forum and "Answers" are a growing body of mostly-useful Unity lore, indexed by the most powerful search engines in the world, and also by Bing.

    Edit it, refresh it, but don't destroy it unless you truly posted something dangerous, private, inappropriate, etc. And usually in those last cases, a Mod will zap your post anyway.
     
  8. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    768
    This, sir, was hilarious.

    But jeah, why remove it? Are you one of those "now that i have my answers, i dont want others to have it easy" kind of people? We've had another one recently who just went along and deleted all his posts after he got an answer.

    So if you can, please try to reconstruct your original post for those to come. It's an interresting topic and if you looked for your answers and found a post discussing it, you wouldnt have wanted the OP to delete his question either, would you? As mentioned by Kurt, there are definitely reasons to delete a post, but other than those it's kinda just unfair for everybody who comes in the future with the same question.
     
    Olmi and Kurt-Dekker like this.
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,207
    Don't remove posts that have replies (or significantly alter them so the replies don't make sense).

    --Eric
     
    Kurt-Dekker likes this.
  10. chinhlv321

    chinhlv321

    Joined:
    Oct 27, 2019
    Posts:
    1
    see this video :
     
  11. unity_noZ0_6W70KHj0A

    unity_noZ0_6W70KHj0A

    Joined:
    Jul 25, 2019
    Posts:
    1
    Can anybody give any idea, how to achieve peeling as I Peel Good ?
     
unityunity