Wednesday, March 25, 2009

Creating Interactive 3D objects inside a PDF

One of the nice feature of MeshLab is its ability of saving meshes, in a variety of formats. Support for saving meshes in U3D format is useful for creating, using LaTeX, cool appealing PDFs with embedded 3D models.

Yes, that means that when, using a plain Acrobat Reader, you open a pdf like this one, you will be able to freely interact with the 3D model, directly inside the text.

To generate such a pdf you simply need to convert your mesh into u3d format, and include the small snip of latex code generated by MeshLab with the right viewing parameters, in your latex document and simply compile it with pdflatex. Thanks to the Movie15 latex package, you will have your u3D embedded in the pdf. Note that the u3d file format is quite compact; for an example you can look at this pdf that contains the 50k triangle mesh of the Laurana's bust squeezed to less than 250 kb. A zip with sources (latex and u3d file) can be found here.

A couple of notes. The conversion process is done through the use of the Universal 3D Sample Software by directly using the IDTF converter provided with the sample library. The conversion process can take a fairly long processing time (many seconds for a mesh composed by 50k triangles) so be patient! Moreover be careful that the process can fail when involving pathnames with non trivial chars. Moreover very large meshes take a LONG time to be converted, be patient... Acrobat reader support this kind of files since ver. 7.