Adventures in importing 3D assets

For Pocket Nature I need to import some 3D models in Wavefront OBJ format. I’ve written my own importer 10 years ago, but that was to tied in with the “engine” I was writing at the time so that I couldn’t use it standalone.


So after some googling my first shot was using Assimp. After all Assimp seemed to be the mother of all asset importers. I ended up not using it, but here’s what I did to make it compile.

Assimp is an open source 3D model import library ( that imports and exports various 3D model formats (think DevIL for 3D models).

Compiling it for iOS wasn’t straightforward. I did this to make it work:

  • Get the trunk of Assimp here: At the time of writing (Jan 15th 2012) the downloadable packages did not contain the ports folder, so make sure to get the trunk.
  • Install CMake:
  • Navigate to the port/iOS subfolder. Now we are going to change some root paths from the old Xcode locations starting at /Developer to the new ones within the Xcode app bundle. (You only need to do this if you are using a newer Xcode version. I am currently on Xcode 4.5.2.)
  • In
    • replace all occurences of -DBUILD_STATIC_LIB=ON by -DASSIMP_BUILD_STATIC_LIB=ON
    • edit the occurrence of export DEVROOT for  ARM7, so that it looks like this: export DEVROOT=/Applications/
    • edit export DEVROOT for i386, so that it looks like this: export DEVROOT=/Applications/
    • Remove ARM6:
      • Comment out the block that builds ARM6 (not supported anymore)
      • In the create_outdir() function change the lipo line to look like this: lipo -arch armv7 $lib_arm7 -arch i386 $lib_i386 -create -output $lib
    • Change base SDK and minimum SDK version to match your setup. In my case
  • Open .cmake files (ARM7, i386 and edit the DEVROOT and SDKROOT lines so they look like this
SET (DEVROOT "/Applications/")

OBJ importer by dhpoware

After struggling for 4 hours to finally get assimp to compile and link with my code it crashed with a dubious error message. Since I didn’t want to waste any more time I took the simple obj importer by dhpoware ( It was one .h and one .cpp file and worked out of the box.

Lesson learned

Don’t crack a nut with a sledgehammer! If I’ll need other model formats in the future I might as well convert them into OBJ first instead of using assimp. And if I need animation, then experience has told me that writing an exporter is often the better solution.

Share this:
  • Slappy

    This is good. Facing a similar issue. Do you have some sample code calling the dhpoware obj importer?

    • Gottfried Chen

      Sure, it’s really straightforward. Importing actually boils down to this:

      ModelOBJ model;
      // This is optional, scale if model it too small/big

      Afterwards ModelOBJ contains all necessary data for rendering (vertices, normals, uvs, etc.).