public bool IsEquivalentTo(HEU_AttributeData other)
	{

	    bool bResult = true;

	    string header = "HEU_AttributeData";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._attributeInfo.ToTestObject(), other._attributeInfo.ToTestObject(), ref bResult, header, "_attributeInfo");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._name, other._name, ref bResult, header, "_name");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._attributeType, other._attributeType, ref bResult, header, "_attributeType");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._intValues, other._intValues, ref bResult, header, "_intValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._floatValues, other._floatValues, ref bResult, header, "_floatValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._stringValues, other._stringValues, ref bResult, header, "_stringValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._attributeState, other._attributeState, ref bResult, header, "_attributeState");

	    return bResult;
	}
Esempio n. 2
0
	public bool IsEquivalentTo(HEU_Handle other)
	{
	    bool bResult = true;

	    string header = "HEU_Handle";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleName, other._handleName, ref bResult, header, "_handleName");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleType,other._handleType, ref bResult, header, "_handleType");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleIndex, other._handleIndex, ref bResult, header, "_handleIndex");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleParamTranslateBinding, other._handleParamTranslateBinding, ref bResult, header, "_handleParamTranslateBinding");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleParamRotateBinding, other._handleParamRotateBinding, ref bResult, header, "_handleParamRotateBinding");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleParamScaleBinding, other._handleParamScaleBinding, ref bResult, header, "_handleParamScaleBinding");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handlePosition, other._handlePosition, ref bResult, header, "_handlePosition");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleRotation, other._handleRotation, ref bResult, header, "_handleRotation");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._handleScale, other._handleScale, ref bResult, header, "_handleScale");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._rstOrder, other._rstOrder, ref bResult, header, "_rstOrder");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._xyzOrder, other._xyzOrder, ref bResult, header, "_xyzOrder");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._convertedTransformEuler.ToTestObject(), other._convertedTransformEuler.ToTestObject(), ref bResult, header, "_convertedTransformEuler");
	    

	    // Skip _materialKey
	 
	    return bResult;
	}
Esempio n. 3
0
	public void OnGUI()
	{
	    using (new GUILayout.VerticalScope())
	    {
		_shelfName = EditorGUILayout.TextField("New Shelf Name", _shelfName);
		using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(_shelfName) || _shelfName.Trim().Length == 0))
		{
		    if (GUILayout.Button("Create"))
		    {
			//HEU_Logger.Log("Shelf name: " + _shelfName);
			HEU_Shelf newShelf = HEU_ShelfTools.AddShelf(_shelfName, _shelfPath);
			if (newShelf != null)
			{
			    HEU_ShelfTools.SaveShelf();
			    HEU_ShelfTools.SetReloadShelves();
			    this.Close();
			}
			else
			{
			    HEU_Logger.LogError("Invalid Shelf! Please check if the name or path is valid.");
			}
		    }
		}

		if (GUILayout.Button("Cancel"))
		{
		    this.Close();
		}
	    }
	}
        public bool IsEquivalentTo(HEU_GeoNode other)
        {
            bool bResult = true;

            string header = "HEU_GeoNode";

            if (other == null)
            {
                HEU_Logger.LogError(header + " Not equivalent");
                return(false);
            }

            HEU_TestHelpers.AssertTrueLogEquivalent(this._geoInfo.ToTestObject(), other._geoInfo.ToTestObject(), ref bResult, header, "_geoInfo");

            //HEU_TestHelpers.AssertTrueLogEquivalent(this._geoName, other._geoName, ref bResult, header, "_geoName");

            HEU_TestHelpers.AssertTrueLogEquivalent(this._parts, other._parts, ref bResult, header, "_part");

            // SKip _containerObjectNode/parentAsset stuff

            HEU_TestHelpers.AssertTrueLogEquivalent(this._geoCurve, other._geoCurve, ref bResult, header, "_geoCurve");

            // Skip volumCache

            HEU_TestHelpers.AssertTrueLogEquivalent(this._volumeCaches, other._volumeCaches, ref bResult, header, "_volumeCaches");


            return(bResult);
        }
	public bool IsEquivalentTo(HEU_AttributesStore other)
	{

	    bool bResult = true;

	    string header = "HEU_AttributesStore";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._geoName, other._geoName, ref bResult, header, "_geoName");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._attributeDatas, other._attributeDatas, ref bResult, header, "_attributeDatas");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._hasColorAttribute, other._hasColorAttribute, ref bResult, header, "_hasColorAttribute");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._localMaterial.ToTestObject(), other._localMaterial.ToTestObject(), ref bResult, header, "_localMaterial");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputTransform.ToTestObject(), other._outputTransform.ToTestObject(), ref bResult, header, "_outputTransform");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._positionAttributeValues, other._positionAttributeValues, ref bResult, header, "_positionAttributeValues");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._vertexIndices, other._vertexIndices, ref bResult, header, "_vertexIndices");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputGameObject, other._outputGameObject, ref bResult, header, "_outputGameObject");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputMesh.ToTestObject(), other._outputMesh.ToTestObject(), ref bResult, header, "_outputMesh");
	    
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputMaterials.ToTestObject(), other._outputMaterials.ToTestObject(), ref bResult, header, "_outputMaterials");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputCollider.ToTestObject(), other._outputCollider.ToTestObject(), ref bResult, header, "_outputColliders");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputColliderMesh.ToTestObject(), other._outputColliderMesh.ToTestObject(), ref bResult, header, "_outputColliderMesh");

	    return bResult;
	}
	public void SyncDirtyAttributesToHoudini(HEU_SessionBase session)
	{
	    if (!UploadAttributeViaMeshInput(session, _geoID, _partID))
	    {
		HEU_Logger.LogError("Unable to upload custom attribute edits!");
	    }
	}
	public static HEU_SessionBase CreateSessionFromType(System.Type type)
	{
#if !UNITY_5_6_OR_NEWER
            HEU_Logger.LogError("Houdini Engine for Unity only supports Unity version 5.6.0 and newer!");
#elif HOUDINIENGINEUNITY_ENABLED
	    if (type == null || type == typeof(HEU_SessionHAPI))
	    {
		// By default, we use HAPI if Houdini Engine is enabled
		return new HEU_SessionHAPI();
	    }
	    else if (_createSessionFromTypeDelegate != null)
	    {
		// For custom HEU_SessionBase classes

		System.Delegate[] delegates = _createSessionFromTypeDelegate.GetInvocationList();
		foreach (System.Delegate del in delegates)
		{
		    CreateSessionFromTypeDelegate createDelegate = del as CreateSessionFromTypeDelegate;
		    HEU_SessionBase newSession = createDelegate.Invoke(type);
		    if (newSession != null)
		    {
			return newSession;
		    }
		}
	    }
#endif
	    // Fallback to empty session
	    return new HEU_SessionBase();
	}
        /// <summary>
        /// Writes out the TerrainLayer file path as a string attribute (primitive-owned) for the specified heightfield volume.
        /// </summary>
        /// <param name="session">Current Houdini session</param>
        /// <param name="geoNodeID">Geometry object ID</param>
        /// <param name="partID">Part ID (volume)</param>
        /// <param name="terrainLayer">The TerrainLayer's file path is set as attribute</param>
        /// <returns>True if successfully added the attribute.</returns>
        public bool SetTerrainLayerAttributesToHeightField(HEU_SessionBase session, HAPI_NodeId geoNodeID, HAPI_PartId partID, TerrainLayer terrainLayer)
        {
            string assetPath = HEU_AssetDatabase.GetAssetPath(terrainLayer);

            if (string.IsNullOrEmpty(assetPath))
            {
                return(false);
            }

            HAPI_AttributeInfo attrInfo = new HAPI_AttributeInfo();

            attrInfo.exists        = true;
            attrInfo.owner         = HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM;
            attrInfo.storage       = HAPI_StorageType.HAPI_STORAGETYPE_STRING;
            attrInfo.count         = 1;
            attrInfo.tupleSize     = 1;
            attrInfo.originalOwner = HAPI_AttributeOwner.HAPI_ATTROWNER_INVALID;

            if (!session.AddAttribute(geoNodeID, partID, HEU_Defines.DEFAULT_UNITY_HEIGHTFIELD_TERRAINLAYER_FILE_ATTR, ref attrInfo))
            {
                HEU_Logger.LogError("Failed to add TerrainLayer file attribute to input heightfield.");
                return(false);
            }

            string[] pathData = new string[] { assetPath };
            if (!session.SetAttributeStringData(geoNodeID, partID, HEU_Defines.DEFAULT_UNITY_HEIGHTFIELD_TERRAINLAYER_FILE_ATTR, ref attrInfo, pathData, 0, 1))
            {
                HEU_Logger.LogError("Failed to set TerrainLayer file name to input heightfield");
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
	public static void CreatePDGAssetLink()
	{
	    GameObject selectedGO = Selection.activeGameObject;
	    if (selectedGO != null)
	    {
		HEU_HoudiniAssetRoot assetRoot = selectedGO.GetComponent<HEU_HoudiniAssetRoot>();
		if (assetRoot != null)
		{
		    if (assetRoot._houdiniAsset != null)
		    {
			string name = string.Format("{0}_PDGLink", assetRoot._houdiniAsset.AssetName);

			GameObject go = HEU_GeneralUtility.CreateNewGameObject(name);
			HEU_PDGAssetLink assetLink = go.AddComponent<HEU_PDGAssetLink>();
			assetLink.Setup(assetRoot._houdiniAsset);

			Selection.activeGameObject = go;
		    }
		    else
		    {
			HEU_Logger.LogError("Selected gameobject is not an instantiated HDA. Failed to create PDG Asset Link.");
		    }
		}
		else
		{
		    HEU_Logger.LogError("Selected gameobject is not an instantiated HDA. Failed to create PDG Asset Link.");
		}
	    }
	    else
	    {
		//HEU_Logger.LogError("Nothing selected. Select an instantiated HDA first.");
		HEU_EditorUtility.DisplayErrorDialog("PDG Asset Link", "No HDA selected. You must select an instantiated HDA first.", "OK");
	    }
	}
        /// <summary>
        /// Create the main heightfield network for input.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="idt"></param>
        /// <returns>True if successfully created the network</returns>
        public bool CreateHeightFieldInputNode(HEU_SessionBase session, HEU_InputDataTerrain idt)
        {
            idt._heightfieldNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
            idt._heightNodeID      = HEU_Defines.HEU_INVALID_NODE_ID;
            idt._maskNodeID        = HEU_Defines.HEU_INVALID_NODE_ID;
            idt._mergeNodeID       = HEU_Defines.HEU_INVALID_NODE_ID;
            idt._parentNodeID      = HEU_Defines.HEU_INVALID_NODE_ID; // Heightfields should have its own objects.

            // Create the HeightField node network
            bool bResult = session.CreateHeightFieldInput(idt._parentNodeID, idt._heightFieldName, idt._numPointsX, idt._numPointsY, idt._voxelSize,
                                                          HAPI_HeightFieldSampling.HAPI_HEIGHTFIELD_SAMPLING_CORNER,
                                                          out idt._heightfieldNodeID, out idt._heightNodeID, out idt._maskNodeID, out idt._mergeNodeID);

            if (!bResult ||
                idt._heightfieldNodeID == HEU_Defines.HEU_INVALID_NODE_ID ||
                idt._heightNodeID == HEU_Defines.HEU_INVALID_NODE_ID ||
                idt._maskNodeID == HEU_Defines.HEU_INVALID_NODE_ID ||
                idt._mergeNodeID == HEU_Defines.HEU_INVALID_NODE_ID)
            {
                HEU_Logger.LogError("Failed to create new heightfield node in Houdini session!");
                return(false);
            }

            if (!session.CookNode(idt._heightNodeID, false))
            {
                HEU_Logger.LogError("New input node failed to cook!");
                return(false);
            }

            return(true);
        }
	public static bool GetParameterColor3Value(HEU_SessionBase session, HAPI_NodeId nodeID, HAPI_ParmInfo[] parameters, string parameterName, Color defaultValue, out Color outputColor)
	{
	    int parameterIndex = GetParameterIndexFromNameOrTag(session, nodeID, parameters, parameterName);
	    if (parameterIndex < 0 || parameterIndex >= parameters.Length)
	    {
		outputColor = defaultValue;
		return false;
	    }

	    if (parameters[parameterIndex].size < 3)
	    {
		HEU_Logger.LogError("Parameter size not large enough to be a Color3");
		outputColor = defaultValue;
		return false;
	    }

	    int valueIndex = parameters[parameterIndex].floatValuesIndex;
	    float[] value = new float[3];

	    if (session.GetParamFloatValues(nodeID, value, valueIndex, 3))
	    {
		outputColor = new Color(value[0], value[1], value[2], 1f);
		return true;
	    }

	    outputColor = defaultValue;
	    return false;
	}
        private void SetErrorState(string msg, bool bLogIt)
        {
            // Log first error
            if (!_errored && bLogIt)
            {
                HEU_Logger.LogError(msg);
            }

            _errored  = true;
            _errorMsg = msg;
        }
        /// <summary>
        /// Set the given TerrainData's TreePrototyes as attributes on the given part.
        /// The TreePrototypes as stored a string attributes where the name is HEU_Defines.HEIGHTFIELD_TREEPROTOTYPE + index.
        /// The string value is the tree prefab's file path comme-separated with the bend factor:
        /// e.g: Assets/Trees/redtree.prefab,0.9
        /// This does nothing if the given TerrainData doesn't have TreePrototype.
        /// </summary>
        /// <param name="session">Houdini Engine session</param>
        /// <param name="geoNodeID">Geometry object ID</param>
        /// <param name="partID">Part ID</param>
        /// <param name="terrainData">The TerrainData containing TreePrototypes.</param>
        public void SetTreePrototypes(HEU_SessionBase session, HAPI_NodeId geoNodeID, HAPI_PartId partID, TerrainData terrainData)
        {
            TreePrototype[] treePrototypes = terrainData.treePrototypes;
            if (treePrototypes == null || treePrototypes.Length == 0)
            {
                return;
            }

            // For each prototype, fill up a string attribute owned by primitive.
            // The string format is: tree_prefab_path,bend_factor
            string prefabPath;
            float  bendFactor;

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

                prefabPath = HEU_AssetDatabase.GetAssetPath(treePrototypes[i].prefab);
                if (prefabPath == null)
                {
                    continue;
                }

                bendFactor = treePrototypes[i].bendFactor;

                HAPI_AttributeInfo attrInfo = new HAPI_AttributeInfo();
                attrInfo.exists        = true;
                attrInfo.owner         = HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM;
                attrInfo.storage       = HAPI_StorageType.HAPI_STORAGETYPE_STRING;
                attrInfo.count         = 1;
                attrInfo.tupleSize     = 1;
                attrInfo.originalOwner = HAPI_AttributeOwner.HAPI_ATTROWNER_INVALID;

                string attrName = HEU_Defines.HEIGHTFIELD_TREEPROTOTYPE + i.ToString();
                if (!session.AddAttribute(geoNodeID, partID, attrName, ref attrInfo))
                {
                    HEU_Logger.LogError("Failed to add TreePrototype string attribute to input heightfield.");
                    return;
                }

                string[] pathData = new string[] { string.Format("{0},{1}", prefabPath, bendFactor) };
                if (!session.SetAttributeStringData(geoNodeID, partID, attrName, ref attrInfo, pathData, 0, 1))
                {
                    HEU_Logger.LogError("Failed to set TreePrototype string value to input heightfield.");
                    return;
                }
            }
        }
        /// <summary>
        /// Helper to set heightfield data for a specific volume node.
        /// Used for a specific terrain layer.
        /// </summary>
        /// <param name="session">Session that the volume node resides in.</param>
        /// <param name="volumeNodeID">ID of the target volume node</param>
        /// <param name="partID">Part ID</param>
        /// <param name="heightValues">Array of height or alpha values</param>
        /// <param name="heightFieldName">Name of the layer</param>
        /// <returns>True if successfully uploaded heightfield values</returns>
        public bool SetHeightFieldData(HEU_SessionBase session, HAPI_NodeId volumeNodeID, HAPI_PartId partID, float[] heightValues, string heightFieldName, ref HAPI_VolumeInfo baseVolumeInfo)
        {
            // Cook the node to get infos below
            if (!session.CookNode(volumeNodeID, false))
            {
                return(false);
            }

            // Get Geo, Part, and Volume infos
            HAPI_GeoInfo geoInfo = new HAPI_GeoInfo();

            if (!session.GetGeoInfo(volumeNodeID, ref geoInfo))
            {
                return(false);
            }

            HAPI_PartInfo partInfo = new HAPI_PartInfo();

            if (!session.GetPartInfo(geoInfo.nodeId, partID, ref partInfo))
            {
                return(false);
            }

            HAPI_VolumeInfo volumeInfo = new HAPI_VolumeInfo();

            if (!session.GetVolumeInfo(volumeNodeID, partInfo.id, ref volumeInfo))
            {
                return(false);
            }

            volumeInfo.tileSize = 1;
            // Use same transform as base layer
            volumeInfo.transform = baseVolumeInfo.transform;

            if (!session.SetVolumeInfo(volumeNodeID, partInfo.id, ref volumeInfo))
            {
                HEU_Logger.LogError("Unable to set volume info on input heightfield node!");
                return(false);
            }

            // Now set the height data
            if (!session.SetHeightFieldData(geoInfo.nodeId, partInfo.id, heightFieldName, heightValues, 0, heightValues.Length))
            {
                HEU_Logger.LogErrorFormat("Unable to set `{0}` height values on input heightfield node!\n" +
                                          "Check your terrain sizes including Control Texture Resolution is less than the Heightmap Resolution.",
                                          heightFieldName);
                return(false);
            }

            return(true);
        }
	public bool IsEquivalentTo(HEU_ParameterData other)
	{
	    bool bResult = true;

	    string header = "HEU_ParameterData";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._name, other._name, ref bResult, header, "_name");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._labelName, other._labelName, ref bResult, header, "_labelName");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._help, other._help, ref bResult, header, "_help");

	    // Skip child parameter Ids values, but not count
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._childParameterIDs.Count, other._childParameterIDs.Count, ref bResult, header, "_childParameterIds");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._intValues, other._intValues, ref bResult, header, "_intValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._floatValues, other._floatValues, ref bResult, header, "_floatValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._stringValues, other._stringValues, ref bResult, header, "_stringValues");
   
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._toggle, other._toggle, ref bResult, header, "_toggle");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._color, other._color, ref bResult, header, "_color");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._gradient.ToTestObject(), other._gradient.ToTestObject(), ref bResult, header, "_gradient");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._animCurve.ToTestObject(), other._animCurve.ToTestObject(), ref bResult, header, "_animCurve");

	    // Skip choiceLabels 

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._choiceStringValues, other._choiceStringValues, ref bResult, header, "_choiceStringValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._choiceIntValues, other._choiceIntValues, ref bResult, header, "_choiceIntValues");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._parmInfo.ToTestObject(), other._parmInfo.ToTestObject(), ref bResult, header, "_parmInfo");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._showChildren, other._showChildren, ref bResult, header, "_showChildren");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._fileTypeInfo, other._fileTypeInfo, ref bResult, header, "_fileTypeInfo");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._folderListChildrenProcessed, other._folderListChildrenProcessed, ref bResult, header, "_folderListChildrenProcessed");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._tabSelectedIndex, other._tabSelectedIndex, ref bResult, header, "_tabSelectedIndex");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paramInputNode, other._paramInputNode, ref bResult, header, "_paramInputNode");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._hasAssetPathTag, other._hasAssetPathTag, ref bResult, header, "_hasAssetPathTag");

	    return bResult;
	}
	public bool IsEquivalentTo(HEU_ToolsInfo other)
	{
	    bool bResult = true;

	    string header = "HEU_ToolsInfo";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintBrushSize, other._paintBrushSize, ref bResult, header, "_paintBrushSize");


	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintBrushOpacity, other._paintBrushOpacity, ref bResult, header, "_paintBrushOpacity");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintIntValue, other._paintIntValue, ref bResult, header, "_paintIntValue");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintFloatValue, other._paintFloatValue, ref bResult, header, "_paintFloatValue");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintStringValue, other._paintStringValue, ref bResult, header, "_paintStringValue");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._lastAttributeNodeName, other._lastAttributeNodeName, ref bResult, header, "_lastAttributeNodeName");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._lastAttributeName, other._lastAttributeName, ref bResult, header, "_lastAttributeName");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._brushHandleColor, other._brushHandleColor, ref bResult, header, "_brushHandleColor");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._affectedAreaPaintColor, other._affectedAreaPaintColor, ref bResult, header, "_affectedAreaPaintColor");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._liveUpdate, other._liveUpdate, ref bResult, header, "_liveUpdate");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._isPainting, other._isPainting, ref bResult, header, "_isPainting");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._editPointBoxSize, other._editPointBoxSize, ref bResult, header, "_editPointBoxSize");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._editPointBoxUnselectedColor, other._editPointBoxUnselectedColor, ref bResult, header, "_editPointBoxUnselectedColor");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._editPointBoxSelectedColor, other._editPointBoxSelectedColor, ref bResult, header, "_editPointBoxSelectedColor");


	    // HEU_TestHelpers.AssertTrueLogEquivalent(this._recacheRequired, other._recacheRequired, ref bResult, header, "_recacheRequired");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintMergeMode, other._paintMergeMode, ref bResult, header, "_paintMergeMode");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._showOnlyEditGeometry, other._showOnlyEditGeometry, ref bResult, header, "_showOnlyEditGeometry");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._alwaysCookUpstream, other._alwaysCookUpstream, ref bResult, header, "_alwaysCookUpstream");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paintMeshVisiblity, other._paintMeshVisiblity, ref bResult, header, "_paintMeshVisibility");

	    return bResult;
	}
Esempio n. 17
0
	public bool IsEquivalentTo(HEU_ObjectInstanceInfo other)
	{
	    bool bResult = true;

	    string header = "HEU_ObjectInstanceInfo";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._instancedInputs, other._instancedInputs, ref bResult, header, "_instancedInputs");

	    return bResult;
	}
        public bool IsEquivalentTo(HEU_AssetSerializedMetaData other)
        {
            bool bResult = true;

            string header = "HEU_AssetSerializedMetaData";

            if (other == null)
            {
                HEU_Logger.LogError(header + " Not equivalent");
                return(false);
            }

            // These things shouldn't be tested because they're specifically "hacky"

            return(bResult);
        }
Esempio n. 19
0
	public bool IsEquivalentTo(HEU_InstancedInput other)
	{
	    bool bResult = true;

	    string header = "HEU_InstancedInput";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._instancedGameObject, other._instancedGameObject, ref bResult, header, "_instancedGameObject");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._rotationOffset, other._rotationOffset, ref bResult, header, "_rotationOffset");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._scaleOffset, other._scaleOffset, ref bResult, header, "_scaleOffset");

	    return bResult;
	}
	public bool IsEquivalentTo(HEU_InstanceInputUIState other)
	{
	    bool bResult = true;

	    string header = "HEU_InstanceInputUIState";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._showInstanceInputs, other._showInstanceInputs, ref bResult, header, "_showInstanceInputs");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._numInputsToShowUI, other._numInputsToShowUI, ref bResult, header, "_numInputsToShowUI");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._inputsPageIndexUI , other._inputsPageIndexUI, ref bResult, header, "_inputPageIndexUI");
	    return bResult;
	}
Esempio n. 21
0
	public bool IsEquivalentTo(HEU_ObjectNode other)
	{
	    bool bResult = true;

	    string header = "HEU_ObjectNode";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._objectInfo.ToTestObject(), other._objectInfo.ToTestObject(), ref bResult, header, "Object Info");
	
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._geoNodes, other._geoNodes, ref bResult, header, "Geo Node");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._objectTransform.ToTestObject(), other._objectTransform.ToTestObject(), ref bResult, header, "Object transform");

	    return bResult;
	}
	public bool IsEquivalentTo(HEU_GeneratedOutput other)
	{
	    bool bResult = true;

	    string header = "HEU_GeneratedOutput";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._outputData, other._outputData, ref bResult, header, "_outputData");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._childOutputs, other._childOutputs, ref bResult, header, "_childOutputs");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this.isInstancer, other.isInstancer, ref bResult, header, "_childOutputs");

	    return bResult;
	}
        private bool SetMaskLayer(HEU_SessionBase session, HEU_InputDataTerrain idt, ref HAPI_VolumeInfo baseVolumeInfo)
        {
            int sizeX     = idt._terrainData.alphamapWidth;
            int sizeY     = idt._terrainData.alphamapHeight;
            int totalSize = sizeX * sizeY;

            float[] maskValues = new float[totalSize];
            if (!SetHeightFieldData(session, idt._maskNodeID, 0, maskValues, HEU_Defines.HAPI_HEIGHTFIELD_LAYERNAME_MASK, ref baseVolumeInfo))
            {
                return(false);
            }

            if (!session.CommitGeo(idt._maskNodeID))
            {
                HEU_Logger.LogError("Failed to commit volume layer 'mask'");
                return(false);
            }

            return(true);
        }
	public bool IsEquivalentTo(HEU_MaterialData other)
	{
	    bool bResult = true;

	    string header = "HEU_MaterialData";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._material.ToTestObject(), other._material.ToTestObject(), ref bResult, header, "_material");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._materialSource, other._materialSource, ref bResult, header, "_materialSource");

	    // Skip _materialKey
	 
	    return bResult;
	}
	public bool IsEquivalentTo(HEU_GeneratedOutputData other)
	{
	    bool bResult = true;

	    string header = "HEU_GeneratedOutputData";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._gameObject, other._gameObject, ref bResult, header, "_gameObject");


	    HEU_TestHelpers.AssertTrueLogEquivalent(_renderMaterials.ToTestObject(), other._renderMaterials.ToTestObject(), ref bResult, header, "_renderMaterials");

	    HEU_TestHelpers.AssertTrueLogEquivalent(_colliders.ToTestObject(), other._colliders.ToTestObject(), ref bResult, header, "_colliders");

	    return bResult;
	}
Esempio n. 26
0
	public bool IsEquivalentTo(HEU_ParameterModifier other)
	{
	    bool bResult = true;

	    string header = "HEU_ParameterModifier";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._parameterIndex, other._parameterIndex, ref bResult, header, "_parameterIndex");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._action, other._action, ref bResult, header, "_action");

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._instanceIndex, other._instanceIndex, ref bResult, header, "_instanceIndex");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._modifierValue, other._modifierValue, ref bResult, header, "_modifierValue");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._floatValue, other._floatValue, ref bResult, header, "_floatValue");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._intValue, other._intValue, ref bResult, header, "_intValue");
	
	    return bResult;
	}
Esempio n. 27
0
	/// <summary>
	/// Start the work in a new thread, with priority and background set.
	/// </summary>
	public virtual void Start()
	{
	    Debug.Assert(!StopRequested, "StopRequested is true. Task didn't get reset!");
	    Debug.Assert(!IsComplete, "IsComplete is true. Task didn't get reset!");

	    if (_thread == null)
	    {
		// Activate the task first ensuring it won't be stopped until complete or stopped
		IsActive = true;
		IsComplete = false;

		HEU_ThreadManager.Instance.AddTask(this);

		_thread = new System.Threading.Thread(Run);
		_thread.Priority = Priority;
		_thread.IsBackground = IsBackground;
		_thread.Start();
	    }
	    else
	    {
		HEU_Logger.LogError("Thread already running!");
	    }
	}
Esempio n. 28
0
	public bool IsEquivalentTo(HEU_HandleParamBinding other)
	{

	    bool bResult = true;

	    string header = "HEU_HandleParamBinding";

	    if (other == null)
	    {
		HEU_Logger.LogError(header + " Not equivalent");
		return false;
	    }

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paramType, other._paramType, ref bResult, header, "_paramType");

	    // SKip parmID

	    HEU_TestHelpers.AssertTrueLogEquivalent(this._paramName, other._paramName, ref bResult, header, "_paramName");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._bDisabled, other._bDisabled, ref bResult, header, "_bDisabled");
	    HEU_TestHelpers.AssertTrueLogEquivalent(this._boundChannels, other._boundChannels, ref bResult, header, "_boundChannels");

	    return bResult;
	}
Esempio n. 29
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="inputNode">The specified inputNode to create the node for (used for settings)</param>
	/// <returns>True if successfully uploading input nodes</returns>
	internal static bool CreateInputNodeWithMultiObjects(HEU_SessionBase session, HAPI_NodeId assetID,
		ref HAPI_NodeId connectMergeID, ref List<HEU_InputObjectInfo> inputObjects, ref List<HAPI_NodeId> inputObjectsConnectedAssetIDs, HEU_InputNode inputNode)
	{
	    bool bKeepWorldTransform = inputNode.KeepWorldTransform;
	    // Create the merge SOP node that the input nodes are going to connect to.
	    if (!session.CreateNode(-1, "SOP/merge", null, true, out connectMergeID))
	    {
		HEU_Logger.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)
		{
		    HEU_Logger.LogWarningFormat("No input interface found for gameobject: {0}. Skipping upload!", inputObjects[i]._gameObject.name);
		    continue;
		}

		// Apply settings based on the interface type.
		System.Type inputInterfaceType = inputInterface.GetType();
		if (inputInterfaceType == typeof(HEU_InputInterfaceMesh))
		{
		    HEU_InputInterfaceMesh meshInterface = inputInterface as HEU_InputInterfaceMesh;
		    meshInterface.Initialize(inputNode.MeshSettings);
		}
		if (inputInterfaceType == typeof(HEU_InputInterfaceTilemap))
		{
		    HEU_InputInterfaceTilemap tilemapInterface = inputInterface as HEU_InputInterfaceTilemap;
		    tilemapInterface.Initialize(inputNode.TilemapSettings);
		}

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

		inputObjectsConnectedAssetIDs[i] = newConnectInputID;

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

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

	    return true;
	}
	/// <summary>
	/// Creates a mesh input node and uploads the mesh data from inputObject.
	/// </summary>
	/// <param name="session">Session that connectNodeID exists in</param>
	/// <param name="connectNodeID">The node to connect the network to. Most likely a SOP/merge node</param>
	/// <param name="inputObject">The gameobject containing the mesh components</param>
	/// <param name="inputNodeID">The created input node ID</param>
	/// <returns>True if created network and uploaded mesh data.</returns>
	public override bool CreateInputNodeWithDataUpload(HEU_SessionBase session, HAPI_NodeId connectNodeID, GameObject inputObject, out HAPI_NodeId inputNodeID)
	{
	    inputNodeID = HEU_Defines.HEU_INVALID_NODE_ID;

	    // Create input node, cook it, then upload the geometry data

	    if (!HEU_HAPIUtility.IsNodeValidInHoudini(session, connectNodeID))
	    {
		HEU_Logger.LogError("Connection node is invalid.");
		return false;
	    }

	    bool bExportColliders = settings != null && settings.ExportColliders == true;

	    // Get upload meshes from input object
	    HEU_InputDataMeshes inputMeshes = GenerateMeshDatasFromGameObject(inputObject, bExportColliders);
	    if (inputMeshes == null || inputMeshes._inputMeshes == null || inputMeshes._inputMeshes.Count == 0)
	    {
		HEU_Logger.LogError("No valid meshes found on input objects.");
		return false;
	    }

	    string inputName = null;
	    HAPI_NodeId newNodeID = HEU_Defines.HEU_INVALID_NODE_ID;
	    session.CreateInputNode(out newNodeID, inputName);
	    if (newNodeID == HEU_Defines.HEU_INVALID_NODE_ID || !HEU_HAPIUtility.IsNodeValidInHoudini(session, newNodeID))
	    {
		HEU_Logger.LogError("Failed to create new input node in Houdini session!");
		return false;
	    }

	    inputNodeID = newNodeID;

	    if (!UploadData(session, inputNodeID, inputMeshes))
	    {
		if (!session.CookNode(inputNodeID, false))
		{
		    HEU_Logger.LogError("New input node failed to cook!");
		    return false;
		}

		return false;
	    }

	    bool createMergeNode = false;
	    HAPI_NodeId mergeNodeId = HEU_Defines.HEU_INVALID_NODE_ID;

	    if (bExportColliders)
	    {
		createMergeNode = true;
	    }

	    if (!createMergeNode)
	    {
		return true;
	    }

	    HAPI_NodeId parentId = HEU_HAPIUtility.GetParentNodeID(session, newNodeID);

	    if (!session.CreateNode(parentId, "merge", null, false, out mergeNodeId))
	    {
		HEU_Logger.LogErrorFormat("Unable to create merge SOP node for connecting input assets.");
		return false;
	    }

	    if (!session.ConnectNodeInput(mergeNodeId, 0, newNodeID))
	    {
		HEU_Logger.LogErrorFormat("Unable to connect to input node!");
		return false;
	    }

	    if (!session.SetNodeDisplay(mergeNodeId, 1))
	    {
		HEU_Logger.LogWarningFormat("Unable to set display flag!");
	    }

	    inputNodeID = mergeNodeId;

	    if (bExportColliders)
	    {
		if (!UploadColliderData(session, mergeNodeId, inputMeshes, parentId))
		{
		    return false;
		}
	    }

	    if (!session.CookNode(inputNodeID, false))
	    {
	        HEU_Logger.LogError("New input node failed to cook!");
	        return false;
	    }
	    return true;
	}