Model does not render with loadModel and drawFaces

Hi, i’m trying to load this model

But got the error “vortex index out of range”. I ended up downloading blender, importing the model and exporting it with some changes to try, and now the console does not return any error but it looks like it’s nothing there

It’s just a blank canvas. I tried zooming in and out, and rotating the camara (because i thought maybe it’s there but the camara is not focusing the model) but didn’t work.

Any ideas?

Edit: I tried using another downlaoded model, a plant and it works (just that it renders the object pure white). I noticed a high size difference (16mb the devil model to 94kb the cactus model), could that be the problem? the file is too big to render?

Thanks.

Hey Leandro,

Details about your model and the code that you use to load it would be helpful to help you :slight_smile: the easier you make it for someone to check this out, the better the chances are that somebody actually takes the time.

Things like attaching your model file, and neatly posting your relevant code (likely ofApp.h and ofApp.cpp) can help. I see that you show the model, but don’t think i can download the model without an account from sketchfab.

Without your code and the model, it’s harder to guess. “Vertex index out of range” means that your application tries to access a vertex that is not there. Let’s say your model has 10 vertices (points) and your code says “give me vertex with index 11” … It breaks. Actually already index of 10 will break it. Very often it can be confusing for beginners that indices start from 0, and the 10th vertex has an index of 9. Not sure if this is happening here though.

Sidenote: 16MB should not be a problem. If you care about performance though, you could optimise the model in sth like blender.

Cheers and good luck

Hi, sorry for not sharing the full information before, i will leave it here:

https://drive.google.com/drive/folders/1kLuC-1f5yXAdPkor5kzGfqjltLtjq4up?usp=share_link

I share a google drive folder because here i get a prompt that i can’t upload files because its a new account. Both .obj says “vertex index out of range” and the other formats like .ply, .dae and .fbx returns an error

exception Microsoft C++: DeadlyImportError in memory location 0x0019F718.
exception in 0x770274F1 (ntdll.dll) en TP Final - POAM2 - Di Maria_debug.exe: 0xC0000005: Infraction on reading the location 0x0AF5901F.

I used this video as reference to make the imports

EDIT: Hi ! I was able to load the devil 3d object, i ended up importing the model to blender and using a decimate modifier to lower the polygon count to 0.25. However i tried to do the same with the astronaut model which is a mesh of 3 parts (upper body, intestines and lower body) and i get the error OBJ: Invalid number of components. Any tips on that? I uploaded the filed to the drive
Thanks

Hi @Leandro_Di_Maria !

Perfect timing.

We just updated the 3D model loading ( via assimp ) in the nightly builds. It adds a lot more formats (FBX / glTF / Blender ) and fixes a lot of issues with existing formats. Can you try the nightly build at the bottom of this page: download | openFrameworks ?

If you run the assimpExample you can drag drop files into the window and it should load them.
If that works then you should be good to go :slight_smile:

Thanks!
Theo

1 Like

Hi, I will try to install it and use it. Right now when i’m trying to import the .obj file, i get the error [ error ] ofxAssimpModelLoader: loadModel(): OBJ: Invalid number of components :confused:

Edit: I tried using the nightly build. It loads a lot faster. With formats like dae, i bypassed the error
exception Microsoft C++: DeadlyImportError in memory location 0x0019F718.
exception in 0x770274F1 (ntdll.dll) en TP Final - POAM2 - Di Maria_debug.exe: 0xC0000005: Infraction on reading the location 0x0AF5901F.

But keep getting the error invalid number of components :confused:

I was able to load it with the nightly but had to make a change to the addon.

In ofxAssimpModelLoader::initImportProperties change line 108 to:

	unsigned int flags =  aiProcess_ConvertToLeftHanded;

If that works for you I’ll work on fixing the addon so this model renders without issues.

Thanks so much for helping us find an issue!
Theo

I’ve added a fix for this here: Fix model loading for obj and allow for more options for passing in flags to assimp by ofTheo · Pull Request #7157 · openframeworks/openFrameworks · GitHub

Should be in the nightly builds tomorrow or the next day.

Theo

Hi sorry for the late response. I don’t know why after i changed the line and restarted the visual studio, i keep getting 372 errors on assimp64.lib. I even tried creating new blanck proyects, and deleting the nightly build and extracting it again but no response. All errors have code LNK2038. Before i downloaded the nightly build, i had a 2017 open frameworks package, and there i don’t get this errors. However i keep getting the ofxAssimpModelLoader: loadModel(): OBJ: Invalid number of components. I’m trying to find a solution to this. When i get the nightlybuild to work again, i will test the change of line you proposed

Ahh it might be a version mismatch due to all the nightly builds being for VS 2019.

Our setup guide is now for 2019 as 2017 is no longer available for download.
https://openframeworks.cc/setup/vs/

I know that is a bit of a pain, but I am guessing if you setup VS 2019 ( you can still keep 2017 ) it will work .

I use visual studio 2019, but when i create/update a project with the project generator from openFrameworks, it always says “Platform: Windows (Visual Studio 2017)” and it’s disabled

Hmm.

So in VS2019 does the assimpExample work ( without using the project generator )?

We still use VS2017 templates currently in the nightly builds so when you open an example for the first time it should ask you to covert the project to 142 (VS 2019). But everything should just work with VS2019 apart from that prompt.

Cheers!
Theo

I downloaded this one https://github.com/openframeworks/openFrameworks/releases/download/0.11.2/of_v0.11.2_vs2017_release.zip from the page, and have VS 2019. (It uses 2017, and when i log in, asks me to update to 2019)

If i try to do anything with the nightly build, i get 300+ errors. And i’m already using VS 2019 there, so i don’t know. I’ve been trying things for the last 7 hours :confused:

This errors 372 errors when trying to use VS 2019 + OpenFrameworks

I just tried with VS 2019 and using the nightly build and it seems to be an issue with building in Debug.
Building in Release it works fine for me.

I’ll get a fix in for the Debug errors, but can you try building the assimpExample in Release ( using the nightly ) for now?

Thanks!
Theo

I can’t believe that i spent like 8-9 hours on this, and the solution was just to change from debug to release… it worked at the first load

Thanks a lot, really, this was a blocker for an assignment and finally i can continue, thanks again !

1 Like

Yay!!! :tada:

Super glad it worked for you and sorry it was such a slog.

Your model actually got me to fix a bunch of things that I believe will solve a lot of other people’s issues too. So thanks for raising this issue and helping test these new changes. :slight_smile:

The Debug fix might take a little bit longer but the import model changes should appear in the nightly builds by Friday.

Thanks and good luck with your assignment!
Theo

1 Like