February 19, 2023

Houdini Engine for Unity-Plugin API

Houdini Engine for Unity-Plugin API

此文档关于houdini引擎的C# API学习
官方文档位置:
http://www.sidefx.com/docs/unity/_plugin_a_p_i.html

分为三部分 1> Asset layer 2>Utility layer 3>HAPI layer
1>资产层
即资产创建以及参数获取和修改的操作
包含以下几个类
HEU_HoudiniAssetRoot这是Unity中Houdini Engine资产的根组件。它是轻量级的,仅充当层次结构的根并提供用户界面。
HEU_HoudiniAsset这是主要的资产组件,其中包含资产的所有元数据,以及构建,烹饪,查询和修改资产的功能。
HEU_ParameterUtility包含便利功能,用于查询和修改资产上的参数。
官方提供了一个相关的实例文档:
Plugins / HoudiniEngineUnity / Scripts / Examples / HEU_ExampleEvergreenQuery.cs

此目录为unity houdini 引擎的包位置下。

实例文档笔记
using HoudiniEngineUnity;

HEU_AssetDatabase.GetAssetFullPath

//Manages the asset database to store persistent assets such as materials, textures, asset data, etc. Wraps around Unity AssetDatabase. Only available in Editor. Probably not needed at runtime as data probably does not need to persist past session.
//Given relative path to an asset (with Assets/ in the path), this returns the full path to it.

HEU_SessionBase
//Base class for a Houdini Engine session. Contains functionality to interface with the Houdini Engine for a particular session.

HEU_SessionManager.GetOrCreateDefaultSession()
//Manages a session for Houdini Engine. Supports all types of sessions.
//获取或者创建有效会话

HEU_HAPIUtility.InstantiateHDA(evergreenFullPath, Vector3.zero, session, true);
//houdini引擎的工作,如创建hda,cook等。
//Load and instantiate an HDA asset in Unity and Houdini, for the asset located at given path.创建指定路径的hda

public static GameObject InstantiateHDA(string filePath, Vector3 initialPosition, HEU_SessionBase session, bool bBuildAsync)
FilePath文件路径 initialPosition 初始位置 获取会话 是否重载

HEU_EditorUtility.SelectObject(rootGO);
//Wrapper around Unity Editor functions.Unity编辑器函数的包装。
//选择物体 返回数组

HEU_HoudiniAsset houdiniAsset = QueryHoudiniAsset(rootGO);
//HEU_HoudiniAsset 资产组件
//QueryHoudiniAsset Shows how to get the HEU_HoudiniAsset component from a HDA root gameobject.

// Make sure the HDA is cooked before querying or changing its properties.
CookAsset(houdiniAsset);

// Example of querying and changing parms.
ChangeParmsAndCook(houdiniAsset);

// This will query objects, geometry, parts, and attributes in the asset.
QueryObjects(houdiniAsset);

// This will query the gravity attribute.
QueryAttribute(houdiniAsset, “EvergreenGenerator”, “EvergreenGenerator1”, 0, “Cd”);

HEU_HoudiniAssetRoot
//The root object of a Houdini Engine asset. Used for organizing hierarchy, and more importantly displaying custom UI.

关于本文

本文作者 Master Gong Sheng, 许可由 CC BY-NC 4.0.