HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Getting Started

Table of Contents

Where is the HDK?

After you install Houdini, the HDK can be found at $HFS/toolkit. Inside the toolkit directory, you will find the following folders:

Folder Contents
include The C++ header files which give you access to Houdini's comprehensive set of libraries.
makefiles A collection of Makefiles intended to be used as building blocks for your HDK project's Makefiles. For more details, see Compiling with Makefiles.
samples A extensive set of HDK code examples. Several HDK samples are referenced throughout the documentation. For example, the standalone/geoisosurface.C link refers to the code sample located at $HFS/toolkit/samples/standalone/geoisosurface.C.

Before You Begin

You need to determine which compiler built the version of Houdini that you are using. On Linux, Houdini is built with the GNU compiler (gcc). The gcc version is embedded in the build's filename (i.e. houdini-X.Y.ZZZ-linux-x86_64-gcc6.3.tar.gz). It is not always required, though recommended, to build your HDK projects with the exact gcc version. For example, if Houdini is built with gcc 4.4 and you are using gcc 4.3, chances are your compiled HDK code will work perfectly with Houdini. However, if Houdini is built with gcc 4.4 and your HDK tools with gcc 3.4, then you may run into problems. You should check the GNU website to see which gcc versions are compatible and which are not.

Linux

On Linux, you will also need some development packages installed in your distribution. Unfortunately, the package names differ depending on the particular Linux distribution.

For Debian-based distributions, try using:

sudo apt-get install tcsh g++ mesa-common-dev libglu1-mesa-dev libxi-dev

For Red Hat-based distributions, try using:

yum install tcsh gcc-c++ mesa-libGL-devel mesa-libGLU-devel libXi-devel

Windows

On Windows, you need Visual Studio to compile the plugins (download from Microsoft). It is vital that you compile your HDK code using the same compiler version that built Houdini. One can determine by looking at the suffix of the installer file. Here is a quick list of the available Houdini Windows versions and which compiler is used to build each one:

Suffix Compiler
vc142Microsoft Visual C++ 2019, version 16.9.4

Note that you will also need to set the MSVCDir environment variable to point to the VC subdirectory of where you have it installed.

Mac OSX

To develop on Mac OSX, you will need to install XCode from the Mac App Store.

Houdini is built with the Apple clang compiler. Similar to gcc on Linux, it is not always required, though recommended, to build your HDK projects with the exact clang version.

My First HDK Program

The sample code standalone/geoisosurface.C is a very simple stand-alone program which can be used as an introduction to the HDK.

The program, in brief, is:

0001: #include <GU/GU_Detail.h>
0002:
0003: static float
0004: densityFunction(const UT_Vector3 &P)
0005: {
0006: return 1 - P.length(); // Return signed distance to unit sphere
0007: }
0008:
0009: int
0010: main(int argc, char *argv[])
0011: {
0012: GU_Detail gdp;
0013: UT_BoundingBox bounds;
0014:
0015: bounds.setBounds(-1, -1, -1, 1, 1, 1);
0016: gdp.polyIsoSurface(HDK_Sample::densityFunction, bounds, 20, 20, 20);
0017: gdp.save("sphere.bgeo", true, NULL);
0018:
0019: return 0;
0020: }

When executed, this simple program generates an ISO surface and saves it to a Houdini geometry file named sphere.bgeo.

To build the program, use hcustom, a tool designed to conveniently build the HDK samples and small custom projects.

Building geoisosurface on Linux

On Linux, first open a shell and set it up for using Houdini and the HDK by typing:

cd /opt/hfsX.Y.ZZZ # substitute X.Y.ZZZ with your particular version
source houdini_setup

After it is set up, copy the geoisosurface HDK sample into a writable place.

mkdir -p $HOME/HDK
cd $HOME/HDK
cp $HFS/toolkit/samples/standalone/geoisosurface.C .

Now you can build geoisosurface by typing:

hcustom -s geoisosurface.C

Building geoisosurface on Mac OSX

On Mac OSX, use Finder to navigate to the Applications folder. Then open the Houdini X.Y.ZZZ folder (substitute X.Y.ZZZ with your particular version) and double click on Houdini Shell.terminal to start the Houdini command-line shell.

In the Houdini shell, copy the geoisosurface HDK sample into a writable place.

mkdir -p $HOME/HDK
cd $HOME/HDK
cp $HFS/toolkit/samples/standalone/geoisosurface.C .

Now you can build geoisosurface by typing:

hcustom -s geoisosurface.C

Building geoisosurface on Windows

On Windows, choose Start > All Programs > Side Effects Software > Houdini X.Y.ZZZ > Command Line Tools (substitute X.Y.ZZZ with your particular version).

In the Command Line Tools window, copy the geoisosurface HDK sample into a writable place:

mkdir HDK
cd HDK
copy "C:\Program Files\Side Effects Software\Houdini X.Y.ZZZ\toolkit\samples\standalone\geoisosurface.C" .

Now you can build geoisosurface by typing:

hcustom -s geoisosurface.C

Running geoisosurface

hcustom creates an application, geoisosurface, in the current directory. Run geoisosurface to generate sphere.bgeo which you can view in Houdini's gplay application. For example:

./geoisosurface
gplay sphere.bgeo

And that's it! You have just built and ran your first HDK application!

More Details on geoisosurface.C

geoisosurface.C connects to Houdini's geometry utility library by including the GU_Detail.h HDK header. The header file can be found in $HFS/toolkit/includes/GU.

The GU_Detail::polyIsoSurface() method evaluates the callback function densityFunction() inside the bounding box specified by bounds. A mesh of polygons is created and saved to sphere.bgeo.

Try experimenting by changing the implementation of densityFunction() and see what kind of surfaces you can create. For more information on creating geometry using the HDK, see the Houdini Geometry section.