Ejemplo n.º 1
0
	/// <summary>
	/// Add the given inputInterface to the registered interface list based on its priority.
	/// </summary>
	/// <param name="inputInterface">Interface to register</param>
	public static void RegisterInputInterface(HEU_InputInterface inputInterface)
	{
	    System.Type inputType = inputInterface.GetType();

	    if (GetInputInterfaceByType(inputType) != null)
	    {
		return;
	    }

	    if (!_inputInterfaces.Contains(inputInterface))
	    {
		// Add to ordered list based on priority
		int numInterfaces = _inputInterfaces.Count;
		if (numInterfaces > 0)
		{
		    for (int i = numInterfaces - 1; i >= 0; i--)
		    {
			if (_inputInterfaces[i] != null && _inputInterfaces[i].Priority <= inputInterface.Priority)
			{
			    _inputInterfaces.Add(inputInterface);
			    //HEU_Logger.LogFormat("Registered {0} at {1}. Total of {2}", inputInterface.GetType(), i, _inputInterfaces.Count);
			    break;
			}
		    }
		}
		else
		{
		    _inputInterfaces.Add(inputInterface);
		    //HEU_Logger.LogFormat("Registered {0} at {1}. Total of {2}", inputInterface.GetType(), _inputInterfaces.Count - 1, _inputInterfaces.Count);
		}
	    }
	}
Ejemplo n.º 2
0
	/// <summary>
	/// Create an input node network and upload the given set of input objects.
	/// This creates a SOP/merge node, and input nodes for each object in inputObjects
	/// which are then connected to the merge node.
	/// It finds the input interface that supports each object in inputObjects for creating
	/// the input node and uploading the data based on the type of data.
	/// </summary>
	/// <param name="session">Session to create the input node in</param>
	/// <param name="assetID">Main asset ID</param>
	/// <param name="connectMergeID">Created SOP/merge node ID</param>
	/// <param name="inputObjects">List of input objects to upload</param>
	/// <param name="inputObjectsConnectedAssetIDs">List of input node IDs for the input nodes created</param>
	/// <param name="bKeepWorldTransform">Whether to use world transform for the input nodes</param>
	/// <returns>True if successfully uploading input nodes</returns>
	public static bool CreateInputNodeWithMultiObjects(HEU_SessionBase session, HAPI_NodeId assetID,
		ref HAPI_NodeId connectMergeID, ref List<HEU_InputObjectInfo> inputObjects, ref List<HAPI_NodeId> inputObjectsConnectedAssetIDs, bool bKeepWorldTransform)
	{
	    // Create the merge SOP node that the input nodes are going to connect to.
	    if (!session.CreateNode(-1, "SOP/merge", null, true, out connectMergeID))
	    {
		Debug.LogErrorFormat("Unable to create merge SOP node for connecting input assets.");
		return false;
	    }

	    int numObjects = inputObjects.Count;
	    for (int i = 0; i < numObjects; ++i)
	    {
		HAPI_NodeId newConnectInputID = HEU_Defines.HEU_INVALID_NODE_ID;
		inputObjectsConnectedAssetIDs.Add(newConnectInputID);

		// Skipping null gameobjects. Though if this causes issues, can always let it continue
		// to create input node, but not upload mesh data
		if (inputObjects[i]._gameObject == null)
		{
		    continue;
		}

		HEU_InputInterface inputInterface = GetInputInterface(inputObjects[i]);
		if (inputInterface == null)
		{
		    Debug.LogWarningFormat("No input interface found for gameobject: {0}. Skipping upload!", inputObjects[i]._gameObject.name);
		    continue;
		}

		bool bResult = inputInterface.CreateInputNodeWithDataUpload(session, connectMergeID, inputObjects[i]._gameObject, out newConnectInputID);
		if (!bResult || newConnectInputID == HEU_Defines.HEU_INVALID_NODE_ID)
		{
		    Debug.LogError("Failed to upload input.");
		    continue;
		}

		inputObjectsConnectedAssetIDs[i] = newConnectInputID;

		if (!session.ConnectNodeInput(connectMergeID, i, newConnectInputID))
		{
		    Debug.LogErrorFormat("Unable to connect input nodes!");
		    return false;
		}

		UploadInputObjectTransform(session, inputObjects[i], newConnectInputID, bKeepWorldTransform);
	    }

	    return true;
	}
Ejemplo n.º 3
0
	/// <summary>
	/// Return the input interface that can upload the given inputObjectInfo's data.
	/// It checks the inputObjectInfo._inputInterfaceType to see if it was previously
	/// uploaded, and if so, uses the same interface.
	/// </summary>
	/// <param name="inputObjectInfo">Input object info used to find the interface</param>
	/// <returns>Compatible input interface or null</returns>
	internal static HEU_InputInterface GetInputInterface(HEU_InputObjectInfo inputObjectInfo)
	{
	    HEU_InputInterface inputInterface = null;
	    if (inputObjectInfo._inputInterfaceType == null)
	    {
		inputInterface = GetInputInterfaceByType(inputObjectInfo._inputInterfaceType);
	    }
	    if (inputInterface == null)
	    {
		inputInterface = GetInputInterface(inputObjectInfo._gameObject);
		if (inputInterface != null)
		{
		    inputObjectInfo._inputInterfaceType = inputInterface.GetType();
		}
	    }
	    return inputInterface;
	}
Ejemplo n.º 4
0
	/// <summary>
	/// Remove the given input interface from list of registered interfaces.
	/// </summary>
	/// <param name="inputInterface">The input interface to unregister</param>
	public static void UnregisterInputInterface(HEU_InputInterface inputInterface)
	{
	    _inputInterfaces.Remove(inputInterface);
	}