Embed 3Ds into PDF with LaTeX & U3D

Submitted by Nicola Rainiero on 2012-11-14 (last updated on 2015-05-02)

I made some experiments about the embedding of interactive 3D objects into PDF documents with LaTeX, but the results don't satisfy me. The big problem is localized in U3D conversion of my 3D content, whereas the writing of TEX file and compiling with pdflatex, once I had loaded the movie15 package and read the instructions, is very easy and fast.

There are two main items to include 3D graphics in your PDF documents:

  • The movie15 package that provides an interface to embed movies, sounds and 3D objects into PDF documents for use with LaTeX as well as pdfLaTeX.
  • U3D is a compressed file format standard for 3D computer graphics data1.

U3D conversion

In a previously article I used the X3D format without any problem. In fact Blender has a default efficient exporter add-on. Unfortunately in this case the things get worse, because Blender hasn't an incorporated exporter and the add-on available in internet, exports U3D incompatibles with Adobe Reader (I obtain the following error: “A 3D data parsing error has occured.”).

How can I solve it? Using Blender it is possible to export in Collada (.DAE) or STL format, leaving the default settings and then to convert with another open-source software: MeshLab available here.

This last software has a problem in Linux, or better in the repository of Ubuntu 12.04 and in another one which has a more recent version, i.e. lacks the executable to make the conversion in U3D format and the program outputs me the following message: Missing converter executable '/usr/bin/IDTFConverter'. I have found here some instructions to fix this inconvenient, but once I have compiled it and lauch the executable I obtain a segmentation fault!

Solution: Wine and installation of the Windows version. At the end it is slower than Linux version, but it works very well. Its U3D exporter creates also a TEX file, completely working!

LaTeX optimizations

Well, the PDF compiled from the TEX file written by MeshLab has two big problems:

  1. needs to change the orientation and scaling of the 3D object and to try new lights and render options every time you load the PDF;
  2. in most PDF readers you can read only the name of your U3D file, while in Adobe Acrobat you have to enable this function like I documented in the below images.




As usual I explain my LaTeX optimizations in a handy example, in order to resolve these troublesome hitches, without any long descriptions!

Example

I use the blender file for my articles on horizontal grit chambers, I select all objects (or CTRL+A) and export them in STL from File -> Export -> STL_(.stl), calling it dissabbiatore.stl.

Open MeshLab software and import this file from File -> Import Mesh, check if it is complete and then export again from File - > Export Mesh As ... - > U3D File format (.U3D), naming it dissabbiatore_meshlab.u3d and as I can see I find a new file named dissabbiatore_meshlab.tex, there is it:

\documentclass[a4paper]{article}
\usepackage[3D]{movie15}
\usepackage{hyperref}
\usepackage[UKenglish]{babel}
\begin{document}
\includemovie[
poster,
toolbar, %same as `controls'
label=dissabbiatoremeshlab.u3d,
text=(dissabbiatoremeshlab.u3d),
3Daac=60.000000, 3Droll=0.000000,
3Dc2c=0.613500 -7.545900 0.855200,
3Droo=7.618947,
3Dcoo=0.613470 0.649878 -0.855214,
3Dlights=CAD,
]{\linewidth}{\linewidth}{dissabbiatore_meshlab.u3d}
\end{document}

OK, I add the following string:

\movieref[3Dcalculate]{dissabbiatoremeshlab.u3d}{Click here!}

You can read its functionality in the 3D quick-start guide appendix of the movie15 package. The file become:

\documentclass[a4paper]{article}
\usepackage[3D]{movie15}
\usepackage{hyperref}
\usepackage[UKenglish]{babel}
\begin{document}
\includemovie[
poster,
toolbar, %same as `controls'
label=dissabbiatoremeshlab.u3d,
text=(dissabbiatoremeshlab.u3d),
3Daac=60.000000, 3Droll=0.000000,
3Dc2c=0.613500 -7.545900 0.855200,
3Droo=7.618947,
3Dcoo=0.613470 0.649878 -0.855214,
3Dlights=CAD,
]{\linewidth}{\linewidth}{dissabbiatore_meshlab.u3d}\\
\movieref[3Dcalculate]{dissabbiatoremeshlab.u3d}{Click here!}
\end{document}

I compile twice or more and next I open the resulting PDF file with Acrobat Reader, I enable the interactive function and using my mouse I change orientation and position of my object, like in a 3D software, then I play with the lights and render settings, all this options are available clicking with the right mouse button on the 3D object (inside the Viewing Options item). After I have finished I click on Clik here! and copy the texts inside the Javascript Window. I paste all in a new TEX file called dissabbiatore_final.tex2, there is it:

\documentclass[a4paper]{article}
\usepackage{epsfig,rotating,amsmath,subfigure}
\usepackage{natbib}
\usepackage[3D]{movie15}
\usepackage{hyperref}
\usepackage[UKenglish]{babel}

\begin{document}
\includemovie[poster,
toolbar,
label=pt,
text={\includegraphics[scale=1.0]{dissabbiatore.png}},
3Droo=6.896200246789337,
3Daac=60.000001669652114,
3Dcoo=0.6134188175201416 0.6502023935317993 -0.8552163243293762,
3Dc2c=-0.8354106545448303 0.3235208988189697 -0.44432342052459717,
3Droll=-75.5946486014902,
3Dlights=Hard,
3Drender=SolidOutline]
{\linewidth}{\linewidth}{dissabbiatore_meshlab.u3d}\\
A 3D, schematic model of a horizontal grit chamber. If the Figure does not appear interactive, please enable this function and click on it or use a recent version of \href{http://get.adobe.com/reader}{Adobe Reader}.
\end{document}

In this last TEX file I add a 2D image of my 3D, so every PDF reader can show something. In the following zip folder I put all the files I used for this article:  pdf_3D.zip




Related Content:

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.

Comments

Nicola Rainiero

Sat, 04/15/2017 - 19:13

Hi! I will try to answer your question.

\begin{figure}
\caption{A schematic model of a horizontal grit chamber}
  \centering
\includemovie[poster,
			  toolbar,
	          label=pt,
	          text={\includegraphics[scale=1.0]{dissabbiatore.png}},
			  3Droo=6.896200246789337,
              3Daac=60.000001669652114,
              3Dcoo=0.6134188175201416 0.6502023935317993 -0.8552163243293762,
              3Dc2c=-0.8354106545448303 0.3235208988189697 -0.44432342052459717,
              3Droll=-75.5946486014902,
              3Dlights=Hard,
              3Drender=SolidOutline]
			  {\linewidth}{\linewidth}{dissabbiatore_meshlab.u3d}
\end{figure}

Hope this helps!

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.