Obtaining triangles (trimesh) from PhysicsNode

hi there!



short version: is there any way to get the array of triangles a PhysicsNode consists of?



long version: i’m willing to code an algorithm for navmesh generation ->  http://www.ai-blog.net/archives/000152.html

in order to achieve this, I need to access all the info about collidable volumes in the physics space. To be accurate, what I need is to access the triangles that conform those volumes.

Quite surprisingly, I can’t find a method that returns Triangle[] for any class in jmephysics2… For sure, someone must have implemented this already (not the nav mesh, but the getTriangles() )

Will I have to code this myself?

thanks in advance!

kraj0t said:

short version: is there any way to get the array of triangles a PhysicsNode consists of?

short answer: no

-ahem-



so, irrisor, could you shed some light on how I should be able to achieve this? there's got to be some place where Triangles are needed so that the physical volumes are built… where is that? I could work from that point and maybe rebuild the code of subclasses

The tris are obtained in the copyFrom (or similar) method in the trimesh physics collision geometry. But it is implemented differently for all implementations and cannot be overridden. So you hardly have any chance to get the data without modifying the API or restricting yourself to a specific implementation (namely ODE).

So your options are:

a) add a new method to the API of jME Physics 2 to obtain triangles from a pcg and implement it at least in the impl you are using (ODE I guess)

b) cast trimesh pcgs to their ODEJava-impl subclass and read triangles from native memory via ODE methods directly (which would be done in the implementing method for plan a)