/// <summary>
    /// Query all attributes of a specific part and a specific owner (detail, primitive, point, vertex).
    /// </summary>
    /// <param name="session">Houdini Engine session</param>
    /// <param name="geoID">The geometry object ID</param>
    /// <param name="partID">The part ID</param>
    /// <param name="owner">The attribute owner</param>
    /// <param name="count">The number of expected attributes for this owner</param>
    public static void QueryPartAttributeByOwner(HEU_SessionBase session, HAPI_NodeId geoID,
                                                 HAPI_PartId partID, HAPI_AttributeOwner owner, int count, StringBuilder sb)
    {
        if (count == 0)
        {
            Debug.LogFormat("No attributes with owner {0}", owner);
            return;
        }

        string[] attrNames = new string[count];
        if (session.GetAttributeNames(geoID, partID, owner, ref attrNames, count))
        {
            for (int i = 0; i < attrNames.Length; ++i)
            {
                HAPI_AttributeInfo attrInfo = new HAPI_AttributeInfo();
                if (HEU_GeneralUtility.GetAttributeInfo(session, geoID, partID, attrNames[i], ref attrInfo) && attrInfo.exists)
                {
                    sb.AppendLine(string.Format("Attribute {0} has storage: {1}", attrNames[i], attrInfo.storage));

                    // Query the actual values with helper for each type
                    QueryAttributeByStorageType(session, geoID, partID, ref attrInfo, attrNames[i]);
                }
            }
        }
    }
		public static void GetAttributeStringDataHelper(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string name, ref HAPI_AttributeInfo info, ref HAPI_StringHandle[] data)
		{
			int originalTupleSize = info.tupleSize;
			bool bResult = false;
			for (HAPI_AttributeOwner type = 0; type < HAPI_AttributeOwner.HAPI_ATTROWNER_MAX; ++type)
			{
				bResult = session.GetAttributeInfo(geoID, partID, name, type, ref info);
				if (bResult && info.exists)
				{
					break;
				}
			}

			if (!bResult || !info.exists)
			{
				return;
			}

			if (originalTupleSize > 0)
			{
				info.tupleSize = originalTupleSize;
			}

			data = new HAPI_StringHandle[info.count * info.tupleSize];
			bResult = session.GetAttributeStringData(geoID, partID, name, ref info, data, 0, info.count);
			if(!bResult)
			{
				Debug.LogErrorFormat("Failed to get string IDs for attribute {0}", name);
			}
		}
		public static bool GetAttribute<T>(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string name, ref HAPI_AttributeInfo info, ref T[] data, GetAttributeArrayInputFunc<T> getFunc)
		{
			int originalTupleSize = info.tupleSize;
			bool bResult = false;
			for (HAPI_AttributeOwner type = 0; type < HAPI_AttributeOwner.HAPI_ATTROWNER_MAX; ++type)
			{
				bResult = session.GetAttributeInfo(geoID, partID, name, type, ref info);
				if (bResult && info.exists)
				{
					break;
				}
			}

			if (!bResult || !info.exists)
			{
				return false;
			}

			if (originalTupleSize > 0)
			{
				info.tupleSize = originalTupleSize;
			}

			data = new T[info.count * info.tupleSize];
			return GetAttributeArray(geoID, partID, name, ref info, data, getFunc, info.count);
		}
예제 #4
0
    public int getElementCountByAttributeOwner(HAPI_AttributeOwner owner)
    {
        switch (owner)
        {
        case HAPI_AttributeOwner.HAPI_ATTROWNER_VERTEX: return(vertexCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_POINT: return(pointCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM: return(faceCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL: return(1);

        default: return(0);
        }
    }
예제 #5
0
    public int getAttributeCountByOwner(HAPI_AttributeOwner owner)
    {
        switch (owner)
        {
        case HAPI_AttributeOwner.HAPI_ATTROWNER_VERTEX: return(vertexAttributeCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_POINT: return(pointAttributeCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM: return(faceAttributeCount);

        case HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL: return(detailAttributeCount);

        default: return(0);
        }
    }
		public static bool GetAttributeInfo(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string attribName, ref HAPI_AttributeInfo attribInfo)
		{
			bool bResult = false;
			for (HAPI_AttributeOwner type = 0; type < HAPI_AttributeOwner.HAPI_ATTROWNER_MAX; ++type)
			{
				bResult = session.GetAttributeInfo(geoID, partID, attribName, type, ref attribInfo);
				if (!bResult)
				{
					attribInfo.exists = false;
					return false;
				}
				else if(attribInfo.exists)
				{
					break;
				}
			}
			return true;
		}
예제 #7
0
    public void reset()
    {
        myName = "NO_NAME";

        myType = Type.UNDEFINED;
        myOriginalAttributeOwner = HAPI_AttributeOwner.HAPI_ATTROWNER_VERTEX;
        myTupleSize = 1;
        myVertexCount = 0;
        myInitializedVertexCount = 0;

        myPaintMode = (int) SpecialPaintMode.COLOUR;

        myIntPaintValue = null;
        myIntMin = myDefaultIntMin;
        myIntMax = myDefaultIntMax;
        myIntData = null;

        myFloatPaintValue = null;
        myFloatMin = myDefaultFloatMin;
        myFloatMax = myDefaultFloatMax;
        myFloatData = null;

        myStringPaintValue = null;
        myStringData = null;
    }
예제 #8
0
 public static bool DoesGeoPartHaveAttribute(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string attrName, HAPI_AttributeOwner owner, ref HAPI_AttributeInfo attributeInfo)
 {
     if (session.GetAttributeInfo(geoID, partID, attrName, owner, ref attributeInfo))
     {
         return(attributeInfo.exists);
         //Debug.LogFormat("Attr {0} exists={1}, with count={2}, type={3}, storage={4}, tuple={5}", "Cd", colorAttrInfo.exists, colorAttrInfo.count, colorAttrInfo.typeInfo, colorAttrInfo.storage, colorAttrInfo.tupleSize);
     }
     return(false);
 }
예제 #9
0
		/// <summary>
		/// Returns true if specified geometry and part has the given atttribute name.
		/// </summary>
		/// <param name="session">Houdini session to check</param>
		/// <param name="geoID">Geometry object ID</param>
		/// <param name="partID">Part ID</param>
		/// <param name="attrName">The name of the attribute to check</param>
		/// <param name="attrOwner">The owner type for the attribute</param>
		/// <returns></returns>
		public static bool HasAttribute(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string attrName, HAPI_AttributeOwner attrOwner)
		{
			if (string.IsNullOrEmpty(attrName))
			{
				return false;
			}

			HAPI_AttributeInfo attrInfo = new HAPI_AttributeInfo();
			bool bResult = session.GetAttributeInfo(geoID, partID, attrName, attrOwner, ref attrInfo);
			return (bResult && attrInfo.exists);
		}
예제 #10
0
		/// <summary>
		/// Returns the single string value from Attribute with given name and owner type, or null if failed.
		/// </summary>
		/// <param name="session">Houdini Engine session to query</param>
		/// <param name="geoID">The geometry ID in Houdini</param>
		/// <param name="partID">The part ID in Houdini</param>
		/// <param name="attrName">Name of the attribute to query</param>
		/// <param name="attrOwner">Owner type of the attribute</param>
		/// <returns>Valid string if successful, otherwise returns null</returns>
		public static string GetAttributeStringValueSingle(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string attrName, HAPI_AttributeOwner attrOwner)
		{
			if (string.IsNullOrEmpty(attrName))
			{
				return null;
			}

			HAPI_AttributeInfo attrInfo = new HAPI_AttributeInfo();
			int[] stringHandle = new int[0];
			HEU_GeneralUtility.GetAttribute(session, geoID, partID, attrName, ref attrInfo, ref stringHandle, session.GetAttributeStringData);
			if (attrInfo.exists)
			{
				if (attrInfo.owner != attrOwner)
				{
					Debug.LogWarningFormat("Expected {0} attribute owner for attribute {1} but got {2}!", attrOwner, attrName, attrInfo.owner);
				}
				else if (stringHandle.Length > 0)
				{
					return HEU_SessionManager.GetString(stringHandle[0]);
				}
			}
			return null;
		}
예제 #11
0
	public int getElementCountByAttributeOwner( HAPI_AttributeOwner owner )
	{
		switch ( owner )
		{
			case HAPI_AttributeOwner.HAPI_ATTROWNER_VERTEX: return vertexCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_POINT: return pointCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM: return faceCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL: return 1;
			default: return 0;
		}
	}
		/// <summary>
		/// Get the attribute names of all attributes having owner of the given part.
		/// </summary>
		/// <param name="nodeID">The SOP node ID</param>
		/// <param name="partID">The part ID</param>
		/// <param name="owner">Attributes must have this owner type</param>
		/// <param name="attributeNames">Result array of name strings. Must be atleast count size.</param>
		/// <param name="count">Expected number of attributes. Should be from HAPI_PartInfo.attributeCounts[owner].</param>
		/// <returns>True if successfully retrieved the names</returns>
		public virtual bool GetAttributeNames(HAPI_NodeId nodeID, HAPI_PartId partID, HAPI_AttributeOwner owner, ref string[] attributeNames, int count)
		{
			return false;
		}
예제 #13
0
	public int getAttributeCountByOwner( HAPI_AttributeOwner owner )
	{
		switch ( owner )
		{
			case HAPI_AttributeOwner.HAPI_ATTROWNER_VERTEX: return vertexAttributeCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_POINT: return pointAttributeCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM: return faceAttributeCount;
			case HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL: return detailAttributeCount;
			default: return 0;
		}
	}
예제 #14
0
	HAPI_GetAttributeNames(
		ref HAPI_Session session,
		HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
		HAPI_AttributeOwner owner,
		[Out] HAPI_StringHandle[] attribute_names_array,
		int count );
예제 #15
0
	HAPI_GetAttributeInfo(
		ref HAPI_Session session,
		HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
		string name, HAPI_AttributeOwner owner,
		ref HAPI_AttributeInfo attr_info );
예제 #16
0
 HAPI_GetAttributeInfo(
     HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
     string name, HAPI_AttributeOwner owner,
     ref HAPI_AttributeInfo attr_info);
예제 #17
0
 HAPI_GetAttributeNames(
     HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
     HAPI_AttributeOwner owner,
     [Out] HAPI_StringHandle[] attribute_names,
     int count);
		public static bool CheckAttributeExists(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, string attribName, HAPI_AttributeOwner attribOwner)
		{
			HAPI_AttributeInfo attribInfo = new HAPI_AttributeInfo();
			if(session.GetAttributeInfo(geoID, partID, attribName, attribOwner, ref attribInfo))
			{
				return attribInfo.exists;
			}
			return false;
		}
예제 #19
0
	public static HAPI_AttributeInfo getAttributeInfo(
		HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id, string name, HAPI_AttributeOwner owner )
	{
#if ( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )
		HAPI_AttributeInfo info = new HAPI_AttributeInfo();
		HAPI_Result status_code = HAPI_GetAttributeInfo( ref mySession, asset_id, object_id, geo_id, part_id, name, owner, ref info );
		processStatusCode( status_code );
		return info;
#else
		throw new HoudiniErrorUnsupportedPlatform();
#endif
	}
		/// <summary>
		/// Get the main geometry info struct.
		/// </summary>
		/// <param name="nodeID">The SOP node ID</param>
		/// <param name="partID">The part ID</param>
		/// <param name="name">Attribute name</param>
		/// <param name="owner">Attribute owner</param>
		/// <param name="attributeInfo">Info to populate</param>
		/// <returns>True if successfully queried the attribute info</returns>
		public virtual bool GetAttributeInfo(HAPI_NodeId nodeID, HAPI_PartId partID, string name, HAPI_AttributeOwner owner, ref HAPI_AttributeInfo attributeInfo)
		{
			return false;
		}
예제 #21
0
	public static string[] getAttributeNames(
		HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
		HAPI_AttributeOwner owner )
	{
#if ( UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || ( UNITY_METRO && UNITY_EDITOR ) )
		HAPI_PartInfo part_info = new HAPI_PartInfo();
		HAPI_Result status_code = HAPI_GetPartInfo( ref mySession, asset_id, object_id, geo_id, part_id, out part_info );
		processStatusCode( status_code );

		int count = part_info.getAttributeCountByOwner( owner );

		int[] names = new int[ count ];
		status_code = HAPI_GetAttributeNames(
			ref mySession, asset_id, object_id, geo_id, part_id, owner, names, count );
		processStatusCode( status_code );

		string[] name_strings = new string[ count ];
		for ( int i = 0; i < count; ++i )
			name_strings[ i ] = getString( names[ i ] );

		return name_strings;
#else
		throw new HoudiniErrorUnsupportedPlatform();
#endif
	}
예제 #22
0
		private void GetAttributesList(HEU_SessionBase session, HAPI_NodeId geoID, HAPI_PartId partID, List<HEU_AttributeData> attributesList, HAPI_AttributeOwner ownerType, int attributeCount)
		{
			if (attributeCount > 0)
			{
				string[] attributeNames = new string[attributeCount];
				if (session.GetAttributeNames(geoID, partID, ownerType, ref attributeNames, attributeCount))
				{
					for (int i = 0; i < attributeNames.Length; ++i)
					{
						HEU_AttributeData attrData = GetAttributeData(attributeNames[i]);
						if (attrData == null)
						{
							// New attribute, so create and populate

							HAPI_AttributeInfo attributeInfo = new HAPI_AttributeInfo();
							if (!session.GetAttributeInfo(geoID, partID, attributeNames[i], ownerType, ref attributeInfo))
							{
								return;
							}

							attrData = CreateAttribute(attributeNames[i], ref attributeInfo);

							PopulateAttributeData(session, geoID, partID, attrData, ref attributeInfo);

							attributesList.Add(attrData);
						}
						else
						{
							// Existing, so just add it
							attributesList.Add(attrData);
						}
					}
				}
			}
		}
 HAPI_GetAttributeNames(
     ref HAPI_Session session,
     HAPI_AssetId asset_id, HAPI_ObjectId object_id, HAPI_GeoId geo_id, HAPI_PartId part_id,
     HAPI_AttributeOwner owner,
     [Out] HAPI_StringHandle[] attribute_names_array,
     int count);