如何在Meshlab上导入VRML 2.0

时间:2017-09-15 14:35:12

标签: meshlab vrml

我试图在Meshlab上导入这个VRML文件的文件:

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

我收到错误:

grammar WellFormedGrammarValidator;

main_program
:
    (
        string
        | string_one_quote
        | expression
        | multiline_comment
        | xml_comment
        | one_line_comment
        | EscapeSequence
    )*
;

one_line_comment
:
    ONE_LINE_COMMENT
;

multiline_comment
:
    MULTILINE_COMMENT
;

xml_comment
:
    XML_COMMENT
;

string
:
    QUOTED
;

string_one_quote
:
    QUOTED_SINGLE
;

expression
:
    not_string_term
    | '{'
    (
        main_program?
    ) '}'
    | '['
    (
        main_program?
    ) ']'
    | '('
    (
        main_program?
    ) ')'
;

not_string_term
:
    NOT_STRING_CHAR+
;

NOT_STRING_CHAR
:
    (
        ~['"']
    )
    | '|'
;

QUOTED
:
    '"' StringCharacters? '"'
    | CharacterLiteral
;

QUOTED_SINGLE
:
    '\'' StringCharactersOneQuote '\''
;

CharacterLiteral
:
    '\'' SingleCharacter '\''
    | '\'' EscapeSequence '\''
;

fragment
SingleCharacter
:
    ~['\\]
;

fragment
StringCharacters
:
    StringCharacter+
;

fragment
StringCharactersOneQuote
:
    StringCharacterOneQuote+
;

StringCharacterOneQuote
:
    (
        ~'\''
    )
    | '\\\\\''
    | EscapeSequence
;

fragment
StringCharacter
:
    (
        ~["]
    )
    | '\\\\"'
    | EscapeSequence
;

EscapeSequence
:
    '\\' [btnfr"'\\]
;

ONE_LINE_COMMENT
:
    '#' ~[\r\n]*
;

MULTILINE_COMMENT
:
    '/*' .*? '*/'
;

XML_COMMENT
:
    '<!--' .*? '-->'
;

WS
:
    [ \t\r\n\u000C]+ -> skip
;

如何导入此类文件?我可以在Blender上轻松完成。

1 个答案:

答案 0 :(得分:1)

除了原始示例中的拼写错误(它应该是SFVec3f,而不是SFFVec3f),Meshlab(版本2016.12)不支持原始Sphere几何。 Meshlab确实支持使用PROTO语句'返回'带有IndexedFaceSet几何的Shape。下面是一个示例VRML97场景,生成两个四面体实例作为网格定义的形状:

#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确实将其导入为两个网格。

建议原始问题的解决方案:将VMRL场景中的球体几何体替换为IndexedFaceSet定义的几何体