Esempio n. 1
0
		/// <summary>
		/// Gets the group names for given group type.
		/// </summary>
		/// <param name="nodeID">The node ID</param>
		/// <param name="groupType">The group type to query</param>
		/// <returns>Populated array of string names, or null if failed</returns>
		public static string[] GetGroupNames(HAPI_NodeId nodeID, HAPI_PartId partID, HAPI_GroupType groupType, bool isInstanced)
		{
			HEU_SessionBase session = GetOrCreateDefaultSession();
			if (session != null)
			{
				HAPI_GeoInfo geoInfo = new HAPI_GeoInfo();
				if (session.GetGeoInfo(nodeID, ref geoInfo))
				{
					int groupCount = 0;

					if(!isInstanced)
					{
						groupCount = geoInfo.getGroupCountByType(groupType); ;
					}
					else
					{
						int pointGroupCount = 0;
						int primGroupCount = 0;
						if (session.GetGroupCountOnPackedInstancePart(nodeID, partID, out pointGroupCount, out primGroupCount))
						{
							groupCount = (groupType == HAPI_GroupType.HAPI_GROUPTYPE_POINT) ? pointGroupCount : primGroupCount;
						}
					}

					if(groupCount <= 0)
					{
						return null;
					}

					int[] groupNames = new int[groupCount];
					bool bSuccess = false;
					if(!isInstanced)
					{
						bSuccess = session.GetGroupNames(nodeID, groupType, ref groupNames, groupCount);
					}
					else
					{
						bSuccess = session.GetGroupNamesOnPackedInstancePart(nodeID, partID, groupType, ref groupNames, groupCount);
					}

					if (bSuccess)
					{
						string[] nameStrings = new string[groupCount];
						for (int i = 0; i < groupCount; ++i)
						{
							nameStrings[i] = GetString(groupNames[i]);
						}
						return nameStrings;
					}
				}
			}
			return null;
		}
Esempio n. 2
0
		/// <summary>
		/// Gets the group names for given group type.
		/// </summary>
		/// <param name="nodeID">The node ID</param>
		/// <param name="groupType">The group type to query</param>
		/// <returns>Populated array of string names, or null if failed</returns>
		public static string[] GetGroupNames(HAPI_NodeId nodeID, HAPI_GroupType groupType)
		{
			HEU_SessionBase sessionBase = GetOrCreateDefaultSession();
			if (sessionBase != null)
			{
				HAPI_GeoInfo geoInfo = new HAPI_GeoInfo();
				if (sessionBase.GetGeoInfo(nodeID, ref geoInfo))
				{
					int count = geoInfo.getGroupCountByType(groupType);
					int[] names = new int[count];
					if (sessionBase.GetGroupNames(nodeID, groupType, ref names, count))
					{
						string[] nameStrings = new string[count];
						for (int i = 0; i < count; ++i)
						{
							nameStrings[i] = GetString(names[i]);
						}
						return nameStrings;
					}
				}
			}
			return null;
		}