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.


Michail Vidiassov said...

Dear Paolo,

here am I again.
If you only take time to integrate it into your solution I am ready to provide you with a small utility to make PDF out of U3D
(no LaTeX), and code to produce
u3d directly (no lengthy IDTF file to be written and parsed, likely a speedup). But I have failed to get an answer if you are interested or not.

Sincerely, Michail
PS. Mac PPC version of U3D lib also works.

AlfC said...

in meshlab when I try to save to .u3d format I get the error box with the message:

Failed conversion executable ' -en 1 -rzf 0 -pq 500 -input "/tmp/hola.u3d.idtf" -output "/home/correaa/.tmp/hola.u3d"'

other format work well. The wiki page says something about the "sample library" that I can't understand.

Tunggo said...

AlfC: It seems that the IDTF filter to create u3d is not avilable for linux :( . Try running the windows version of MeshLab using wine. At least it worked for me!