static VertexDeclarationBuilder() { _formatMapping = new Dictionary <Type, DeclarationType>(); _formatMappingSize = new Dictionary <DeclarationType, int>(); _usageMapping = new Dictionary <string, DeclarationUsage>(); _formatMapping.Add(typeof(Color), DeclarationType.Color); _formatMapping.Add(typeof(Half2), DeclarationType.HalfTwo); _formatMapping.Add(typeof(Half4), DeclarationType.HalfFour); _formatMapping.Add(typeof(float), DeclarationType.Float1); _formatMapping.Add(typeof(Vector2), DeclarationType.Float2); _formatMapping.Add(typeof(Vector3), DeclarationType.Float3); _formatMapping.Add(typeof(Vector4), DeclarationType.Float4); foreach (KeyValuePair <Type, DeclarationType> kvp in _formatMapping) { _formatMappingSize.Add(kvp.Value, Marshal.SizeOf(kvp.Key)); } FieldInfo[] enums = typeof(DeclarationUsage).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); foreach (FieldInfo field in enums) { DeclarationUsage usage = (DeclarationUsage)field.GetValue(null); _usageMapping.Add(usage.ToString().ToLower(), usage); } _usageMapping.Add("norm", DeclarationUsage.Normal); _usageMapping.Add("pos", DeclarationUsage.Position); _usageMapping.Add("binorm", DeclarationUsage.Binormal); _usageMapping.Add("colour", DeclarationUsage.Color); _usageMapping.Add("diffuse", DeclarationUsage.Color); _usageMapping.Add("col", DeclarationUsage.Color); _usageMapping.Add("size", DeclarationUsage.PointSize); _usageMapping.Add("psize", DeclarationUsage.PointSize); _usageMapping.Add("tex", DeclarationUsage.TextureCoordinate); _usageMapping.Add("texture", DeclarationUsage.TextureCoordinate); _usageMapping.Add("texcoord", DeclarationUsage.TextureCoordinate); _usageMapping.Add("texcoordinate", DeclarationUsage.TextureCoordinate); }
/// <summary> /// Returns a string describing the object. /// </summary> /// <returns>A string describing the object.</returns> public override string ToString() { return(Usage.ToString() + "[" + UsageIndex + "]"); }