patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.91k stars 597 forks source link

Error loading .obj mesh with just vertices and faces #204

Closed Matakov closed 6 years ago

Matakov commented 6 years ago

Hi, the issue is I cannot load any .obj mesh in a c++ code, whether .obj was created with library, or not. The code is as following: " std::vector name = split(argv[1],".");

std::cout<<name[0]+".obj"<<std::endl; eos::core::Mesh mesh = eos::core::read_obj(argv[1]);

" The error is this:

main: /home/matko/builds/eos sandbox/eos/include/eos/core/read_obj.hpp:163: auto eos::core::detail::parse_face(const string&): Assertion `subtokens.size() == 3' failed. Aborted (core dumped)

Data which is in a .obj is as such: v 60.085400 -24.344900 -18.341000 f 1 2 3

By code in read_obj.hpp it should be correct. Could you please tell me what I am doing wrong. Thank you for your time and looking forward for a reply. P.S. Object can be downloaded at the following link. https://drive.google.com/open?id=1UhZvfUoWvZ5g8Jdg2zYldUok9As0AYbb

patrikhuber commented 6 years ago

Hi!

I'm sorry but the read_obj(...) function is more of a work-in-progress (actually I haven't worked on it in a while), it may or may not work for your particular case. It's not really a "clean", supported part of eos - maybe we should mark it as such! It sounds like in your case it could just be a wrong newline character or something like that (e.g. Linux vs. Windows).

I would suggest that you either debug & adjust the function for your obj, or read the obj by yourself or by any library out there, it should be more or less trivial.

I'll still leave this open, because we should at least document that this function may or may not have seen its best days.

patrikhuber commented 6 years ago

Okay, I had a look at this today. So the read_obj function was actually pretty good already. I think it should've worked for your obj file too, and I suspect a user-error is more likely.

However I've taken this opportunity to polish the read_obj function a bit, and it should support most cases of obj files now. The commits are in the devel branch.