Howdy, Stranger!

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

A mesh save/load utility

Jmv38Jmv38 Mod
edited November 2012 in General Posts: 3,295

Hello everyone! I am happy to release this utility to save and load a mesh to your documents as an image.
This video shows how it works. Note that:

  1. there is a problem of 3d rendering, but only in the video recording, it is ok in the reallity.
  2. the last object i load in the video is an earth model, the image is 1.3Mo so the loading and decoding are rather long 15s?).

So this is the video:

You can get the whole project there (copy/paste in a codea main tab and run. This is 2500 lines of code because there are also a lot of things i used elsewhere, and i don't want to clean the code).
If you've saved the meshes locally and want to clean it afterwards, you can see and access them via the sprite picker, in your Documents folder.
For those who want to use it in their project, here is how to do that:
- Add a 'Convert' tab class to your project.
- Copy and paste in it the following code gist of Convert. It is only 500 lines, but again there are more functionnalities than just the ones needed for saving a standard mesh. Actually it can save more object types (but not all).
- then in your program create a 'tool' to save and load the mesh 'obj' with the name you want, here 'test':

   tool = Convert()
    obj = tool:loadMesh("test")
    tool:saveMesh(obj, "test")

it's that simple.
I save the vertices, the colors, the texCoords and the texture image.
It should work even if your mesh has some of these fields equal to nil.
As with any other program on the ipad, if you load or save very big objects, you may run out of memory and Codea may close. Manage this as usual (close all apps, free memory, etc...).
I hope this will help some of you to start playing with 3d.

Comments

  • edited November 2012 Posts: 196

    @jmv38 nice one :D
    I use something similar on my blender exporter since it's much easier to "self-email" blender models into codea as images, instead of 50 pages of vertex info :P
    thanks for sharing !

  • BortelsBortels Mod
    edited November 2012 Posts: 1,557

    Heh - bumpy earth is fun. Thank you for sharing.

    If you press and hold the new project "+", you can choose "paste into project", which is faster and will re-create the original tabs.

  • Posts: 10

    @jmv38 , I have been following the evolution of your 3d mesh selector/renderer with great enthusiasm. I still surprised with the final performance of it. Congratulations. :) .

    I don't have no experience in 3d, but I would like to have your opinion if it is possible to create a "light" version of the rotating textured earth, to use in a planetarium type app that could show different planets using different textures. One of my concerns is about the loading time (using local images on the IPad) that need to be fast and globally not to much memory consuming.

    Thanks in advance,

  • Jmv38Jmv38 Mod
    Posts: 3,295

    Hello @pcarras. Thanks for your support. At this stage i have a little bit put aside the 3d stuff because what i was tring to do was starting to be more and more work and less and less fun. And a lot of frustation because the end result was always not simple enough to be easily maintainable.
    But concerning your question: i think your planetarium is very much achievable. At some point in time i was considering doing it, but i took another direction. Loading time and memory usage can be acceptable if you accept to have not too detailed planet textures. All the planet texture can be found at the web url i indicate in my tuto. To avoid to have too many meshes in memory you can have 1 single sphere mesh in memory, and draw it a several location, changing the texture image inbetween.

Sign In or Register to comment.