Пример #1
0
        /// <summary>
        /// Load a NodeSync file and create its construct in Unity.
        /// </summary>
        /// <param name="filePath">Path to the NodeSync file</param>
        /// <param name="name">Name of the NodeSync node</param>
        void CreateNodeSyncFromFile(string filePath, string name)
        {
            HEU_SessionBase session = HEU_SessionManager.GetDefaultSession();

            if (session == null || !session.IsSessionValid())
            {
                return;
            }

            HAPI_NodeId parentNodeID = -1;
            string      nodeName     = name;
            HAPI_NodeId newNodeID    = -1;

            // This loads the node network from file, and returns the node that was created
            // with newNodeID. It is either a SOP object, or a subnet object.
            // The actual loader (HEU_ThreadedTaskLoadGeo) will deal with either case.
            if (!session.LoadNodeFromFile(filePath, parentNodeID, nodeName, true, out newNodeID))
            {
                Log(string.Format("Failed to load node network from file: {0}.", filePath));
                return;
            }

            // Wait until finished
            if (!HEU_HAPIUtility.ProcessHoudiniCookStatus(session, nodeName))
            {
                Log(string.Format("Failed to cook loaded node with name: {0}.", nodeName));
                return;
            }

            GameObject newGO = new GameObject(nodeName);

            HEU_NodeSync nodeSync = newGO.AddComponent <HEU_NodeSync>();

            nodeSync.InitializeFromHoudini(session, newNodeID, nodeName, filePath);
        }
Пример #2
0
        public static bool CreateAndCookCurveAsset(HEU_SessionBase session, string assetName, bool bCookTemplatedGeos, out HAPI_NodeId newAssetID)
        {
            newAssetID = HEU_Defines.HEU_INVALID_NODE_ID;
            if (!session.CreateNode(HEU_Defines.HEU_INVALID_NODE_ID, "SOP/curve", "Curve", true, out newAssetID))
            {
                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, delete the node created earlier
                session.DeleteNode(newAssetID);
                newAssetID = HEU_Defines.HEU_INVALID_NODE_ID;
                return(false);
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Cooks node and returns true if successfull.
        /// </summary>
        /// <param name="nodeID">The node to cook</param>
        /// <param name="bCookTemplatedGeos">Whether to cook templated geos</param>
        /// <returns>True if successfully cooked node</returns>
        public static bool CookNodeInHoudini(HEU_SessionBase session, HAPI_NodeId nodeID, bool bCookTemplatedGeos, string assetName)
        {
            bool bResult = session.CookNode(nodeID, bCookTemplatedGeos);

            if (bResult)
            {
                return(HEU_HAPIUtility.ProcessHoudiniCookStatus(session, assetName));
            }

            return(bResult);
        }
Пример #4
0
        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);
        }