Hi,
I converted a small VRML model to egg with no problem, but then all the other wrl models (which I can see with a vrml viewer) cannot be converted.
vrml2egg calims that there is an error:
Error in yt.wrl at line 1, column 0:
#VRML V2.0 utf8
^
syntax error
however, that’s only a comment and the file that works also has it.
Any ideas?
I suspect your file might actually begin with Window’s special encoding bytes: a pair of invisible bytes at the beginning of the file that indicate the encoding system used within the file.
Most Windows editors are designed to recognize these two bytes and pretend they aren’t there, so you never see them when you open the file in an editor.
You can test this by opening it in, say, Python, and reading the first few bytes yourself.
I’m having the same problem, and there are no ‘invisible bytes’ (checked with a hex editor). I do notice that if I take my .wrl file and delete most of the Shapes in it, the conversion happens successfully. The funny thing is that I have bigger .wrl models that were generated in the same fashion as the problematic ones that convert successfully.
Looking at the source (I think the relevant file is vrmlParser.cxx.prebuilt: panda3d.cvs.sourceforge.net/view … iew=markup) it looks like the vrml2egg I have was built with verbose error messages turned off (d’oh).
If I provided one of these misbehaving files is there someone with a debug version of vrml2egg who could try to see what the problem is?
Okay, I’ve just stripped that .wrl file to its essentials and it appears it doesnt chew the “1e-06” thats in there. Replace it with “0” to make it work.
I’ll look further to see if I can make it support the “e”. Yech, I’ve never worked with flex/bison/whatever.
Nope, I can’t tell you which line a problem is. Maybe its possible but I don’t know beans about the vrml converter.
It appears 1.0e-09 parses fine but 1e-09 doesn’t. Odd. I checked the regexes that are stored in there but they match.
drwr, if you know anything about how it works, could you give me a hint where to start looking for this? At least in which file?
Looking closer at the parser, it looks like it’s the lack of decimal point in the scientific notation that’s confusing it. “1.0e-06” works, while “1e-06” doesn’t. The official VRML grammar states only that it expects to find a “floating point number in ANSI C floating point format”, and checking the official ANSI C specs seems to indicate that a decimal point is optional, so this is indeed a bug in Panda’s VRML parser. It’s easy to fix; I’ll check in a fix for it.
On the other hand, the parser should have reported a more useful error message than yelling about the first line. I’ll look into that too.
It appears that flex’s operator precedence is different from python’s re module. Flex is thinking that the ([eE][+-]?[0-9]+)?) expression is grouped with the ([0-9].[0-9]+) expression, not with the whole ([0-9]+)|([0-9].[0-9]+) expression.
But I’m still working on the error reporting. It looks like that was cut-and-pasted from some other lexer, like the egg lexer, and combined with a different lexer approach written by someone else; I don’t think it’s ever worked properly here.
Edit: Fixed silly mistake in call to .sub(). I was putting re.VERBOSE (which equals 64) where that method expects the count (number of matches to replace). The result was that I had to run the filter more than once on some files, d’oh!
@drwr: I just updated from cvs and it works great now! The errors are reported fine now as well - if I add something invalid it prints out the erroring line. Thanks alot!