Game Developer & Computer Graphics Engineer
This is going to be a short tutorial on how to setup a c++ project using integrating HoudiniEngine in your custom engine
A few notes
-
Houdini is very strict about licenses, meaning you'll need a license for Houdini in order to make calls to the HoudiniEngine, it is also important to note that files with a Houdini endie license are different and will be incompatible with normal Houdini, A HoudiniCore or FX license should work fine
-
My project will be using Visual Studio to build and link, translating it to Cmake should be easy enough
-
This is a barebones implementation letting you use the Houdini API, there is 0 thought given to architecture
-
This is a simplistic case of a simple HDA but hopefully it will help you get started
Setup
Use the Houdini Launcher and install any Houdini version
Head to your installation folder, Default should be "C:\Program Files\Side Effects Software\Houdini 20.5.584"
Open your preferred console and run
"source houdini_Setup"

Now head to your enviornment variables and add "HOUDINI_ROOT/bin"

Now that setup is complete, open or create a c++ project and add "C:\Program Files\Side Effects Software\Houdini 20.5.584\toolkit\include" as an include directory
and add "C:\Program Files\Side Effects Software\Houdini 20.5.584\custom\houdini\dsolib" as a library directory, no just link against HAPI.lib and we can start calling houdini functions
Using The HAPI
We want to start by callin HAPi_Initialize(), for now the only input I care about is creating a cook option with a maxVerticesPerPrimitive of 3 in order to force triangles when convexing, other than that I pass null values, for more information see HAPI_Initialize()
As you can see I'm using an ENSURE_SUCCESS macro,I will also later use ENSURE_COOK_SUCCESS these are macros recommended in the HoudiniAPI website but ill paste them and their helper functions down below
You could of course also just do something like this
Now we will try to load an HDA or Houdini Digital Asset, as SideFX state on their website "Houdini lets you turn your work into reusable custom nodes called digital assets.", in this case I have an HDA that generates a ball with some noise applied to it
Notice that I pass NULL for the session parameter, this is because I'm telling houdini to use a default session, and we set "id" as an out paremeter, the HAPI works by giving handles(or IDS) and using them to request information
An example of getting the name of my asset
get_houdini_string() is a simple function I made to return a string from a HAPI_StringHandle
As you can see a pattern is starting to emerge, we get an id, and make a request with that ID.
Now how do we start working with this HDA
Calling CreateNode given the assetName and assetID as an out parameter will create a node on houdini's network and give us its Id to use later
Using that ID, we request the Parm counts and then Parm infos, which will hold the information to tell us what the parameter is named, what its type is, and if it has a parent, this can be used to reconstruct the parameter tree in your gui
In my context I know what parameters I want to change, In the long run I'm planning to use the parmInfos to construct a gui and then change the values through it but for now this will do
What I'm doing here is setting a parm by name in my asset to a value, since "rad" is a vector3 I also set the value for each position
After we set values, the next step is getting the SOP node, which hold our geometry, and cooking the node, which will evaluate the node with the new values we changed, and in my case generate the geometry
After we set values, the next step is getting the SOP node, which hold our geometry, and cooking the node, which will evaluate the node with the new values we changed, and in my case generate the geometry
I chose to save my geometry to a .obj file but you could also get the get the geometry as a bufferer using HAPI_SaveGeoToMemory
geometry when setting amplitude to 5
geometry when setting amplitude to 0.5
The last thing to do is call cleanup and we're all set
Closing Remarks
I do have some plans to turn this test all done in the main function to a dynamic library, which will notify the engines UI on what the params are, and then update them when edited in the engine, but seeing how little information I found online other than the HAPI documentation i figured this was worth posting.
If I do make this more than an experiment I will update this page