Ejemplo n.º 1
0
	public void CopyInputValuesTo(HEU_SessionBase session, HEU_InputNode destInputNode)
	{
	    destInputNode._pendingInputObjectType = _inputObjectType;

	    if (destInputNode._inputObjectType == InputObjectType.HDA)
	    {
		destInputNode.ResetConnectionForForceUpdate(session);
	    }

	    destInputNode.RemoveAllInputEntries();

	    foreach (HEU_InputObjectInfo srcInputObject in _inputObjects)
	    {
		HEU_InputObjectInfo newInputObject = new HEU_InputObjectInfo();
		srcInputObject.CopyTo(newInputObject);

		destInputNode._inputObjects.Add(newInputObject);
	    }

	    foreach (HEU_InputHDAInfo srcInputInfo in _inputAssetInfos)
	    {
		HEU_InputHDAInfo newInputInfo = new HEU_InputHDAInfo();
		srcInputInfo.CopyTo(newInputInfo);

		destInputNode._inputAssetInfos.Add(newInputInfo);
	    }

	    destInputNode._keepWorldTransform = _keepWorldTransform;
	    destInputNode._packGeometryBeforeMerging = _packGeometryBeforeMerging;
	}
Ejemplo n.º 2
0
	public void CopyTo(HEU_InputHDAInfo destInfo)
	{
	    destInfo._pendingGO = _pendingGO;
	    destInfo._connectedGO = _connectedGO;

	    destInfo._connectedInputNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
	}
Ejemplo n.º 3
0
	private HEU_InputHDAInfo CreateInputHDAInfo(GameObject inputGameObject)
	{
	    HEU_InputHDAInfo newInputInfo = new HEU_InputHDAInfo();
	    newInputInfo._pendingGO = inputGameObject;
	    newInputInfo._connectedInputNodeID = HEU_Defines.HEU_INVALID_NODE_ID;

	    return newInputInfo;
	}
Ejemplo n.º 4
0
	private HEU_InputHDAInfo InternalAddInputHDAAtEnd(GameObject newInputHDA)
	{
	    HEU_InputHDAInfo inputInfo = CreateInputHDAInfo(newInputHDA);
	    _inputAssetInfos.Add(inputInfo);
	    return inputInfo;
	}
	public static void ExecuteToolOperatorMultiple(string toolName, string toolPath, GameObject[] inputObjects)
	{
	    GameObject outputObjectToSelect = null;

	    GameObject go = HEU_HAPIUtility.InstantiateHDA(toolPath, Vector3.zero, HEU_SessionManager.GetOrCreateDefaultSession(), false);
	    if (go == null)
	    {
		HEU_Logger.LogWarningFormat("Failed to instantiate tool: {0}", toolName);
		return;
	    }

	    HEU_HoudiniAssetRoot assetRoot = go.GetComponent<HEU_HoudiniAssetRoot>();
	    if (assetRoot != null)
	    {
		HEU_HoudiniAsset asset = assetRoot._houdiniAsset;
		HEU_SessionBase session = asset.GetAssetSession(true);

		int numInputs = inputObjects.Length;

		List<HEU_InputNode> inputNodes = asset.GetInputNodes();
		if (inputNodes == null || inputNodes.Count == 0)
		{
		    HEU_Logger.LogErrorFormat("Unable to assign input geometry due to no asset inputs on selected tool.");
		}
		else
		{
		    // User could have selected any number of inputs objects, and asset could have any number of inputs.
		    // So use minimum of either to set input object into asset input.
		    int minInputCount = Mathf.Min(inputNodes.Count, numInputs);
		    for (int i = 0; i < minInputCount; ++i)
		    {
			bool bShouldUseHDA = IsValidInputHDA(inputObjects[i]);

			if (!bShouldUseHDA &&!IsValidInputMesh(inputObjects[i]))
			{
			    continue;
			}
			else if (bShouldUseHDA && !IsValidInputHDA(inputObjects[i]))
			{
			    continue;
			}
			
			GameObject inputObject = inputObjects[i];

			HEU_InputNode inputNode = inputNodes[i];
			inputNode.ResetInputNode(session);


			if (!bShouldUseHDA)
			{
			    inputNode.ChangeInputType(session, HEU_InputNode.InputObjectType.UNITY_MESH);
    
			    HEU_InputObjectInfo inputInfo = inputNode.AddInputEntryAtEndMesh(inputObject);
			    if (inputInfo != null)
			    {
			        inputInfo._useTransformOffset = false;
			        inputNode.KeepWorldTransform = true;
			        inputNode.PackGeometryBeforeMerging = false;
    
			        inputNode.RequiresUpload = true;
			    }
			    else
			    {
			        HEU_Logger.LogErrorFormat("Invalid input format: {0}", inputObject.gameObject.name);
			    }
			}
			else
			{
			    inputNode.ChangeInputType(session, HEU_InputNode.InputObjectType.HDA);

			    HEU_InputHDAInfo inputHDAInfo = inputNode.AddInputEntryAtEndHDA(inputObject);
			    if (inputHDAInfo != null)
			    {
			        inputNode.KeepWorldTransform = true;
			        inputNode.PackGeometryBeforeMerging = false;
    
			        inputNode.RequiresUpload = true;
			    }
			    else
			    {
			        HEU_Logger.LogErrorFormat("Invalid input format: {0}", inputObject.gameObject.name);
			    }
			}
		    }

		    asset.RequestCook(true, true, true, true);

		    outputObjectToSelect = assetRoot.gameObject;
		}
	    }

	    if (outputObjectToSelect != null)
	    {
		HEU_EditorUtility.SelectObject(outputObjectToSelect);
	    }
	}
	public static void ExecuteToolOperatorSingle(string toolName, string toolPath, GameObject[] inputObjects)
	{
	    // Single operator means single asset input. If multiple inputs are provided, create tool for each input.

	    bool bShouldUseHDA = ShouldUseHDA(inputObjects);

	    List<GameObject> outputObjectsToSelect = new List<GameObject>();

	    int numInputs = inputObjects.Length;
	    for (int i = 0; i < numInputs; ++i)
	    {
		if (inputObjects[i] == null)
		{
		    continue;
		}

		if (!bShouldUseHDA && !IsValidInputMesh(inputObjects[i]))
		{
		    HEU_Logger.LogWarningFormat("Specified object {0} does not contain a valid mesh!", inputObjects[i].name);
		    continue;
		}

		if (bShouldUseHDA && !IsValidInputHDA(inputObjects[i]))
		{
		    HEU_Logger.LogWarningFormat("Specified object {0} does not contain a valid HDA input!", inputObjects[i].name);
		    continue;
		}

		GameObject inputObject = inputObjects[i];

		GameObject go = HEU_HAPIUtility.InstantiateHDA(toolPath, Vector3.zero, HEU_SessionManager.GetOrCreateDefaultSession(), false);
		if (go != null)
		{
		    HEU_HoudiniAssetRoot assetRoot = go.GetComponent<HEU_HoudiniAssetRoot>();
		    if (assetRoot != null)
		    {
			HEU_HoudiniAsset asset = assetRoot._houdiniAsset;
			HEU_SessionBase session = asset.GetAssetSession(true);

			List<HEU_InputNode> inputNodes = asset.GetInputNodes();
			if (inputNodes == null || inputNodes.Count == 0)
			{
			    HEU_Logger.LogErrorFormat("Unable to assign input geometry due to no asset inputs on selected tool.");
			}
			else
			{
			    HEU_InputNode inputNode = inputNodes[0];

			    inputNode.ResetInputNode(session);

			    if (!bShouldUseHDA)
			    {
				inputNode.ChangeInputType(session, HEU_InputNode.InputObjectType.UNITY_MESH);

				HEU_InputObjectInfo inputInfo = inputNode.AddInputEntryAtEndMesh(inputObject);
				if (inputInfo != null)
				{
				    inputInfo._useTransformOffset = false;
				    inputNode.KeepWorldTransform = true;
				    inputNode.PackGeometryBeforeMerging = false;

				    inputNode.RequiresUpload = true;

				    asset.RequestCook(true, true, true, true);

				    outputObjectsToSelect.Add(assetRoot.gameObject);
				}
				else
				{
				    HEU_Logger.LogErrorFormat("Invalid input format: {0}", inputObject.gameObject.name);
				}
			    }
			    else
			    {
				inputNode.ChangeInputType(session, HEU_InputNode.InputObjectType.HDA);

				HEU_InputHDAInfo inputHDAInfo = inputNode.AddInputEntryAtEndHDA(inputObject);
				if (inputHDAInfo != null)
				{
				    inputNode.KeepWorldTransform = true;
				    inputNode.PackGeometryBeforeMerging = false;

				    inputNode.RequiresUpload = true;
				    asset.RequestCook(true, true, true, true);
				    outputObjectsToSelect.Add(assetRoot.gameObject);
				}
				else
				{
				    HEU_Logger.LogErrorFormat("Invalid input format: {0}", inputObject.gameObject.name);
				}
			    }
			}
		    }
		}
		else
		{
		    HEU_Logger.LogWarningFormat("Failed to instantiate tool: {0}", toolName);
		}
	    }

	    if (outputObjectsToSelect.Count > 0)
	    {
		HEU_EditorUtility.SelectObjects(outputObjectsToSelect.ToArray());
	    }
	}