Exemple #1
0
 public static bool TryGetAttribute(this HoudiniGeo geo, string attrName, HoudiniGeoAttributeType type,
                                    HoudiniGeoAttributeOwner owner, out HoudiniGeoAttribute attr)
 {
     if (owner == HoudiniGeoAttributeOwner.Any)
     {
         attr = geo.attributes.FirstOrDefault(a => a.type == type && a.name == attrName);
     }
     else
     {
         attr = geo.attributes.FirstOrDefault(a => a.owner == owner && a.type == type && a.name == attrName);
     }
     return(attr != null);
 }
Exemple #2
0
        public static string AttributeEnumValueToTypeStr(HoudiniGeoAttributeType enumValue)
        {
            switch (enumValue)
            {
            case HoudiniGeoAttributeType.Integer:
                return("int32");

            case HoudiniGeoAttributeType.Float:
                return("fpreal64");    // NOTE: Don't know whether to use fpreal32 or fpreal64 so just using 64 for now.

            case HoudiniGeoAttributeType.String:
                return("string");

            default:
                throw new HoudiniGeoParseException("Unexpected attribute type: " + enumValue);
            }
        }
Exemple #3
0
        private static bool ValidateForGetValues <T>(this HoudiniGeoAttribute attr, HoudiniGeoAttributeType expectedType,
                                                     int expectedMinTupleSize)
        {
            if (attr.type != expectedType)
            {
                Debug.LogError(string.Format("Cannot convert raw values of {0} attribute '{1}' to {2} (type: {3})",
                                             attr.owner, attr.name, typeof(T).Name, attr.type));
                return(false);
            }

            if (attr.tupleSize < expectedMinTupleSize)
            {
                Debug.LogError(string.Format("The tuple size of {0} attribute '{1}' too small for conversion to {2}",
                                             attr.owner, attr.name, typeof(T).Name));
                return(false);
            }

            return(true);
        }
Exemple #4
0
        public static string AttributeTypeEnumValueToCategoryString(HoudiniGeoAttributeType enumValue)
        {
            string typeString = null;

            switch (enumValue)
            {
            case HoudiniGeoAttributeType.Float:
            case HoudiniGeoAttributeType.Integer:
                typeString = "numeric";
                break;

            case HoudiniGeoAttributeType.String:
                typeString = "string";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(typeString);
        }
Exemple #5
0
 public static bool TryGetAttribute(this HoudiniGeo geo, string attrName, HoudiniGeoAttributeType type, out HoudiniGeoAttribute attr)
 {
     attr = geo.attributes.FirstOrDefault(a => a.type == type && a.name == attrName);
     return(attr != null);
 }