2011-08-17 16:44:28 +08:00
|
|
|
\section{Python integration}
|
|
|
|
\label{sec:python}
|
|
|
|
A recent feature of Mitsuba is a simple Python interface to the renderer API.
|
|
|
|
While the interface is still limited at this point, it can already be
|
2011-08-19 15:13:18 +08:00
|
|
|
used for simple automation purposes. To access the API, start your Python
|
|
|
|
interpreter and enter
|
2011-08-17 16:44:28 +08:00
|
|
|
\begin{python}
|
|
|
|
import mitsuba
|
|
|
|
\end{python}
|
|
|
|
For this to work on MacOS X, you will first have to run the ``\emph{Apple
|
2011-08-19 15:13:18 +08:00
|
|
|
Menu}$\to$\emph{Command-line access}'' menu item from within Mitsuba.
|
|
|
|
On Windows and non-packaged Linux builds, you may have to update the extension
|
|
|
|
search path before issuing the \code{import} command:
|
2011-08-17 16:44:28 +08:00
|
|
|
\begin{python}
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Update the extension search path
|
|
|
|
# (may vary depending on your setup)
|
|
|
|
sys.path.append('dist/python')
|
|
|
|
|
|
|
|
import mitsuba
|
|
|
|
\end{python}
|
2011-08-19 15:13:18 +08:00
|
|
|
For an overview of the currently exposed API subset, refer
|
|
|
|
to the following page: \url{http://www.mitsuba-renderer.org/api/group__libpython.html}.
|
|
|
|
|
|
|
|
\subsection{Fundamentals}
|
|
|
|
All
|
|
|
|
|
|
|
|
Where applicable, the Python wrapper supports operator overloading,
|
|
|
|
default arguments, and
|
|
|
|
\begin{python}
|
|
|
|
import mitsuba
|
|
|
|
from mitsuba.core import *
|
|
|
|
|
|
|
|
myVector = normalize(Vector(1.0, 2.0, 3.0))
|
|
|
|
|
|
|
|
print(myVector * 2)
|
|
|
|
|
|
|
|
Log(EInfo, "" +)
|
|
|
|
\end{python}
|
|
|
|
|
2011-08-17 16:44:28 +08:00
|
|
|
|