- Home /
How might I measure the total area of a mesh during displacement?
I'm displacing/warping/stretching a cloth component with a sphere collider, and in doing so I'm stretching the distance between vertices.
Is there a way I can measure the total area (or sum of the line lengths) of the mesh at each timestep, which would be correspondent to the amount of stretching?
I'm sure it involves some math on Mesh.vertices. Would it be too expensive to add up all the distances between every set of adjacent vertices?
How might I calculate the total area from $$anonymous$$esh.triangles?
Answer by Serinx · Apr 22, 2018 at 09:29 PM
Hello,
I had a look on google and found these answers on StackOverflow. You might need to retrofit them for Unity but they should give you what you want.
To calculate the area: https://stackoverflow.com/questions/26312570/calculate-surface-area-of-a-3d-mesh
To calculate the volume: https://stackoverflow.com/questions/1406029/how-to-calculate-the-volume-of-a-3d-mesh-object-the-surface-of-which-is-made-up
As for performance, that depends on the number of vertices but I can't imagine it being super expensive.
Your answer
Follow this Question
Related Questions
How to return mesh of interactive cloth? 0 Answers
Skinned Cloth Editor Crashs 1 Answer
Textures help 0 Answers
Null Reference Exception Assigning Vertices to Mesh 0 Answers