Ejemplo n.º 1
0
 public override string ToString()
 {
     return("{{Offset:" + Offset.ToString() +
            " Format:" + VertexElementFormat.ToString() +
            " Usage:" + VertexElementUsage.ToString() +
            " UsageIndex: " + UsageIndex.ToString() +
            "}}");
 }
Ejemplo n.º 2
0
        static VertexDeclarationBuilder()
        {
            formatMapping     = new Dictionary <Type, VertexElementFormat>();
            formatMappingSize = new Dictionary <VertexElementFormat, int>();
            usageMapping      = new Dictionary <string, VertexElementUsage>();

            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Byte4), VertexElementFormat.Byte4);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.Color), VertexElementFormat.Color);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.HalfVector2), VertexElementFormat.HalfVector2);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.HalfVector4), VertexElementFormat.HalfVector4);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Normalized101010), VertexElementFormat.Normalized101010);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.NormalizedShort2), VertexElementFormat.NormalizedShort2);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.NormalizedShort4), VertexElementFormat.NormalizedShort4);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Rg32), VertexElementFormat.Rg32);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Rgba32), VertexElementFormat.Rgba32);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Rgba64), VertexElementFormat.Rgba64);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Short2), VertexElementFormat.Short2);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.Short4), VertexElementFormat.Short4);
            formatMapping.Add(typeof(float), VertexElementFormat.Single);
            formatMapping.Add(typeof(Microsoft.Xna.Framework.Graphics.PackedVector.UInt101010), VertexElementFormat.UInt101010);
            formatMapping.Add(typeof(Vector2), VertexElementFormat.Vector2);
            formatMapping.Add(typeof(Vector3), VertexElementFormat.Vector3);
            formatMapping.Add(typeof(Vector4), VertexElementFormat.Vector4);

            foreach (KeyValuePair <Type, VertexElementFormat> kvp in formatMapping)
            {
                formatMappingSize.Add(kvp.Value, Marshal.SizeOf(kvp.Key));
            }

            FieldInfo[] enums = typeof(VertexElementUsage).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            foreach (FieldInfo field in enums)
            {
                VertexElementUsage usage = (VertexElementUsage)field.GetValue(null);
                usageMapping.Add(usage.ToString().ToLower(), usage);
            }
            usageMapping.Add("norm", VertexElementUsage.Normal);
            usageMapping.Add("pos", VertexElementUsage.Position);
            usageMapping.Add("binorm", VertexElementUsage.Binormal);
            usageMapping.Add("colour", VertexElementUsage.Color);
            usageMapping.Add("diffuse", VertexElementUsage.Color);
            usageMapping.Add("col", VertexElementUsage.Color);
            usageMapping.Add("size", VertexElementUsage.PointSize);
            usageMapping.Add("psize", VertexElementUsage.PointSize);
            usageMapping.Add("tex", VertexElementUsage.TextureCoordinate);
            usageMapping.Add("texture", VertexElementUsage.TextureCoordinate);
            usageMapping.Add("texcoord", VertexElementUsage.TextureCoordinate);
            usageMapping.Add("texcoordinate", VertexElementUsage.TextureCoordinate);
        }
 /// <summary>
 /// Combines a vertex declaration usage and usage index into a string name.
 /// </summary>
 /// <param name="vertexElementUsage">A vertex declaration.</param>
 /// <param name="usageIndex">An index for the vertex declaration.</param>
 /// <returns>Resulting encoded name.</returns>
 public static string EncodeName(VertexElementUsage vertexElementUsage, int usageIndex)
 {
     return(vertexElementUsage.ToString() + usageIndex.ToString(CultureInfo.InvariantCulture));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Combines a vertex declaration usage and usage index into a string name.
 /// </summary>
 /// <param name="vertexElementUsage">A vertex declaration.</param>
 /// <param name="usageIndex">An index for the vertex declaration.</param>
 /// <returns>Resulting encoded name.</returns>
 public static string EncodeName(VertexElementUsage vertexElementUsage, int usageIndex)
 {
     return vertexElementUsage.ToString() + usageIndex.ToString(CultureInfo.InvariantCulture);
 }