/// <summary> /// Do the geometry loading in Houdini in a thread. /// Creates a file node, loads the bgeo, then retrives the geometry into local buffers. /// </summary> protected override void DoWork() { _loadData._loadStatus = HEU_LoadData.LoadStatus.STARTED; //HEU_Logger.LogFormat("DoWork: Loading {0}", _filePath); if (_session == null || !_session.IsSessionValid()) { AppendLog(HEU_LoadData.LoadStatus.ERROR, "Invalid session!"); return; } if (_loadType == LoadType.FILE) { if (!DoFileLoad()) { return; } } else if (_loadType == LoadType.ASSET) { if (!DoAssetLoad()) { return; } } // For LoadType.NODE, assume the node already exists in Houdini session // We simply recook and generate geometry HAPI_NodeId cookNodeID = GetCookNodeID(); if (cookNodeID == HEU_Defines.HEU_INVALID_NODE_ID) { AppendLog(HEU_LoadData.LoadStatus.ERROR, string.Format("Unable to get cook node.")); return; } if (_loadCallback != null) { _loadCallback(_session, _loadData, HEU_LoadCallbackType.PRECOOK); } // Cooking it will update the node so we can query its details // This will block until cook has completed or failed if (!CookNode(_session, cookNodeID)) { return; } if (_loadCallback != null) { _loadCallback(_session, _loadData, HEU_LoadCallbackType.POSTCOOK); } // Get nodes to cook based on the type of node HAPI_NodeInfo nodeInfo = new HAPI_NodeInfo(); if (!_session.GetNodeInfo(cookNodeID, ref nodeInfo)) { return; } HAPI_ObjectInfo[] objectInfos = null; HAPI_Transform[] objectTransforms = null; if (!HEU_HAPIUtility.GetObjectInfos(_session, cookNodeID, ref nodeInfo, out objectInfos, out objectTransforms)) { return; } _loadData._loadedObjects = new List<HEU_LoadObject>(); bool bResult = true; // For each object, get the display and editable geometries contained inside. for (int i = 0; i < objectInfos.Length; ++i) { bResult &= LoadObjectBuffers(_session, ref objectInfos[i]); } if (bResult) { AppendLog(HEU_LoadData.LoadStatus.SUCCESS, "Completed!"); } else { AppendLog(HEU_LoadData.LoadStatus.ERROR, "Failed to load geometry!"); } }