Пример #1
0
        static void Main(string[] args)
        {
            byte[] buffer = System.IO.File.ReadAllBytes("./api.dimbin");

            // byte[] buffer = new byte[10];
            List <dynamic> result = Dimbin.Parse(buffer);

            Meta meta = Dimbin.GetMeta(buffer);

            Console.Write(meta);

            Console.WriteLine(result[0]);
            Console.WriteLine(result[7][0]);

            Console.WriteLine(Dimbin.StringsParse(result[8])[0]);

            // // float
            // Console.WriteLine(result[0][0]);

            // // int16
            // Console.WriteLine(result[5][0]);

            // // nested
            // Console.WriteLine(result[7][0][0][2]);
        }
Пример #2
0
        static public GeomData Parse(byte[] buffer)
        {
            List <dynamic> dim = Dimbin.Parse(buffer);

            Dictionary <string, AttributeData> attributes = new Dictionary <string, AttributeData>();

            List <String> names = Dimbin.StringsParse(dim[0]);

            for (int i = 0; i < names.Count; i++)
            {
                var array = dim[1][i];
                var props = dim[2][i];

                AttributeData attr;
                attr.array       = array;
                attr.name        = names[i];
                attr.version     = (uint)props[0];
                attr.itemSize    = (uint)props[1];
                attr.count       = (uint)props[2];
                attr.updateRange = new uint[] { (uint)props[3], (uint)props[4] };
                attributes.Add(names[i], attr);
            }

            AttributeData index;

            attributes.TryGetValue("index", out index);
            attributes.Remove("index");

            GeomData result;

            result.attributes = attributes;
            result.index      = index;
            result.drawRange  = new uint[] { (uint)dim[3][0], (uint)dim[3][1] };
            result.userData   = "";

            return(result);
        }