Create a pipeline to export geometries as FBX - jostly/PatternsOfGameDevelopment GitHub Wiki

Part of Houdini

Problem: You have an HDA that creates geometry. You want to apply variations of parameters to the HDA to create different outputs, and export each variation as an FBX. You want this automated to run at the press of a button.

Step 1: Create an FBX export HDA (if you don't already have it)

Create empty HDA

In the /obj network, create a geometry, and enter it.

Create a Null node, name it IN, and press Shift-C to collapse it into a sub-network. Enter the sub-network and connect the Null node to Sub-Network Input #1.

Move out of the sub-network and save it as a HDA. This will be the FBX export HDA, so name it accordingly.

Create internal structure

Inside the HDA, on the same level as your IN Null node, create an Object Network, name it export_network, and enter it.

Inside export_network, create a Geometry named Input and a ROP Network named FBX_Render.

The structure should now be:

HDA
|
+ IN (Null)
|
+ export_network (Object Network)
  |
  + Input (Geometry)
  |
  + FBX_Render (ROP Network)

Bring in the geometry

Inside the Input Geometry, create an Object Merge node, and in Object 1 path, write ../../../IN to bring in the geometry from the top Null node.

Export the FBX

Inside the FBX_Render ROP Network, create a Filmbox FBX node. In the Export parameter, enter `opfullpath("../..") + "/Input"` to link it to the Input geometry.

Add HDA Parameters

Open the Type Properties for your FBX export HDA: Select the menu Assets/Edit Asset Properties.../<your HDA name>

From the Filmbox FBX node, drag the Save to Disk button to the HDA parameter list, and name it something like "Export FBX". Also drag the Output File parameter to the HDA parameter list. Press Accept to close the Type Properties window, and save your HDA.

Test

Test the export by creating some geometry and linking it to your HDA input. Press the "Export FBX" button in the HDA parameters, and make sure the FBX is saved to the selected output file.

Step 2: Use a TOP Network to create variations and export them

In the /obj network, create a TOP Network.

Use Wedge nodes to create variations of parameters.

Link the Wedge nodes to a HDA Processor, which refers to your HDA in the HDA file parameter. In Batch Mode, select "All items in One Batch" to speed up the processing. In the HDA Parameters tab, use @attribute_name syntax to input the parameters created in the wedges into the HDA parameters.

Link the HDA Processor to a new HDA Processor node. Name the new node "export", and link to your FBX Export HDA from step 1 in the HDA File parameter. Make sure that Batch Mode is set to "All Items in One Batch", and that "Create File Inputs" is selected under Asset Inputs. Disable Write Outputs under Asset Outputs. Under HDA Parameters tab, select the Export checkmark, and enter a suitable file name. You can use the backtick syntax to refer to attributes in the filename, for instance:

$HIP/rabbit.`@pdg_index`.fbx

will name each exported file with an index from 0, rabbit.0.fbx, rabbit.1.fbx, and so on.

Step 3: Run the TOP network to produce the files.

Right-click on the "export" HDA Processor and select "Dirty and Cook This Node" (or press Shift-V). The network will run, and the files will be created.