コード例 #1
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);
        }
コード例 #2
0
		private void DeleteSessionData()
		{
			if (_fileNodeID != HEU_Defines.HEU_INVALID_NODE_ID)
			{
				HEU_SessionBase session = GetHoudiniSession(false);
				if (session != null)
				{
					session.DeleteNode(_fileNodeID);
				}

				_fileNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
			}
		}
コード例 #3
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);
        }
コード例 #4
0
	private void DisconnectAndDestroyInputs(HEU_SessionBase session)
	{
	    // First disconnect the merge node from its connections
	    DisconnectConnectedMergeNode(session);

	    // Clear out input HDA hooks (upstream callback)
	    ClearConnectedInputHDAs();

	    if (session != null)
	    {
		// Delete the input nodes that were created
		foreach (HAPI_NodeId nodeID in _inputObjectsConnectedAssetIDs)
		{
		    if (nodeID != HEU_Defines.HEU_INVALID_NODE_ID)
		    {
			session.DeleteNode(nodeID);
		    }
		}

		// Delete the SOP/merge we created
		if (_connectedNodeID != HEU_Defines.HEU_INVALID_NODE_ID && HEU_HAPIUtility.IsNodeValidInHoudini(session, _connectedNodeID))
		{
		    // We'll delete the parent Object because we presume to have created the SOP/merge ourselves.
		    // If the parent Object doesn't get deleted, it sticks around unused.
		    HAPI_NodeInfo parentNodeInfo = new HAPI_NodeInfo();
		    if (session.GetNodeInfo(_connectedNodeID, ref parentNodeInfo))
		    {
			if (parentNodeInfo.parentId != HEU_Defines.HEU_INVALID_NODE_ID)
			{
			    session.DeleteNode(parentNodeInfo.parentId);
			}
		    }
		}
	    }

	    _inputObjectsConnectedAssetIDs.Clear();
	    _connectedNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
	}
コード例 #5
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);
        }
コード例 #6
0
        public virtual void DeleteSessionData()
        {
            if (_cookNodeID != HEU_Defines.HEU_INVALID_NODE_ID)
            {
                HEU_SessionBase session = GetHoudiniSession(false);
                if (session != null)
                {
                    HAPI_NodeId deleteID = _cookNodeID;

                    if (_deleteParent)
                    {
                        deleteID = GetParentNodeID(session);
                    }

                    session.DeleteNode(deleteID);
                }

                _cookNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
            }
        }