public override bool CreateInputNodeWithDataUpload(HEU_SessionBase session, int connectNodeID, GameObject inputObject, out int inputNodeID) { inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID; if (!HEU_HAPIUtility.IsNodeValidInHoudini(session, connectNodeID)) { Debug.LogError("Connection node is invalid."); return false; } HEU_InputDataTilemap inputTilemap = GenerateTilemapDataFromGameObject(inputObject); string inputName = null; HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID; session.CreateInputNode( out newNodeID, inputName ); if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsNodeValidInHoudini(session, newNodeID)) { Debug.LogError("Failed to create new input node in Houdini session!"); return false; } inputNodeID = newNodeID; if (!session.CookNode(inputNodeID, false)) { Debug.LogError("New input node failed to cook!"); return false; } return UploadData(session, inputNodeID, inputTilemap); }
public static bool CreateAndCookInputAsset(HEU_SessionBase session, string assetName, bool bCookTemplatedGeos, out HAPI_NodeId newAssetID) { newAssetID = HEU_Defines.HEU_INVALID_NODE_ID; if (!session.CreateInputNode(out newAssetID, null)) { return(false); } // Make sure cooking is successfull before proceeding. Any licensing or file data issues will be caught here. if (!HEU_HAPIUtility.ProcessHoudiniCookStatus(session, assetName)) { return(false); } // In case the cooking wasn't done previously, force it now. bool bResult = HEU_HAPIUtility.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); } // After cooking, set an empty partinfo HAPI_GeoInfo inputGeoInfo = new HAPI_GeoInfo(); if (!session.GetDisplayGeoInfo(newAssetID, ref inputGeoInfo)) { return(false); } HAPI_PartInfo newPart = new HAPI_PartInfo(); newPart.init(); newPart.id = 0; newPart.vertexCount = 0; newPart.faceCount = 0; newPart.pointCount = 0; // TODO: always set to mesh type? newPart.type = HAPI_PartType.HAPI_PARTTYPE_MESH; if (!session.SetPartInfo(inputGeoInfo.nodeId, 0, ref newPart)) { Debug.LogErrorFormat(HEU_Defines.HEU_NAME + ": Failed to set partinfo for input node!"); return(false); } return(true); }
/// <summary> /// Create input node for the given inputObject, and upload its mesh data (along with LOD meshes). /// Outputs the inputNodeID if successfully uploaded mesh data and returns true. /// </summary> /// <param name="session">Session to create input node</param> /// <param name="assetID">The parent asset ID</param> /// <param name="inputObject">The input GameObject to query mesh data from</param> /// <param name="inputNodeID">Output of input node ID if successfully created</param> /// <returns>True if successfully created and uploaded mesh data</returns> public static bool CreateInputNodeWithGeoData(HEU_SessionBase session, HAPI_NodeId assetID, GameObject inputObject, out HAPI_NodeId inputNodeID) { inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID; if (!HEU_HAPIUtility.IsAssetValidInHoudini(session, assetID)) { return false; } bool bHasLODGroup = false; List<HEU_UploadMeshData> uploadMeshDatas = GenerateMeshDatasFromInputObject(inputObject, out bHasLODGroup); if (uploadMeshDatas == null || uploadMeshDatas.Count == 0) { return false; } // If connected asset is not valid, then need to create an input asset if (inputNodeID == HEU_Defines.HEU_INVALID_NODE_ID) { string inputName = null; HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID; session.CreateInputNode(out newNodeID, inputName); if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsAssetValidInHoudini(session, newNodeID)) { Debug.LogErrorFormat("Failed to create new input node in Houdini session!"); return false; } inputNodeID = newNodeID; if (!session.CookNode(inputNodeID, false)) { Debug.LogErrorFormat("New input node failed to cook!"); return false; } } return UploadInputMeshData(session, inputNodeID, uploadMeshDatas, bHasLODGroup); }
/// <summary> /// Creates a mesh input node and uploads the mesh data from inputObject. /// </summary> /// <param name="session">Session that connectNodeID exists in</param> /// <param name="connectNodeID">The node to connect the network to. Most likely a SOP/merge node</param> /// <param name="inputObject">The gameobject containing the mesh components</param> /// <param name="inputNodeID">The created input node ID</param> /// <returns>True if created network and uploaded mesh data.</returns> public override bool CreateInputNodeWithDataUpload(HEU_SessionBase session, HAPI_NodeId connectNodeID, GameObject inputObject, out HAPI_NodeId inputNodeID) { inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID; // Create input node, cook it, then upload the geometry data if (!HEU_HAPIUtility.IsNodeValidInHoudini(session, connectNodeID)) { Debug.LogError("Connection node is invalid."); return false; } // Get upload meshes from input object HEU_InputDataMeshes inputMeshes = GenerateMeshDatasFromGameObject(inputObject); if (inputMeshes == null || inputMeshes._inputMeshes == null || inputMeshes._inputMeshes.Count == 0) { Debug.LogError("No valid meshes found on input objects."); return false; } string inputName = null; HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID; session.CreateInputNode(out newNodeID, inputName); if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsNodeValidInHoudini(session, newNodeID)) { Debug.LogError("Failed to create new input node in Houdini session!"); return false; } inputNodeID = newNodeID; if (!session.CookNode(inputNodeID, false)) { Debug.LogError("New input node failed to cook!"); return false; } return UploadData(session, inputNodeID, inputMeshes); }
/// <summary> /// Creates a mesh input node and uploads the mesh data from inputObject. /// </summary> /// <param name="session">Session that connectNodeID exists in</param> /// <param name="connectNodeID">The node to connect the network to. Most likely a SOP/merge node</param> /// <param name="inputObject">The gameobject containing the mesh components</param> /// <param name="inputNodeID">The created input node ID</param> /// <returns>True if created network and uploaded mesh data.</returns> public override bool CreateInputNodeWithDataUpload(HEU_SessionBase session, HAPI_NodeId connectNodeID, GameObject inputObject, out HAPI_NodeId inputNodeID) { inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID; // Create input node, cook it, then upload the geometry data if (!HEU_HAPIUtility.IsNodeValidInHoudini(session, connectNodeID)) { HEU_Logger.LogError("Connection node is invalid."); return false; } bool bExportColliders = settings != null && settings.ExportColliders == true; // Get upload meshes from input object HEU_InputDataMeshes inputMeshes = GenerateMeshDatasFromGameObject(inputObject, bExportColliders); if (inputMeshes == null || inputMeshes._inputMeshes == null || inputMeshes._inputMeshes.Count == 0) { HEU_Logger.LogError("No valid meshes found on input objects."); return false; } string inputName = null; HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID; session.CreateInputNode(out newNodeID, inputName); if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsNodeValidInHoudini(session, newNodeID)) { HEU_Logger.LogError("Failed to create new input node in Houdini session!"); return false; } inputNodeID = newNodeID; if (!UploadData(session, inputNodeID, inputMeshes)) { if (!session.CookNode(inputNodeID, false)) { HEU_Logger.LogError("New input node failed to cook!"); return false; } return false; } bool createMergeNode = false; HAPI_NodeId mergeNodeId = HEU_Defines.HEU_INVALID_NODE_ID; if (bExportColliders) { createMergeNode = true; } if (!createMergeNode) { return true; } HAPI_NodeId parentId = HEU_HAPIUtility.GetParentNodeID(session, newNodeID); if (!session.CreateNode(parentId, "merge", null, false, out mergeNodeId)) { HEU_Logger.LogErrorFormat("Unable to create merge SOP node for connecting input assets."); return false; } if (!session.ConnectNodeInput(mergeNodeId, 0, newNodeID)) { HEU_Logger.LogErrorFormat("Unable to connect to input node!"); return false; } if (!session.SetNodeDisplay(mergeNodeId, 1)) { HEU_Logger.LogWarningFormat("Unable to set display flag!"); } inputNodeID = mergeNodeId; if (bExportColliders) { if (!UploadColliderData(session, mergeNodeId, inputMeshes, parentId)) { return false; } } if (!session.CookNode(inputNodeID, false)) { HEU_Logger.LogError("New input node failed to cook!"); return false; } return true; }