Converting 3D objects

From a standard format to a personal format

When I've started this project, I've quickly encountered a problem: how to create complex 3D objects and how to represent them in term of data structure? I knew there were a lot of existing format (3DS, OBJ, and so on) but none of them was easily or directly usable. Thus I've decided to create mine, a simple compact format in wich data are stored as a stream of structures, that I've called HB3D. This description of 3D object makes easy to fill the lists (vertices, faces, materials) "on the fly" while reading the data.

Of course, this personal format is not the key of the 3D rendering engine but it has helped me a lot to easily embed 3D scenes in HB++ projects. So, I think it will probably help you too. Anyway, you can define your own format and the first sample project does not use such a format and shows you how to dynamically generate 3D objects.

I've made a conversion tool to convert WaveFront OBJ format to my HB3D data format. Wavefront OBJ format is a known standard for representing polygonal data in ASCII form, many 3D modelers can export 3D meshes in that format. This is why I've choosen it as starting point for conversions.

Creating and converting a 3D scene

Create your 3D scene with a 3D modeler that can export your work as Wavefront OBJ format.

 

Use my HB3D converter tool and load the OBJ file. This tool lets you see how your 3D scene (or object) will be rendered with my pno code on your Palm OS device.

 

Export your 3D model as Palm database, binary file or h3d file.

 

These three file types use the same 3D data structure.

  • Exporting to Palm database lets you directly use it with the StreamFileDB class.
  • Exporting to binary file lets you embed your 3d object as binary resource in your HB++ project (you can use the built-in function of my tool to cut the file in several parts of 64kb).
  • Exporting to h3d file lets you merge several objects into one single binary file or Palm database (usefull for complex 3d scenes or for embedding several objects).

I recommand you to keep default options:

  • Size optimization: remove useless or duplicated vertices.
  • Force texture dimensions as even: Ensure compatibility with low and double resolution display.

The option "pixel per unit" lets you define the model scale. Anyway you can make some tries by yourself to see the result and to fix the properties you wish.

I do not have time to provide more details about the use of my convertion tool, if you need more explainations you can contact me.