Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

problem with loading .obj model with craft

in Bugs Posts: 573

@john a number of my .obj models give an error message when i attempt to load via craft. Interestingly, they are correctly rendered in the .model picker. The same models do load correctly if i use old @ignatz code for loading .obj assets.

the error message....

expect userdata, got nil
stack traceback:
[c] in ?
[c] in metamethod



  • edited December 2017 Posts: 1,926

    @plinthesky - I had quite a few models that threw out that error, found that most were due to errors in the file. Some had been converted from other file formats and lost their compliance to the obj file format. Others required textures which were not the files I had.

    @John has posted that a more general model file loader is planned which may be more robust in loading and error capture.

    I have quite a few models which load in Finder on the Mac and in the Codea Documents folder as icons.

    On the Ignatz front many of his models are not true .obj files as they combine .mtl and .obj. Also Some Ignatz' loaders are designed for his own files.

    I can vouch for the Craft's object loader I now have several good models which load successfully. Are your models multi component models as I' m not sure but complex multi component models may not be supported yet?

  • edited December 2017 Posts: 1,926

    @plinthesky - an example of one of the problems I found is with one of the free models I downloaded:

    MQ9 Predator Drone

    The file I downloaded doesn’t display properly, part of the central fuselage appears to be missing. May be a corruption in the file I downloaded, but I would have expected an error rather than partial resolution of the model.

    The site provides users one free model download.

  • When i click on your predator drone link, safari can’t get the address?
    Does your model display correctly in the dropbox asset picker?

    i have an example in which everything looks perfect in the dropbox asset picker, but when i load it with entity.model i see the model but all the colours are absent.
    It is quite frustrating that the asset picker can render the model correctly but the codea code cannot. Hopefully @john will find some time to look into this soon.

  • Posts: 1,926

    @piinthesky - weird, tried my own link and failed to get ther. So extracted link and edite the thread to show the full url. Got this to work but two out of three times!!!

    Hope it works now.

    I think many models default to an all grey colour scheme if there is a problem with the texture. Seen this in the asset picker many times. Think the loader must be set up if traps an error.

    Is your example a free model on the net?

    Most of my models are in sub directories so they don’t show in the asset picker of Documents.

  • i was referring to the XWing model in @yojimbo2000 obj.lmporter project

  • edited December 2017 Posts: 1,926

    @piinthesky - interesting, after unlinking my Dropbox folder, delinking and syncing ensuring the files were named correctly I retried loading the Utsira models of XWing and TieFighter, they loaded up OK!!! Must have had a corruption somewhere. But they initially appeared grey. When I provided a bright light source the models showed up in colour with no surface effects. Now looking at some of my other models which showed up errors.

    Edit: - forgot to say I previously had been able to load these models using Utsira’s obj loader, but failed trying to load the models with Craft hence my view on corrupt models in my Dropbox folder.

  • edited January 2018 Posts: 573

    @Bri_G @John after some experimentation i was able to successfully load my blender models. The trick is to export the .obj with the options ‘write normals’ ‘triangulate faces’ but do not include the UVs.

  • edited February 2018 Posts: 1,926

    Hi @piinthesky - have you compared the files to see where the differences are? Be nice to understand what to look for in the file.

Sign In or Register to comment.