How to import fully 3D objects (Final post)

http://www.youtube.com/watch?v=OhIIdOj57yo

The OBJ format for 3D objects is in plain text, with all the vertices listed. With a bit of manipulation, you can get them into Codea, as shown above.

=D> (As usual)

Here’s another, of a Cessna aircraft. It is nearly 28,000 lines of data (made up of 3,750 points and 24,000 vertices using those points). Codea loads and runs the model quite quickly, but editing code is a real strain and very slow.

http://www.youtube.com/watch?v=aAFEwj9Sp1c

The code for both this and the shuttle are on Codea Community.

Clearly, it is going to be very difficult to import and use anything complex.

(As an aside, why go to all the trouble of building this model without wheels (so it is flying) and then show propellors that aren’t going round?)

Also, the reason this interests me so much is because I’ve been looking for a use for an app I purchased a while back called Verto Studio 3DM that makes 3d OBJ files. So now I can make models on my iPad and put them in Codea!
Thanks!

Well, there is some work to do. I used Excel to convert the obj. files to Codea format, because there is so much data and Codea doesn’t read and write files easily. And Excel VBA lets you step through line by line.

I’m happy to share my program, but it seems every time I find a new obj. file, it has some quirks that require changes to the VBA program!

I see you are using very nice shading in your videos. Very important to get the 3D feeling.

@Jmv38 - yes, lighting makes a big difference!

Hi @Ignatz,

Boy are you barking up the same tree as me. I have been trying to get into 3D for months - making painfully slow progress. I am currently trying to learn Blender but it’s a mamoth mountain to climb (probably actually an age thing!!).

You can export to a number of different formats and, if you can program in Python, can also build your own export add-on. Export formats include 3ds, JSON , obj etc. I’m sure you’ve been here.

I’m trying to make a number of models for a personal project and hope to generate something soon. Most of the models I use and hand coded and messy. I’ve only just started exporting models in JSON format but need to be able to read them into Codea - most of the links to JSON reading in the forum I find a little bit vague.

I was going to look into reading an obj file, but it looks like you have done it. With Excel - do you read in and wrtite out in CSV format?

I’ll be in touch later.

Thanks,

Bri_G

=D>

Hi @Ignatz,

Just downloaded your model display software and the 4 models - very impressive. Are you moving on to simpler models and UV mapping for them?

So far I’ve managed to build simple models with single colour faces and progressed as far as the shading by giving each vertex (in each triangular face) a different colour.

That’s why I’m trying to get into Blender - first target - a UV mapped cube.

Thanks again,

Bri_G

=D> =D> =D> =D>

@Bri_G - I’ve been using Blender to convert from 3ds to obj, so I can read the vertices.

My Excel code takes an obj file and converts it to the layout you’ll see in the Data tab, ie a list of point vec3’s, followed by a list of vertices. Some “faces” in the obj file have more than 3 points, and in this case, I calculate the midpoint and make triangles for every pair of adjacent faces. My VBA dumps the list of data in a worksheet, and then I have to fiddle about manually, transferring it to Codea.

At the moment, I’m ignoring normals (where provided in the obj file) and textures. I calculate normals based on the average at each vertex, which seems to work pretty well. I’d like to extend to using normals and vertex mappings as well, but the immediate problem is - as you will notice on loading any of these projects - the amount of data puts the Codea editor under massive strain.

So right now I’m looking at encoding the point and vertex data in an image instead of in code. If I can do that, and if it isn’t too slow to unwrap, I can then extend to normals and texture mappings.

I haven’t looked at UV mappings, no. First things first. I’ve only been doing this for a day!

@Bri_G - I have managed to save all my lunar lander data to a 70kb image, which makes it much more manageable, as no data needs to be stored in the code. In the next day or two I’ll test this approach on the other models, and then look at vertices and normals…

Hi @Ignatz,

Curious and curiouser, I downloaded and ran your files - great. Then tried to transfer them to my PC to digest. Main and Shader - no probs. Data crashes Codea. Must be on the data limit. Yet downloading from cc worked fine. Any ideas - how did you edit and transfer data?

Thanks
Bri_G

=;

I tried downloading the Files from CC but it doesnt download or run any of the projects, nit even my backups! Any Help?

I copied and pasted the data tab from a text file I put in my normal Dropbox folder. But now I’m going to see if I can store the data in an image outside of Codea, so it can handle larger models.

In other words, a helper program will turn an obj file into an image that Codea can read without having to store any data in the code itself.

Is there a problem with txt files handling? I’ve been using them a lot for my work on backups, and i have no pb with that.

Hi @Ignatz,

Moving to JSON file loaded from Documents or Dropbox or are you going to load a ‘png’ file from the codea spritepack in Dropbox?

I favour the JSON file approach as it can be expanded in sections - the vertices, faces, colours and later the UV map just by changing the JSON file structure.

I’d try with a simple model first.

Interesting project.

Thanks,

Bri_G

=;

Interesting discussion guys. I’ve written a similar tool in Python for some 3d games im writing, that takes .obj s that I’ve built, uv’d and textured in Maya, and converts them to a bunch of vec3’s for vertices, uv’s and normals that you can cut and paste via Dropbox into Codea…

As @Ignatz (and others in previous threads) has pointed out - vec3 lists are way too verbose for anything other than very simple models. Representing them as images is obviously the way to go or until Codea can easily support importing 3d assets. Hopefully the new asset browser (in the next version) could provide a route for doing this in future.

Happy to share my Python code if anyone’s interested. :slight_smile:

@CodeaNoob Are you on an iPad 1. I am and “cc” is totally useless on it. When I try to display the code, most of the code doesn’t show. If there are multiple tabs, switching tabs does nothing most of the time. It just keeps showing what was in the first tab. It used to work and I could do everything, but something changed and now it doesn’t. I don’t even try to use it anymore.

@andymac3d - yes please to the code

@dave1707 - I’ll post code soon on a gist, just refining it

@Bri_G - I haven’t thought about a JSON file because I haven’t used that file format yet, nor tried to save/load them in Codea. Do you have any examples?

@dave1707, I’m on an iPad Mini, and CC has worked two days ago, just not now