Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obj loader #10

Closed
waveform80 opened this issue Jul 18, 2015 · 1 comment
Closed

Obj loader #10

waveform80 opened this issue Jul 18, 2015 · 1 comment
Assignees
Milestone

Comments

@waveform80
Copy link
Owner

We need to add something like Martin's obj loader for 0.5. Probably don't need all the rotation and scaling stuff - we can defer to Vector for that. Rather it should be something brutally simple: load the obj and present it as a dict mapping vectors to blocks. For the material mapping we might to provide something a little extra - maybe a function to query all the materials used by the file, or something?

Also need to provide recipes showing how to scale/translate/rotate the resulting dict of vectors (although that should be pretty obvious from the vector tutorial, but you can bet people who want obj loading will jump past that stuff).

@waveform80 waveform80 self-assigned this Jul 18, 2015
@waveform80 waveform80 added this to the 0.5 milestone Jul 18, 2015
waveform80 added a commit that referenced this issue Sep 6, 2015
Turns out the obj format is *lot* more complex than can be handled by
simple line splitting and regexes (it's a line-based format with
backslash continuations, arbitrary comments, and a certain amount of
state based parsing like the negative index handling). This is an
attempt at using pyparsing to handle the format; this works but it's
*really* slow ... probably too slow to use on a Pi (it's taking 6
seconds to parse a 300kb model on my Core i7; I dread to think what
that translates to on a Pi 1).

Then again, pyparsing is pretty slow generally - might be worth trying
to hand-roll a lexer & parser for this?
waveform80 added a commit that referenced this issue Sep 9, 2015
After digging out the most complete docs on the .obj spec (appendix from
the Wavefront manual) it seems this format *can* be parsed with simple
line splitting provided one assumes (like the Blender variant of the
parser, and the vim syntax file) that commands all start in column 1.
This isn't actually in the spec, but oh well - enough existing parsers
agree with it to make it a de-facto standard.

The parser is now largely complete along with associated machinery, and
it's about as fast as we can reasonably hope to make it on a Pi (at
least it's much faster than the 2 minutes that the pyparsing variant
took...). Now to finish the render method, and we can consider this
done.
waveform80 added a commit that referenced this issue Sep 10, 2015
Nearly done now - the renderer works nicely. Just need more docs and
tests.
@waveform80
Copy link
Owner Author

I'm declaring this done - it's working nicely enough for me now. The only thing to add is tests; that can wait for 0.6 and I want to get this out before the weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant