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

Can't Open Other OBJ Files #45

Open
blipson opened this issue Feb 25, 2020 · 2 comments
Open

Can't Open Other OBJ Files #45

blipson opened this issue Feb 25, 2020 · 2 comments

Comments

@blipson
Copy link

blipson commented Feb 25, 2020

These lessons work very well for the sample OBJ files that you provide, but I'm having trouble loading in other OBJ files. I pulled a few from https://groups.csail.mit.edu/graphics/classes/6.837/F03/models/ and they either threw segmentation faults or drew the geometry completely wrong.

@blipson
Copy link
Author

blipson commented Feb 26, 2020

I managed to figure out the problem! Model.cpp has this line of code when reading a face from an OBJ file (line starting with "f").

while (iss >> idx >> trash >> itrash >> trash >> itrash)

Meaning it expects 4 characters after each index, specifically a slash followed by a number followed by a slash followed by another number. But not all OBJ files define vt's and vn's so some define faces like this:

f 2227 2077 2049

I changed the code to do this instead:

while (iss >> idx)

and it worked, but ideally it'd be able to handle either format. Will keep looking...

@blipson
Copy link
Author

blipson commented Feb 26, 2020

Proof that I could render those sample models:
Screen Shot 2020-02-26 at 11 48 20 AM

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

No branches or pull requests

1 participant