< Back to IRCAM Forum

How to read 3D mesh files in Modalys for Max

Hi, I’m new to both of those software so I’m still clueless to most features here, and I’m using Windows so it’s just Max and I don’t have ModaLisp. In what directory should I place the mesh file? How do I properly read that .mesh/.msh file without error? Is the read-from-file object treated as a resonator? Does it have to be a hexahedral mesh, or can it be triangular? Last, how do the position settings work here?
Attached is the test file I’m trying to read (triangular mesh) agong.mesh (342.9 KB)

Hello,

Your triangular polygon “agong.mesh” does not work in ModaLisp.

— The location of the mesh file should specified with a path within the mlys or maxpat file. The easiest would just put everything into the same folder.
— The extension could indeed be .mesh, .msh, .data or whatever you want at the condition it is not a binary mesh. Modalys does not take STL files.
— Modalys very unfortunately does NOT work with triangular meshes; but rather hexahedral ones. You then need to remesh it using another software. That process is not so easy and I did not find any simple software doing that.
If you know something easy running under MacOS… I could not find out if MeshLab or Gmsh were doing it. I am using Rhino for now but, unless you are doing other stuff with it, it is a bit cumbersome for such a direct conversion.

O.

Thanks for the reply! So you use Rhino to convert to hexahedral mesh? I’ll look around for software and try to work on making a hexahedral mesh first, then I’ll update afterwards. For the file path, what is the syntax? Is the file path and name typed after the “read from file” object?

Hi,

So you use Rhino to convert to hexahedral mesh?

I am using it for other means so I indeed also use it for hexahedral meshing.
But I am also looking for a quick workflow and therefore a way to re-mesh from triangular polygons to hexahedral ones.

For the file path, what is the syntax? Is the file path and name typed after the “read from file” object?

You can simply use the filepath syntax from your system…

For instance, if you wanna import a mesh from MacOS in a Modalys LISP file:
(setq diapason (make-mesh 'read-from-file "/my/path/mymesh.mesh"))

Or from Max’s Mlys on MacOS:
Object = make_object('read-from-file','/my/path/mymesh.mesh')

Or, on MacOS, within the ‘mlys.read-from-file’ Max object argument:
mlys.read-from-file 1 2 @name Object @filename /my/path/mymesh.mesh

I guess I was able to get Max to read the file, but now it says “ERROR: bad ModalObject data in file”. This was with a hexahedral mesh I was able to make with gmsh, unless I did that wrong. I used this tutorial (7:10 onwards) https://www.youtube.com/watch?v=U5GCClyaxWo
-Imported a STEP file
-Went to tools > options > mesh > general
-MeshAdapt for 2D algorithm, MMG3D for 3d algo
-All hexas subdivision algorithm

Hi, I’m also an enthousiast Rhino user who’s looking for the right method to import my mesh into modalys and generate a modal file from it.

This way I could load it in max and play in real time using the mlys.read-from-file object

I’ve quandrangulate my Mesh then exported to .obj, but I can’t find a way to convert the file into .mesh format either with blender or meshlab…
any updates on this ?
thanks for your help !

Hello !

Sorry for my late answer !! :wink:

— You can indeed quadrangulate some meshes using… “quadrangulate” in Grasshopper for instance. This does not always work well though.
Rhino 7 now allows the creation of quad meshes from surfaces, solids, meshes, or SubDs (!!) and works better for complex forms.
— After Baking with Grasshopper, I personally export that Rhino mesh as a STL file and convert into a .mesh (INRIA mEdit file) file using the lovely Gmsh (https://gmsh.info).
— However, these are quad meshes and not hexa… So this is probably not working for ModaLisp ? Any “ERROR: bad ModalObject data in file” message ?

I cannot wait having a cool and easy FEM sound generator in Rhino and my little finger tells me there is going to be an experimental one soon. :wink:

O.

1 Like

Hello,

Couldn’t any among MeshLab’s many remeshing modes function for this purpose?

Thanks a lot ! Just saw Rhino 7 includes the Mesh Quadrangulate command and that Modalys 3.6 now support .obj files ! Light at the end of the tunnel ? :grinning:

Please feel free to share .obj meshes made with Rhino7. That’s going to be interesting for testing.
And by the way, Modays 3.6 will be published later today :wink:
Robert
Update: I am including a .obj import example in 3.6…

Hello,

I’ve tried without success to replace the .obj file from the example with some .STLs made in Openscad then converted to quadrangular mesh and exported as .obj files from MeshLab. In each case I get a “not enough arguments” error message.

If anyone knows how to proceed from the aforementioned program, Blender or Gmsh, it would be nice to share the information.

By the way, I’ve noticed that Gmsh can export files as .mesh. Could this file format be of any use in Mlys?

Hi rbaudoux!

The best, as always, is to post questionable files! (patch, .obj etc.)

And .mesh files right out of Gmsh should work, too.

Robert

Hi Robert,

Actually I have taken the Lua cymbal3d example and only replaced the name of the .obj file. I am going to check again and post some files here indeed.

So, I’ve designed a simple volume in Openscad and saved it as an .stl.

Then, I’ve opened it in MeshMixer, subdivided the mesh several times and converted it to quads and finally exported the mesh as an .obj file.
I’ve applied a similar procedure in Blender, with a different result.

Then I’ve tried to use both files in the “3d “.obj” patate with mlys.lua” example. But both produce similar error messages:

*** ERROR: could not read mesh from file ‘cube_blender_quads.obj’


*** ERROR: could not create the mesh


*** ERROR: too few arguments


*** ERROR: invalid argument type for function


*** ERROR: expected a mesh


cube_blender_quads.obj (15.0 KB) cube_meshmixer_quads_2.obj (77.1 KB)

Hi rbaudoux,

You can’t just replace file and expect it work! :smiling_imp: Care has to be given to actual:

  • holding points (boundary conditions)
  • input (=hitting) points
  • output (=listening) points

Attached is the modified patate example. Just place your cube_blender_quads.obj file next to it in a folder.

A few additional comments:

  • You object is quite enormous (10 meters high!..) For what it is worth, there is a scale parameter when exporting as .obj from Blender. You could also use the function modalys.transform_mesh{method="homothety", center={x,y,z}, scale=0.2} afterwards.
  • You object is topologically closed (homeomorphic to a sphere). This is fine but keep in mind that it doesn’t make it solid, it is just a very large and very thin box!
  • The other .obj file (cube_meshmixer_quads_2.obj) is not well formed for physics; it has some funky edges etc. Looks like MeshMixer really “mixes” it up…

I hope this helps,
Robert
lua_from_obj_file_1.maxpat (70.2 KB)

Hello Robert,

Thanks a lot, now I can really go forward!

Actually the object was only 10mm high, I don’t know where in the process millimeters were changed into meters.

I am aware of that. Does Modalys accept solid shapes? Would they sound better?

MeshMixer has many algorithms to tweak meshes, and some with many parameters. Maybe it will be of some interest later…

That’s weird because now I have the same error messages but followed a confirmation of the initialization…

*** ERROR: could not read mesh from file ‘cube_blender_quads.obj’


*** ERROR: could not create the mesh


*** ERROR: too few arguments


*** ERROR: invalid argument type for function


*** ERROR: expected a mesh


! mlys.lua - nil mesh with “modalys.create_object” and “finite-element”
initialized!

Also, if I try to trigger the model, I have another error message.

*** ERROR: Bad controller reference!


Please attach your files (.obj+patch). I am not psychic enough to guess your changes! :mage:
Robert

Actually I haven’t changed anything! :teddy_bear:

With the very same files that I sent?.. That is odd.
Which exact version of Modalys are you actually using?
Robert