Page 1 of 1

Get Triangle count as command

Posted: 19 Jun 2024, 12:05
by das
Hello,

I need the triangle count of a shape created by the mesh import function.
I want to do subsequent calculations with it. I have to expand exisiting lua scripts. Therefore, I need it as a lua command.
Manually it is easy to find: Scene Object Properties >> Geometry >> Mesh Info >> Triangle Count. But like I said, I need it as a command.

Thank you for your help.

Re: Get Triangle count as command

Posted: 19 Jun 2024, 14:37
by fferri
You can use sim.getShapeMesh and get the length of the returned indices array (which is 3 times the number of triangles).

In short: local numTriangles = #({sim.getShapeMesh(shapeHandle)})[2]//3

Re: Get Triangle count as command

Posted: 19 Jun 2024, 14:43
by das
Thanks for the fast reaction.