Problems loading OBJ files into Cinder

Hi

I’m quite new to Cinder but I need to load an obj file and can’t figure out what is going wrong.

When I copy the Satellite.obj file into the cinder/samples/data/models/ folder where the sample 8lbs.obj is and update the Resources.h file with this file name instead, I get the following error when compiling:

|error | void cinder::app::AppBase::executeLaunch()[137] Uncaught exception, type: cinder::app::ResourceLoadExc, what : Failed to load resource: Satellite.obj
libc++abi.dylib: terminating with uncaught exception of type cinder::app::ResourceLoadExc: Failed to load resource: Satellite.obj

If instead I try and load it via the line

ObjLoader loader(loadFile("…/…/…/data/models/Satellite.obj"));

in the loadObj function, I get a EXC_BAD_ACCESS error at the line :

while( ! mStream->isEof() )

Both errors are the same even if I incorrectly spell the filename as a test so I think its a problem with finding the resource rather than the obj file itself.

What is the best way to import an obj file into Cinder?

The file that I’m trying to load is here:

Thanks

Hi,

Did you add the model to your project? Check the ‘Adding a Resource’ section here:
https://www.libcinder.org/docs/guides/resources/index.html

You can also try using assets, which is a bit easier.

-Gabor

Great, thanks. That worked.

Adding the .obj file via the ‘Adding a Resource’ method worked when referencing the file in Resources.h and adding it into the assets folder worked using this line

ObjLoader loader(loadAsset(“Satellite.obj”));

1 Like