public static List<HEU_Handle> FindOrGenerateHandles(HEU_SessionBase session, ref HAPI_AssetInfo assetInfo, HAPI_NodeId assetID, string assetName, HEU_Parameters parameters, List<HEU_Handle> currentHandles) { List<HEU_Handle> newHandles = new List<HEU_Handle>(); if (assetInfo.handleCount == 0) { return newHandles; } HAPI_HandleInfo[] handleInfos = new HAPI_HandleInfo[assetInfo.handleCount]; HEU_GeneralUtility.GetArray1Arg(assetID, session.GetHandleInfo, handleInfos, 0, assetInfo.handleCount); for (int i = 0; i < handleInfos.Length; ++i) { if (handleInfos[i].bindingsCount <= 0) { continue; } string handleName = HEU_SessionManager.GetString(handleInfos[i].nameSH, session); HEU_Handle.HEU_HandleType handleType = HEU_Handle.HEU_HandleType.UNSUPPORTED; string handleTypeString = HEU_SessionManager.GetString(handleInfos[i].typeNameSH, session); if (handleTypeString.Equals(HEU_Defines.HAPI_HANDLE_TRANSFORM)) { handleType = HEU_Handle.HEU_HandleType.XFORM; } else { // Commented out warning as it gets annoying, especially with "Curve" handles //Debug.LogWarningFormat("Asset {0} has unsupported Handle type {0} for handle {1}", assetName, handleName, handleTypeString); continue; } HEU_Handle newHandle = null; foreach (HEU_Handle curHandle in currentHandles) { if (curHandle.HandleName.Equals(handleName)) { newHandle = curHandle; break; } } if (newHandle == null) { newHandle = ScriptableObject.CreateInstance<HEU_Handle>(); } bool bSuccess = newHandle.SetupHandle(session, assetID, i, handleName, handleType, ref handleInfos[i], parameters); if (bSuccess) { newHandles.Add(newHandle); //Debug.LogFormat("Found handle {0} of type {1}", handleName, handleTypeString); } } return newHandles; }
public static bool CreateAndCookAssetNode(HEU_SessionBase session, string assetName, bool bCookTemplatedGeos, out HAPI_NodeId newAssetID) { newAssetID = HEU_Defines.HEU_INVALID_NODE_ID; // Create top level node. Note that CreateNode will cook the node if HAPI was initialized with threaded cook setting on. bool bResult = session.CreateNode(-1, assetName, "", false, out newAssetID); if (!bResult) { return(false); } // Make sure cooking is successfull before proceeding. Any licensing or file data issues will be caught here. if (!ProcessHoudiniCookStatus(session, assetName)) { return(false); } // In case the cooking wasn't done previously, force it now. bResult = CookNodeInHoudini(session, newAssetID, bCookTemplatedGeos, assetName); if (!bResult) { // When cook failed, deleted the node created earlier session.DeleteNode(newAssetID); newAssetID = HEU_Defines.HEU_INVALID_NODE_ID; return(false); } // Get the asset ID HAPI_AssetInfo assetInfo = new HAPI_AssetInfo(); bResult = session.GetAssetInfo(newAssetID, ref assetInfo); if (bResult) { // Check for any errors HAPI_ErrorCodeBits errors = session.CheckForSpecificErrors(newAssetID, (HAPI_ErrorCodeBits)HAPI_ErrorCode.HAPI_ERRORCODE_ASSET_DEF_NOT_FOUND); if (errors > 0) { // TODO: revisit for UI improvement HEU_EditorUtility.DisplayDialog("Asset Missing Sub-asset Definitions", "There are undefined nodes. This is due to not being able to find specific " + "asset definitions.", "Ok"); return(false); } } return(true); }
// GEOMETRY GETTERS ------------------------------------------------------------------------------------------- public static string GetUniqueMaterialShopName(HAPI_NodeId assetID, HAPI_NodeId materialID) { HEU_SessionBase sessionBase = GetOrCreateDefaultSession(); if (sessionBase != null) { HAPI_AssetInfo assetInfo = new HAPI_AssetInfo(); if (!sessionBase.GetAssetInfo(assetID, ref assetInfo)) { return ""; } HAPI_MaterialInfo materialInfo = new HAPI_MaterialInfo(); if (!sessionBase.GetMaterialInfo(materialID, ref materialInfo)) { return ""; } HAPI_NodeInfo assetNodeInfo = new HAPI_NodeInfo(); if (!sessionBase.GetNodeInfo(assetID, ref assetNodeInfo)) { return ""; } HAPI_NodeInfo materialNodeInfo = new HAPI_NodeInfo(); if (!sessionBase.GetNodeInfo(materialInfo.nodeId, ref materialNodeInfo)) { return ""; } string assetNodeName = HEU_SessionManager.GetString(assetNodeInfo.internalNodePathSH, sessionBase); string materialNodeName = HEU_SessionManager.GetString(materialNodeInfo.internalNodePathSH, sessionBase); if (assetNodeName.Length > 0 && materialNodeName.Length > 0) { // Remove assetNodeName from materialNodeName. Extra position is for separator. string materialName = materialNodeName.Substring(assetNodeName.Length + 1); return materialName.Replace("/", "_"); } } return ""; }
/// <summary> /// Returns the asset info for the given node /// </summary> /// <param name="nodeID">The node to retrieve the asset info for</param> /// <param name="assetInfo">The asset info structure to populate</param> /// <returns>True if successfully queried the asset info</returns> public virtual bool GetAssetInfo(HAPI_NodeId nodeID, ref HAPI_AssetInfo assetInfo) { return false; }