PistonDevelopers / wavefront_obj

A parser written in rust for the wavefront .obj file format.
MIT License
27 stars 18 forks source link

3Ds Max exports fail; likely to be linked to order of parsing #51

Closed hadronized closed 8 years ago

hadronized commented 8 years ago

The parsing order might be dependent on the way the parser expects tokens to appear.

cgaebel commented 8 years ago

?

hadronized commented 8 years ago

I cannot load obj exported from 3Ds Max, because the order / abscence of some keys make the parser fail. For instance, unnamed objects (no o) causes an error when reading the first vertex. Or the normals come after the texture coordinates (or the other way around, I don’t quit remember), making the parser fail as well.

cgaebel commented 8 years ago

Can you attach an minimal-ish example?

hadronized commented 8 years ago

The example I tested on is 45MB big, so… not yet :D. But looking at the parser, I guess there’s something wrong with the order the parser expects things to occur.

hadronized commented 8 years ago

Though:

# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 24.07.2016 15:28:16

#mtllib Magnum fury test build 2.mtl

#
# object Object030
#

v  46.9378 58.0687 -53.6929
v  46.4123 56.1572 -53.9380
v  45.5589 54.3956 -54.3359
v  46.9378 62.0444 -53.6929
…

thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: ParseFailed(ParseError { line_number: 10, message: "Expected end of input but got v." })', ../src/libcore/result.rs:799

hadronized commented 8 years ago

Ok, looks like it’s a problem with unammed object. I’ll fix that and push a PR soon.

hadronized commented 8 years ago

Ok, I fixed the problem with objects. Now I have another problem. Fixing it as well.

hadronized commented 8 years ago

Ok, almost there. Just need to fix the texture coordinates parser, and it’ll be good!