General Workflow for Houdini HDK C++ Development (AI-Assisted Version)

🛠️ General Workflow for Houdini HDK C++ Development (AI-Assisted Version)

General Workflow for Houdini HDK C++ Development (AI-Assisted Version)

Core Concept: AI writes logic, CMake manages builds, VS writes code, Houdini verifies results.

Phase One: Setup and Skeleton

Do not start from scratch; establish a standardized directory structure.

1. Create Folder Structure

Create a project directory on your development drive (e.g., D drive):

Plaintext

MyNewNode/
├── CMakeLists.txt       <-- Build script (universal template)
└── src/
    ├── SOP_MyNode.h     <-- Header file (facade, class definition)
    └── SOP_MyNode.C     <-- Source file (brain, logic implementation)

2. Fill in <span>CMakeLists.txt</span> (Universal Template)

Copy this template; you only need to change the names in <span>project(...)</span> and <span>add_library(...)</span>.

CMake

cmake_minimum_required( VERSION 3.17 )
project( SOP_MyNode ) # <--- Change here: Project name

# 1. Environment Location
list( APPEND CMAKE_PREFIX_PATH "$ENV{HFS}/toolkit/cmake" )
find_package( Houdini REQUIRED )

# 2. Include and Auto-generate
include_directories( src )
houdini_generate_proto_headers( FILES src/SOP_MyNode.C ) # <--- Change here: Source file

# 3. Define Library
add_library( SOP_MyNode SHARED # <--- Change here: Library name
    src/SOP_MyNode.C           # <--- Change here
    src/SOP_MyNode.h           # <--- Change here
)

# 4. Link and Install
target_link_libraries( SOP_MyNode Houdini )
target_include_directories( SOP_MyNode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} )
houdini_configure_target( SOP_MyNode )

# 5. Auto-install to documentation directory (note version number)
install( TARGETS SOP_MyNode DESTINATION "$ENV{USERPROFILE}/Documents/houdini21.0/dso" )

Phase Two: AI Code Generation (Coding)

Use Antigravity or Cursor, following the “Verb Architecture”.

1. Generate Header File (.h)

Prompt Instruction:

“Create a standard Houdini HDK header file for a SOP node named <span>SOP_MyNode</span>. Inherit from <span>SOP_Node</span>. Use the modern Verb-based architecture boilerplate.”

2. Generate Source File (.C) — Step-by-Step Strategy

Do not let AI write complex algorithms all at once; take it step by step:

  • Step One: Placeholder Logic (Dummy Logic)

    Prompt Instruction:

    “Create SOP_MyNode.C. Include header and proto.

    Use theDsFile raw string to define ONE dummy parameter (e.g., float ‘tolerance’).

    In cookMySop, just implement a simple logic: Copy the Input 0 geometry to Output.

    Register the operator as my_node.

    Ensure no encoding issues (UTF-8).”

    Purpose: Ensure the pipeline is functional, and the node can display in Houdini without errors.

  • Step Two: Inject Core Algorithm (Core Algorithm)

    Prompt Instruction:

    “Now replace the cookMySop logic with [your algorithm description].

    Example: Iterate all primitives, calculate average position, and create a point there.”

Phase Three: Build and Compile

Use Houdini Command Line Tools (Administrator privileges).

1. Initialize Project (Do this only once)

Bash

d:
cd D:\MyNewNode
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64

2. Compile and Install (Run after every code change)

⚠️ Golden Rule: Close Houdini before compiling!

Bash

cmake --build . --config RelWithDebInfo --target install

Phase Four: Debugging and Iteration

This is the most critical skill enhancement phase.

1. Encountering Compile Errors

  • API does not exist / is not a member:

    • Action: Do not guess. Directly go to the path in the error message, open the <span>.h</span> header file to check the source code.

    • Example: Just like finding <span>GU_RayInfo</span> in <span>myT</span>.

  • Chinese garbled text (C4819):

    • Action: Ensure the file is saved as UTF-8, and try not to write Chinese comments in the code.

2. Encountering Logic Errors

  • Houdini crashed: Check if the pointer is null (<span>!gdp</span><code><span>) and if the array is out of bounds.</span>

  • Incorrect results:

    • Make minor logic changes in C++.

    • Close Houdini -> Compile -> Open Houdini -> Test.

Phase Five: Advanced Techniques

  1. Multi-object Loop:

    Try to iterate using GA_FOR_ALL_PRIMITIVES in C++, do not rely on Houdini’s For-Loop node.

  2. Parameter Definition:

    Stick to defining parameters in the .C file using theDsFile (Raw String), do not modify the .h file.

  3. Houdini Engine:

    If you want to use it in UE/Unity, ensure the Houdini version pointed to by UE matches the version you compiled the plugin with.

📄 Your Common Command Cheat Sheet

Action Command
Switch to D drive <span>d:</span>
Enter directory <span>cd D:\ProjectName</span>
Generate VS Project <span>cmake .. -G "Visual Studio 17 2022" -A x64</span>
Compile and Install <span>cmake --build . --config RelWithDebInfo --target install</span>
Invoke AI <span>Ctrl + L</span> (Chat) or <span>Ctrl + I</span> (Inline)

With this map, developing any HDK node in the future will be a fill-in-the-blank question. Happy coding!

Leave a Comment