Search Unity

mesh deformation to a shape ,how do i found that my mesh is deformed to a specific shape

Discussion in 'Scripting' started by ahmedarshadcoll, Jan 22, 2020.

?

mesh deformation to a shape ,how do i found that my mesh is deformed to a specific shape

  1. Quick

    2 vote(s)
    100.0%
  2. Quick help

    1 vote(s)
    50.0%
Multiple votes are allowed.
  1. ahmedarshadcoll

    ahmedarshadcoll

    Joined:
    Nov 11, 2019
    Posts:
    7
    i am doing mesh deformation in unity by hitting tool and on collision mesh has deformed to opposite to the direction of the force , now my deformation is working fine but i am getting problem is that , i have no exact idea on run time that either the mesh is deformed to the proper shape or not , how i get to know that , one method i had already tried was that , i put the same shape in the mesh and get that shapes vertices distance on collision hit.point and then calculate how much vertices are collided from the whole list of all vertices , but this method is not so effective , because on some points the inner shape have more detail and on some points it have less , when it collide on the detailed vertices then its progression jumped to the half of the total , like if i gave bottle as inner shape , and the bottle`s hap have 400 vertices and other entire bottle have 600 , total are 1000 , when it will collide to the bottle`s cap it gives 40% progress completed , but the bottle is just shown 5 or 10 % sorry for the english side , i`m not native english speaker , don`t i have delivered my exact point or not , i need help ,

    like this game Woodturning 3D by vodoo https://apps.apple.com/us/app/woodturning-3d/id1492451796
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    By definition geometric shape is a set of positions in space conforming to specific equation or set of equations. So check your mesh vertices to conform the equation for your shape and see how far it is form the required shape.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    if there are complicated shapes and forms,
    i'd probably try comparing pixels (from lower resolution correct shape vs user modified shape side view)

    as in here (could check if all black areas have wood under it, and areas outside black mask should not have have wood)
    upload_2020-1-22_11-44-21.png
     
  4. ahmedarshadcoll

    ahmedarshadcoll

    Joined:
    Nov 11, 2019
    Posts:
    7
    @mgear thank you so much for the reply but it`s in 3D not 2D then how i can check pixel wise.?
     
  5. ahmedarshadcoll

    ahmedarshadcoll

    Joined:
    Nov 11, 2019
    Posts:
    7
    @palex-nx i did not get the exact idea , can you please elaborate it , how i can i achieve it , in need progression also , like its 2 percent competed , or 10 % or 90 % and when it deform to the exact shape then it will have 100% and level completed ,
    i had tried it using mesh bounds but this method wasn`t usefull
    please guide me what equations i should use , as you said geometry shape it can be usefull but i need progression too , which can not achieve through this method
     
  6. erdincayaritu

    erdincayaritu

    Joined:
    Jan 7, 2020
    Posts:
    2
    Hello how can we compare the pixels, could u explain more pls?
    Thanks,
     
  7. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    from texture, you can get pixels into array https://docs.unity3d.com/ScriptReference/Texture2D.GetPixels32.html
    if both textures are same size, the correct answer "mask texture"
    and the current player made shape as texture,
    then loop over the pixels, check if mask pixel is, for example, black,
    then check the same pixel from the player texture, if it has wood color (or not transparent),
    then you get counter values for correct and wrong pixels.

    maybe other option would be to compare vertex positions,
    view from orthographic 2d side view,
    from correct answer mesh: check each vertex, if they overlap the player mesh behind.
     
    Last edited: Apr 4, 2020