public void UploadInput(HEU_SessionBase session)
	{
	    if (_nodeID == HEU_Defines.HEU_INVALID_NODE_ID)
	    {
		Debug.LogErrorFormat("Input Node ID is invalid. Unable to upload input. Try recooking.");
		return;
	    }

	    if (_pendingInputObjectType != _inputObjectType)
	    {
		ChangeInputType(session, _pendingInputObjectType);
	    }

	    if (_inputObjectType == InputObjectType.UNITY_MESH)
	    {
		// Connect regular gameobjects

		if (_inputObjects == null || _inputObjects.Count == 0)
		{
		    DisconnectAndDestroyInputs(session);
		}
		else
		{
		    DisconnectAndDestroyInputs(session);

		    List<HEU_InputObjectInfo> inputObjectClone = new List<HEU_InputObjectInfo>(_inputObjects);

		    // Special input interface preprocessing
		    for (int i = inputObjectClone.Count - 1; i >= 0; i--)
		    {
			if (inputObjectClone[i] == null || inputObjectClone[i]._gameObject == null)
			{
			    continue;
			}

			HEU_BoundingVolume boundingVolume = inputObjectClone[i]._gameObject.GetComponent<HEU_BoundingVolume>();
			if (boundingVolume == null)
			{
			    continue;
			}

			List<GameObject> boundingBoxObjects = boundingVolume.GetAllIntersectingObjects();
			if (boundingBoxObjects == null)
			{
			    continue;
			}

			foreach (GameObject obj in boundingBoxObjects)
			{
			    if (obj == null)
			    {
				continue;
			    }

			    HEU_InputObjectInfo newObjInfo = new HEU_InputObjectInfo();
			    inputObjectClone[i].CopyTo(newObjInfo);
			    newObjInfo._gameObject = obj;
			    inputObjectClone.Add(newObjInfo);
			}

			// Remove this because it's not a real interface
			inputObjectClone.RemoveAt(i);

		    }

		    // Create merge object, and input nodes with data, then connect them to the merge object
		    bool bResult = HEU_InputUtility.CreateInputNodeWithMultiObjects(session, _nodeID, ref _connectedNodeID, ref inputObjectClone, ref _inputObjectsConnectedAssetIDs, _keepWorldTransform);
		    if (!bResult)
		    {
			DisconnectAndDestroyInputs(session);
			return;
		    }

		    // Now connect from this asset to the merge object
		    ConnectToMergeObject(session);

		    if (!UploadObjectMergeTransformType(session))
		    {
			Debug.LogErrorFormat("Failed to upload object merge transform type!");
			return;
		    }

		    if (!UploadObjectMergePackGeometry(session))
		    {
			Debug.LogErrorFormat("Failed to upload object merge pack geometry value!");
			return;
		    }
		}
	    }
	    else if (_inputObjectType == InputObjectType.HDA)
	    {
		// Connect HDAs

		// First clear all previous input connections
		DisconnectAndDestroyInputs(session);

		// Create merge object, and connect all input HDAs
		bool bResult = HEU_InputUtility.CreateInputNodeWithMultiAssets(session, _parentAsset, ref _connectedNodeID, ref _inputAssetInfos, _keepWorldTransform, -1);
		if (!bResult)
		{
		    DisconnectAndDestroyInputs(session);
		    return;
		}

		// Now connect from this asset to the merge object
		ConnectToMergeObject(session);

		if (!UploadObjectMergeTransformType(session))
		{
		    Debug.LogErrorFormat("Failed to upload object merge transform type!");
		    return;
		}

		if (!UploadObjectMergePackGeometry(session))
		{
		    Debug.LogErrorFormat("Failed to upload object merge pack geometry value!");
		    return;
		}
	    }
	    //else if (_inputObjectType == InputObjectType.CURVE)
	    //{
	    // TODO INPUT NODE - create new Curve SOP (add HEU_Curve here?)
	    //}
	    else
	    {
		Debug.LogErrorFormat("Unsupported input type {0}. Unable to upload input.", _inputObjectType);
	    }

	    RequiresUpload = false;
	    RequiresCook = true;

	    ClearUICache();
	}
Beispiel #2
0
	public void UploadInput(HEU_SessionBase session)
	{
	    if (_nodeID == HEU_Defines.HEU_INVALID_NODE_ID)
	    {
		Debug.LogErrorFormat("Input Node ID is invalid. Unable to upload input. Try recooking.");
		return;
	    }

	    if (_pendingInputObjectType != _inputObjectType)
	    {
		ChangeInputType(session, _pendingInputObjectType);
	    }

	    if (_inputObjectType == InputObjectType.UNITY_MESH)
	    {
		// Connect regular gameobjects

		if (_inputObjects == null || _inputObjects.Count == 0)
		{
		    DisconnectAndDestroyInputs(session);
		}
		else
		{
		    DisconnectAndDestroyInputs(session);

		    // Create merge object, and input nodes with data, then connect them to the merge object
		    bool bResult = HEU_InputUtility.CreateInputNodeWithMultiObjects(session, _nodeID, ref _connectedNodeID, ref _inputObjects, ref _inputObjectsConnectedAssetIDs, _keepWorldTransform);
		    if (!bResult)
		    {
			DisconnectAndDestroyInputs(session);
			return;
		    }

		    // Now connect from this asset to the merge object
		    ConnectToMergeObject(session);

		    if (!UploadObjectMergeTransformType(session))
		    {
			Debug.LogErrorFormat("Failed to upload object merge transform type!");
			return;
		    }

		    if (!UploadObjectMergePackGeometry(session))
		    {
			Debug.LogErrorFormat("Failed to upload object merge pack geometry value!");
			return;
		    }
		}
	    }
	    else if (_inputObjectType == InputObjectType.HDA)
	    {
		// Connect HDAs

		// First clear all previous input connections
		DisconnectAndDestroyInputs(session);

		// Create merge object, and connect all input HDAs
		bool bResult = HEU_InputUtility.CreateInputNodeWithMultiAssets(session, _parentAsset, ref _connectedNodeID, ref _inputAssetInfos, _keepWorldTransform, -1);
		if (!bResult)
		{
		    DisconnectAndDestroyInputs(session);
		    return;
		}

		// Now connect from this asset to the merge object
		ConnectToMergeObject(session);

		if (!UploadObjectMergeTransformType(session))
		{
		    Debug.LogErrorFormat("Failed to upload object merge transform type!");
		    return;
		}

		if (!UploadObjectMergePackGeometry(session))
		{
		    Debug.LogErrorFormat("Failed to upload object merge pack geometry value!");
		    return;
		}
	    }
	    //else if (_inputObjectType == InputObjectType.CURVE)
	    //{
	    // TODO INPUT NODE - create new Curve SOP (add HEU_Curve here?)
	    //}
	    else
	    {
		Debug.LogErrorFormat("Unsupported input type {0}. Unable to upload input.", _inputObjectType);
	    }

	    RequiresUpload = false;
	    RequiresCook = true;

	    ClearUICache();
	}