Beispiel #1
0
        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);
        }