|
| Petit |
Post
#1
|
|
Advanced Member Group: Moderator Posts: 543 Joined: 21-June 06 From: Borgholm, Sweden Member No.: 38 |
I've played around a bit with the WRLParser, and found that it has some problems with white space.
The documentation says : "WRL files must NOT have indentation! Please choose the without indentation option before generation." True enough, but it doesn't stop there. I tried to make a small change in the 2cubes.wrl, that comes with the Sandy 1.0 WRLTest. I used TextPad and saved the file as UTF8, and after that the geometry was corrupted. After some testing and reading the file in hexadecimal form, I discovered that TextPad changed the white space in a subtle way. Here is the point array for the first box in 2cubes.wrl: CODE coord DEF Box01-COORD Coordinate { point [ -16.68 0 19.32, 16.68 0 19.32, -16.68 0 -19.32, 16.68 0 -19.32, -16.68 25.83 19.32, 16.68 25.83 19.32, -16.68 25.83 -19.32, 16.68 25.83 -19.32] } The first line of points ends with a space and an end of line, hex '20 0D 0A'. On save, the text editor strips the space character at the end of that line, as being superfluous. The WRLParser reads the point array as corrupted. I don't know why it wants a space here, as we already have a comma ( ',' ) delimiter, which would be enough. Possible solutions: VRML uses space ( hex 20 ) as delimiter for the x, y, z values of in a point array, so we cannot simply skip spaces. What we could do, to make the parser less sensitive to the amount and order of white space, would be to preprocess the file, after it is loaded to make the following change, before the text is parsed: o Read through the file and change any length of white space into one space character. If this is done, all 'end of line' or tab characters are converted to just one space, which is what the parser wants. As extra bonuses, we could use any UTF8 capable editor to write or change a VRML file, and we can use pretty printed WRL files with indentations for block levels. The extra overhead introduced by preprocessing, I think, would be well compensated for by the possibility to use different VRML generators and the more human readable WRL files. This post has been edited by Petit: Sep 27 2006, 11:30 AM |
| kiroukou |
Post
#2
|
|
Administrator Group: Root Admin Posts: 865 Joined: 12-June 06 Member No.: 1 |
Hi Petit,
Indeed I've heard some problems with the Wrl files... This format doens't seems to be a real standard... in AS3 the problem will be easier to fix thanks to regular expressions. For the moment, I recommand to use the ASEParser which seems to be more robust. I'll read more carrefully your propositions, when I'll update my code and prepare it for the next release! thanks!! |
| Petit |
Post
#3
|
|
Advanced Member Group: Moderator Posts: 543 Joined: 21-June 06 From: Borgholm, Sweden Member No.: 38 |
I suggested
QUOTE Read through the file and change any length of white space into one space character. Well, I tried my simplistic solution for a couple of hours, and found a nice little algorithm, that did just that. To no avail (IMG:style_emoticons/default/sad.gif) Which just proves, I didn't know the VRML file format well enough. Had I not been such a simple mind, I should have realized, it's not quite that simple. First of all comments in a wrl file starts with '#' and ends with end-of-line ( aka '\n' or hex 0D0A ). Changing all white space to space makes everything a long and interesting comment, as the file will start with "#VRML V2.0 utf8". So, some more thought should go into this. |
| Lo-Fi Version | Time is now: 17th July 2007 - 03:07 PM |