Spatial/RigidBody Surface Area/Volume Calculations

So I’ve already got some code to do some of this from an old project, and I’ll be implementing it regardless of whether it exists already or not, but I figured I’d ask if there’s any way to do this already built into jmonkey.

I’d like to be able to call a function to calculate the surface area and volume of a Spatial or RigidBody (or rather, I suppose, the mesh from either). It’s not that hard to do, and once it’s done, you can just store the float (as the initial calculation is a bit cumbersome to do frequently). Also, with some information about the material density and how much of the volume is filled (either an approximation via a thickness of the surface times the surface area, or a % of the contents being filled) one could easily get a nice accurate mass.

So, does any of that functionality already exist, and if not, would people like me to release the code I end up with that calculates such information?

I dunno if functionality already exists. Are you gonna find the area of each triangle (0.5 * A * B * sin ©) in the mesh and add them together?

And yes the volume would have to be an approximation

There are already several different algorithms for that but not in jme3 (from my knowledge). I’m using different approaches by myself. Raycasting, Analytical,…

EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION

Fast GPU computation of themass properties of a general shape and its application to buoyancy simulation

I would be interested to see your approaches and how they perform.

There are already several different algorithms for that but not in jme3 (from my knowledge). I'm using different approaches by myself. Raycasting, Analytical,...

EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION

Fast GPU computation of themass properties of a general shape and its application to buoyancy simulation

I would be interested to see your approaches and how they perform.

Interesting stuff.
I guess performance would be the main issue, but if it mostly only occurs in the init methods (and maybe if the object gets damaged to the extent that some of the material is ablated or punctured in which case I'd do something with the thickness parameter) then there's not really a problem.
@wezrule said:
I dunno if functionality already exists. Are you gonna find the area of each triangle (0.5 * A * B * sin (C)) in the mesh and add them together?

And yes the volume would have to be an approximation

Because most of my objects are procedurally generated from cross sections, it would actually not be hard for me to make the volume pretty exact. Once I start making methods to combine objects (getting rid of the intersecting points and smoothing out seams) then it will become difficult to get exact volume again. Luckily, since most of the complicated objects in my game will probably be spaceship hulls, surface area * thickness is a pretty good approximation.