Is it possible to import 3D models in Codea?

It’s quite a hard work to code the mesh,I think.So I’m wondering are there any possibilities to import some 3D model(like .obj) modeling by GUI?It would be much easier to build a 3D program,specially a game.Can anyone helps?

I wrote this program post for this purpose: easy loadin and sharing meshes… Does that fit your question? I am currently woarking on more advanced tools to build 3d objects and share them via this utility. Would you be interested?

I have been grappling with the same issue. Apparently @Xavier has put together a Blender model import to mesh function. I’m trying to work out if you can do something similar with Illustrator.

I have written a ply and x3d importer, so the answer to your question is yes, depending on the format.

.@aciolino - what do you recommend for drawing very simple models which can export as ply or obj? Blender?

I use meshlab but it’s buggy and cumbersome, though it does WONDERS for vertex and face reduction.

I also use Google’s sketch lab for buildings and some shrubs/trees.

If you already know blender, use it. I don’t use it because I’m no good with it.

Illustrator should output some 3d type…which ones?

.@aciolino.That’s really cool.But where could I get it?

I have a gist for ReadPLY and WritePLY. Check out

Thanks @aciolino - I will give your ply reader a go. Illustrator looks to be a bust, it doesn’t seem to have any useful 3d types. You can export as an autocad file but Im not sure if that is much use. I’m having a play with Blender - it is complicated but at least you cant complain about the price.

How did it work out?

I was a long time user of TrueSpace — long time as in starting over 20 years ago on the Amiga. Microsoft bought them out several years ago when a 3D modeling tool seemed like something all the big dogs were adding to their portfolio, then promptly closed them down. But it’s still available on the web, and I’d highly recommend it for ease of use.

.@aciolino - I’m still trying to build my 3D model in Blender! Talk about a frustrating program. I’ll have another go over the weekend. If that doesn’t work I might have a play with TrueSpace.

Truespace or SketchLab. What kind of model are you trying to build?

.@aciolino - just a simple spaceship. I’m having problems with the mirror modifier. I got it working once but I’m not sure how I did it. I’m sure I will work it out and if not I’ll try the other programs suggested. Blender reminds me of Gimp and Scribus when I first started using them.

.@aciolino - ok I drew my space ship!

Edit: Looks like your readPly class may need a bit of tweaking to get it to load a ply file from the iPad. The good news is that if I look at my ply file in a text editor its format is similar to your example file. I will see if i can use my Codea File Manager class to locate the file and load it using your ReadPLY class. I might even do a tutorial on it so others can do the same if that is ok?

I use my defereredloader and DropBox to do reads,but the code is set up so that you can bypass all that hooey.

If that’s the version without the deferredloader code (lne 18), just pass the string representation of the .PLY file to the constructor, so try this:

obj = ReadPLY()

The resultant obj file should have a collection of self.renderitems, which has a single entry, so self.renderitems[1] will be your mesh. The reason for this is because the code for X3D, which this is based off of, allows for a single file (X3D world) to containt multiple meshes. PLY doesn’t do that so there’s only one valid mesh.

Note that if you have a texturefile and load this thing without the deferredloader, you won’t get your texture file, and likely the renderer will fail becuase it expects one.

That sounds easier - trying now…

I don’t have any textures at this stage - I havent worked out how to attach a texture to the model yet.

Good luck.

All good - I have got my model displaying in Codea. Codea on the iPad 1 doesn’t handle large files like the PLY model very well - I’m using a relatively small model (456 triangles) but it stretches over 1500 lines as a string in Lua. Codea crashes whenever I try and edit the model file. On the upside it renders very quickly.

As an aside - I’m sure that there is a simple way to do this but it isn’t obvious to me, how do you display your mesh as a wireframe? I’m not using any textures and the model lacks definition.