示例#1
0
        private static void OnScriptsReloaded()
        {
            HEU_InputInterfaceTerrain inputInterface = new HEU_InputInterfaceTerrain();

            HEU_InputUtility.RegisterInputInterface(inputInterface);
            #if UNITY_2019_2_OR_NEWER
            // Make sure that the default terrain material is always included in the build
            HEU_AssetDatabase.AddAlwaysIncludedShader("Nature/Terrain/Diffuse");
            #endif
        }
示例#2
0
	public void UploadInputObjectTransforms(HEU_SessionBase session)
	{
	    // Only need to upload Mesh inputs, since HDA inputs don't upload transform
	    if (_nodeID == HEU_Defines.HAPI_INVALID_PARM_ID || _inputObjectType != InputObjectType.UNITY_MESH)
	    {
		return;
	    }

	    int numInputs = GetConnectedInputCount();
	    for (int i = 0; i < numInputs; ++i)
	    {
		HAPI_NodeId connectedNodeID = GetConnectedNodeID(i);
		if (connectedNodeID != HEU_Defines.HEU_INVALID_NODE_ID && _inputObjects[i]._gameObject != null)
		{
		    HEU_InputUtility.UploadInputObjectTransform(session, _inputObjects[i], connectedNodeID, _keepWorldTransform);
		}
	    }
	}
示例#3
0
		public bool UploadInputObjectTransforms(HEU_SessionBase session)
		{
			if (_nodeID == HEU_Defines.HAPI_INVALID_PARM_ID)
			{
				return false;
			}

			if (_inputObjectType != InputObjectType.UNITY_MESH)
			{
				return false;
			}

			for (int i = 0; i < _inputObjects.Count; ++i)
			{
				if(_inputObjects[i]._gameObject == null)
				{
					continue;
				}

				HEU_InputUtility.UploadInputObjectTransform(session, _inputObjects[i], _inputObjectsConnectedAssetIDs[i], _keepWorldTransform);
			}

			return false;
		}
示例#4
0
		private static void OnScriptsReloaded()
		{
			HEU_InputInterfaceMesh inputInterface = new HEU_InputInterfaceMesh();
			HEU_InputUtility.RegisterInputInterface(inputInterface);
		}
示例#5
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);

		    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();
	}
示例#6
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();
	}
示例#7
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)
			{
				if(_inputObjects == null || _inputObjects.Count == 0)
				{
					DisconnectAndDestroyInputAssets(session);
				}
				else
				{
					DisconnectAndDestroyInputAssets(session);

					bool bResult = HEU_InputUtility.CreateInputNodeWithMultiObjects(session, _nodeID, ref _connectedNodeID, ref _inputObjects, ref _inputObjectsConnectedAssetIDs, _keepWorldTransform);
					if(!bResult)
					{
						DisconnectAndDestroyInputAssets(session);
						return;
					}

					ConnectInputNode(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 HDA. Note only 1 connection supported.

				if (IsInputAssetConnected())
				{
					DisconnectInputAssetActor(session);
				}

				if (_inputAsset != null)
				{
					HEU_HoudiniAssetRoot inputAssetRoot = _inputAsset.GetComponent<HEU_HoudiniAssetRoot>();
					if(inputAssetRoot != null && inputAssetRoot._houdiniAsset != null)
					{
						if (!inputAssetRoot._houdiniAsset.IsAssetValidInHoudini(session))
						{
							// Force a recook if its not valid (in case it hasn't been loaded into the session)
							inputAssetRoot._houdiniAsset.RequestCook(true, false, true, true);
						}

						ConnectInputAssetActor(session);
					}
					else
					{
						Debug.LogWarningFormat("The input GameObject {0} is not a valid HDA asset.", _inputAsset.name);
					}
				}
			}
			//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();
		}
示例#8
0
		/// <summary>
		/// Register this interface class with HEU_InputUtility
		/// so that it will be used on input gameobjects
		/// </summary>
		public void RegisterInterface()
		{
			HEU_InputUtility.RegisterInputInterface(this);
		}