meshlabvrml

How to import VRML 2.0 on Meshlab


The file I'm trying to import this VRML file on Meshlab:

#VRML 2.0 utf-8
PROTO my_sphere [ exposedField SFFVec3f xyz 0 0 0 ] {
    Transform {
        translation IS xyz
        children [
            Shape {
                appearance Appearance { material Material { 
diffuseColor 1.0 0.05 0.05 } }
                geometry Sphere { radius 0.66 }
            }
        ]
    }
}
my_sphere { xyz 0.0 0.0 0.119 } # 0
my_sphere { xyz 0.0 0.0 0.119 } # 1

I'm getting the error:

Error encountered while loading file:
"/my_path/test.wrl"

File: /my_path/test.wrl
Error details: -- line 2 col 32: invalid FieldType
-- line 4 col 42: "{" expected

How can I import this type of file? I can easily do it on Blender.


Solution

  • Apart from the misspelling in the original example (it should be SFVec3f, not SFFVec3f), Meshlab, at version 2016.12, does not support the primitive Sphere geometry. Meshlab does support using the PROTO statement that 'returns' Shape with IndexedFaceSet geometry. Here is an example VRML97 scene generating two tetrahedra instances as mesh-defined shapes:

    #VRML 2.0 utf-8
     PROTO my_tetrahedron [ exposedField SFVec3f xyz 0 0 0 ] {
         Transform {
             translation IS xyz
             children [
          Shape {
            appearance Appearance {
              material Material {
                diffuseColor 0.0 1.0 0.0
              }
            }
            geometry IndexedFaceSet {
              coordIndex [ 3 1 0 -1  3 2 1 -1  3 0 2 -1  0 1 2 -1]
              coord Coordinate {
                point [0.29 0.50 -0.20 0.29 -0.50 -0.20 -0.58 0.00 -0.20 0.00 0.00 0.61]
              }
            }
          }
             ]
         }
     }
    
    
    # [Scene] ========== ========== ==========
    
    
    my_tetrahedron { xyz 0.0 0.0 0.0 } 
    my_tetrahedron { xyz -1.0 -1.0 -1.0 }
    

    Meshlab 2016 does import this as two meshes.

    Suggest solution to original question: replace the Sphere geometry in the VMRL scene with geometry defined by an IndexedFaceSet