Exemplo n.º 1
0
        public bool Load(byte[] file)
        {
            var br  = new System.IO.BinaryReader(new System.IO.MemoryStream(file));
            var buf = new byte[1024];

            if (br.Read(buf, 0, 16) != 16)
            {
                br.Close();
                return(false);
            }

            if (buf[0] != 'E' ||
                buf[1] != 'F' ||
                buf[2] != 'K' ||
                buf[3] != 'M')
            {
                return(false);
            }

            int version = BitConverter.ToInt32(buf, 4);

            if (version > (int)LatestSupportVersion)
            {
                return(false);
            }

            GUID = BitConverter.ToUInt64(buf, 8);

            while (true)
            {
                if (br.Read(buf, 0, 8) != 8)
                {
                    br.Close();
                    break;
                }

                if (buf[0] == 'D' &&
                    buf[1] == 'E' &&
                    buf[2] == 'S' &&
                    buf[3] == 'C')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int count = 0;
                    reader.Get(ref count);

                    for (int i = 0; i < count; i++)
                    {
                        int    lang = 0;
                        string name = null;
                        string desc = null;
                        reader.Get(ref lang);
                        reader.Get(ref name, Encoding.UTF8);
                        reader.Get(ref desc, Encoding.UTF8);
                        Names.Add((Language)lang, name);
                        Descriptions.Add((Language)lang, desc);
                    }
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '_')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    reader.Get(ref ShadingModel);

                    reader.Get(ref HasNormal);

                    reader.Get(ref HasRefraction);

                    reader.Get(ref CustomData1Count);

                    reader.Get(ref CustomData2Count);

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    List <TextureInformation> textures = new List <TextureInformation>();

                    for (int i = 0; i < textureCount; i++)
                    {
                        TextureInformation info = new TextureInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);

                        // name is for human, uniformName is a variable name after 3
                        if (version >= 3)
                        {
                            reader.Get(ref info.UniformName, Encoding.UTF8);
                        }
                        else
                        {
                            info.UniformName = info.Name;
                        }

                        reader.Get(ref info.DefaultPath, Encoding.UTF8);
                        reader.Get(ref info.Index);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.IsParam);
                        int textureType = 0;
                        reader.Get(ref textureType);
                        info.Type = (TextureType)textureType;
                        reader.Get(ref info.Sampler);

                        // convert a path into absolute
                        if (string.IsNullOrEmpty(info.DefaultPath))
                        {
                            info.DefaultPath = string.Empty;
                        }

                        textures.Add(info);
                    }

                    Textures = textures.ToArray();

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    List <UniformInformation> uniforms = new List <UniformInformation>();

                    for (int i = 0; i < uniformCount; i++)
                    {
                        UniformInformation info = new UniformInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);

                        // name is for human, uniformName is a variable name after 3
                        if (version >= 3)
                        {
                            reader.Get(ref info.UniformName, Encoding.UTF8);
                        }
                        else
                        {
                            info.UniformName = info.Name;
                        }

                        reader.Get(ref info.Offset);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.Type);
                        reader.Get(ref info.DefaultValues[0]);
                        reader.Get(ref info.DefaultValues[1]);
                        reader.Get(ref info.DefaultValues[2]);
                        reader.Get(ref info.DefaultValues[3]);
                        uniforms.Add(info);
                    }

                    Uniforms = uniforms.ToArray();
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '2')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    if (version >= 2)
                    {
                        int customDataCount = 0;
                        reader.Get(ref customDataCount);
                        AllocateCustomData(customDataCount);

                        for (int j = 0; j < customDataCount; j++)
                        {
                            int count = 0;
                            reader.Get(ref count);

                            for (int i = 0; i < count; i++)
                            {
                                int    lang = 0;
                                string name = null;
                                string desc = null;
                                reader.Get(ref lang);
                                reader.Get(ref name, Encoding.UTF8);
                                reader.Get(ref desc, Encoding.UTF8);
                                CustomData[j].Summaries.Add((Language)lang, name);
                                CustomData[j].Descriptions.Add((Language)lang, desc);
                            }
                        }
                    }

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    for (int j = 0; j < textureCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Textures[j].Summaries.Add((Language)lang, name);
                            Textures[j].Descriptions.Add((Language)lang, desc);
                        }
                    }

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    for (int j = 0; j < uniformCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Uniforms[j].Summaries.Add((Language)lang, name);
                            Uniforms[j].Descriptions.Add((Language)lang, desc);
                        }
                    }
                }

                if (buf[0] == 'E' &&
                    buf[1] == '_' &&
                    buf[2] == 'C' &&
                    buf[3] == 'D')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int customDataCount = 0;
                    reader.Get(ref customDataCount);
                    AllocateCustomData(customDataCount);

                    for (int j = 0; j < customDataCount; j++)
                    {
                        reader.Get(ref CustomData[j].DefaultValues[0]);
                        reader.Get(ref CustomData[j].DefaultValues[1]);
                        reader.Get(ref CustomData[j].DefaultValues[2]);
                        reader.Get(ref CustomData[j].DefaultValues[3]);
                    }
                }

                if (buf[0] == 'G' &&
                    buf[1] == 'E' &&
                    buf[2] == 'N' &&
                    buf[3] == 'E')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    reader.Get(ref Code, Encoding.UTF8);
                }

                if (buf[0] == 'D' &&
                    buf[1] == 'A' &&
                    buf[2] == 'T' &&
                    buf[3] == 'A')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    string jsonText = Encoding.UTF8.GetString(temp);
                    EditorData = JsonConvert.DeserializeObject <JObject>(jsonText);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            System.IO.FileStream fs = null;
            if (!System.IO.File.Exists(path))
            {
                return(false);
            }

            try
            {
                fs = System.IO.File.Open(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            }
            catch (System.IO.FileNotFoundException e)
            {
                return(false);
            }


            var br = new System.IO.BinaryReader(fs);

            var buf = new byte[1024];


            if (br.Read(buf, 0, 16) != 16)
            {
                fs.Dispose();
                br.Close();
                return(false);
            }

            if (buf[0] != 'e' ||
                buf[1] != 'f' ||
                buf[2] != 'k' ||
                buf[3] != 'M')
            {
                return(false);
            }

            int    version = BitConverter.ToInt32(buf, 4);
            UInt64 guid    = BitConverter.ToUInt64(buf, 8);

            while (true)
            {
                if (br.Read(buf, 0, 8) != 8)
                {
                    fs.Dispose();
                    br.Close();
                    break;
                }


                if (buf[0] == 'p' &&
                    buf[1] == 'a' &&
                    buf[2] == 'r' &&
                    buf[3] == 'a')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int shadingModel = 0;
                    reader.Get(ref shadingModel);

                    bool hasNormal = false;
                    reader.Get(ref hasNormal);

                    bool hasReflection = false;
                    reader.Get(ref hasReflection);

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    List <TextureInformation> textures = new List <TextureInformation>();

                    for (int i = 0; i < textureCount; i++)
                    {
                        TextureInformation info = new TextureInformation();

                        reader.Get(ref info.Name);
                        reader.Get(ref info.DefaultPath);
                        reader.Get(ref info.Index);
                        reader.Get(ref info.IsParam);
                        int textureType = 0;
                        reader.Get(ref textureType);
                        info.Type = (TextureType)textureType;

                        // convert a path into absolute
                        if (string.IsNullOrEmpty(info.DefaultPath))
                        {
                            info.DefaultPath = string.Empty;
                        }
                        else
                        {
                            Func <string, string> escape = (string s) =>
                            {
                                return(s.Replace("%", "%25"));
                            };

                            Func <string, string> unescape = (string s) =>
                            {
                                return(s.Replace("%25", "%"));
                            };

                            Uri basePath   = new Uri(path);
                            Uri targetPath = new Uri(basePath, info.DefaultPath);
                            info.DefaultPath = targetPath.AbsolutePath;
                        }

                        textures.Add(info);
                    }

                    Textures = textures.ToArray();

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    List <UniformInformation> uniforms = new List <UniformInformation>();

                    for (int i = 0; i < uniformCount; i++)
                    {
                        UniformInformation info = new UniformInformation();

                        reader.Get(ref info.Name);
                        reader.Get(ref info.Offset);
                        reader.Get(ref info.Type);
                        reader.Get(ref info.DefaultValues[0]);
                        reader.Get(ref info.DefaultValues[1]);
                        reader.Get(ref info.DefaultValues[2]);
                        reader.Get(ref info.DefaultValues[3]);
                        uniforms.Add(info);
                    }

                    Uniforms = uniforms.ToArray();
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            System.IO.FileStream fs = null;
            if (!System.IO.File.Exists(path))
            {
                return(false);
            }

            try
            {
                fs = System.IO.File.Open(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            }
            catch (System.IO.FileNotFoundException e)
            {
                return(false);
            }


            var br = new System.IO.BinaryReader(fs);

            var buf = new byte[1024];


            if (br.Read(buf, 0, 16) != 16)
            {
                fs.Dispose();
                br.Close();
                return(false);
            }

            if (buf[0] != 'E' ||
                buf[1] != 'F' ||
                buf[2] != 'K' ||
                buf[3] != 'M')
            {
                return(false);
            }

            int version = BitConverter.ToInt32(buf, 4);

            GUID = BitConverter.ToUInt64(buf, 8);

            while (true)
            {
                if (br.Read(buf, 0, 8) != 8)
                {
                    fs.Dispose();
                    br.Close();
                    break;
                }

                if (buf[0] == 'D' &&
                    buf[1] == 'E' &&
                    buf[2] == 'S' &&
                    buf[3] == 'C')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int count = 0;
                    reader.Get(ref count);

                    for (int i = 0; i < count; i++)
                    {
                        int    lang = 0;
                        string name = null;
                        string desc = null;
                        reader.Get(ref lang);
                        reader.Get(ref name, Encoding.UTF8);
                        reader.Get(ref desc, Encoding.UTF8);
                        Names.Add((Language)lang, name);
                        Descriptions.Add((Language)lang, desc);
                    }
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '_')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int shadingModel = 0;
                    reader.Get(ref shadingModel);

                    bool hasNormal = false;
                    reader.Get(ref hasNormal);

                    bool hasReflection = false;
                    reader.Get(ref hasReflection);

                    int customData1Count = 0;
                    reader.Get(ref customData1Count);

                    int customData2Count = 0;
                    reader.Get(ref customData2Count);

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    List <TextureInformation> textures = new List <TextureInformation>();

                    for (int i = 0; i < textureCount; i++)
                    {
                        TextureInformation info = new TextureInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);
                        reader.Get(ref info.DefaultPath, Encoding.UTF8);
                        reader.Get(ref info.Index);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.IsParam);
                        int textureType = 0;
                        reader.Get(ref textureType);
                        info.Type = (TextureType)textureType;
                        int sampler = 0;
                        reader.Get(ref sampler);

                        // convert a path into absolute
                        if (string.IsNullOrEmpty(info.DefaultPath))
                        {
                            info.DefaultPath = string.Empty;
                        }
                        else
                        {
                            Func <string, string> escape = (string s) =>
                            {
                                return(s.Replace("%", "%25"));
                            };

                            Func <string, string> unescape = (string s) =>
                            {
                                return(s.Replace("%25", "%"));
                            };

                            Uri basePath   = new Uri(path);
                            Uri targetPath = new Uri(basePath, info.DefaultPath);
                            info.DefaultPath = targetPath.AbsolutePath;
                        }

                        textures.Add(info);
                    }

                    Textures = textures.ToArray();

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    List <UniformInformation> uniforms = new List <UniformInformation>();

                    for (int i = 0; i < uniformCount; i++)
                    {
                        UniformInformation info = new UniformInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);
                        reader.Get(ref info.Offset);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.Type);
                        reader.Get(ref info.DefaultValues[0]);
                        reader.Get(ref info.DefaultValues[1]);
                        reader.Get(ref info.DefaultValues[2]);
                        reader.Get(ref info.DefaultValues[3]);
                        uniforms.Add(info);
                    }

                    Uniforms = uniforms.ToArray();
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '2')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    for (int j = 0; j < textureCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Textures[j].Names.Add((Language)lang, name);
                            Textures[j].Descriptions.Add((Language)lang, desc);
                        }
                    }

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    for (int j = 0; j < uniformCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Uniforms[j].Names.Add((Language)lang, name);
                            Uniforms[j].Descriptions.Add((Language)lang, desc);
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public bool Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            byte[] file = null;

            if (Core.OnFileLoaded != null)
            {
                file = Core.OnFileLoaded(path);
                if (file == null)
                {
                    return(false);
                }
            }
            else
            {
                if (!System.IO.File.Exists(path))
                {
                    return(false);
                }

                try
                {
                    file = System.IO.File.ReadAllBytes(path);
                }
                catch
                {
                    return(false);
                }
            }

            var br  = new System.IO.BinaryReader(new System.IO.MemoryStream(file));
            var buf = new byte[1024];

            if (br.Read(buf, 0, 16) != 16)
            {
                br.Close();
                return(false);
            }

            if (buf[0] != 'E' ||
                buf[1] != 'F' ||
                buf[2] != 'K' ||
                buf[3] != 'M')
            {
                return(false);
            }

            int version = BitConverter.ToInt32(buf, 4);

            GUID = BitConverter.ToUInt64(buf, 8);

            while (true)
            {
                if (br.Read(buf, 0, 8) != 8)
                {
                    br.Close();
                    break;
                }

                if (buf[0] == 'D' &&
                    buf[1] == 'E' &&
                    buf[2] == 'S' &&
                    buf[3] == 'C')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int count = 0;
                    reader.Get(ref count);

                    for (int i = 0; i < count; i++)
                    {
                        int    lang = 0;
                        string name = null;
                        string desc = null;
                        reader.Get(ref lang);
                        reader.Get(ref name, Encoding.UTF8);
                        reader.Get(ref desc, Encoding.UTF8);
                        Names.Add((Language)lang, name);
                        Descriptions.Add((Language)lang, desc);
                    }
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '_')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    int shadingModel = 0;
                    reader.Get(ref shadingModel);

                    bool hasNormal = false;
                    reader.Get(ref hasNormal);

                    bool hasReflection = false;
                    reader.Get(ref hasReflection);

                    int customData1Count = 0;
                    reader.Get(ref customData1Count);

                    int customData2Count = 0;
                    reader.Get(ref customData2Count);

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    List <TextureInformation> textures = new List <TextureInformation>();

                    for (int i = 0; i < textureCount; i++)
                    {
                        TextureInformation info = new TextureInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);

                        // name is for human, uniformName is a variable name after 3
                        if (version >= 3)
                        {
                            reader.Get(ref info.UniformName, Encoding.UTF8);
                        }
                        else
                        {
                            info.UniformName = info.Name;
                        }

                        reader.Get(ref info.DefaultPath, Encoding.UTF8);
                        reader.Get(ref info.Index);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.IsParam);
                        int textureType = 0;
                        reader.Get(ref textureType);
                        info.Type = (TextureType)textureType;
                        int sampler = 0;
                        reader.Get(ref sampler);

                        // convert a path into absolute
                        if (string.IsNullOrEmpty(info.DefaultPath))
                        {
                            info.DefaultPath = string.Empty;
                        }
                        else
                        {
                            info.DefaultPath = Utils.Misc.GetAbsolutePath(path, info.DefaultPath);
                        }

                        textures.Add(info);
                    }

                    Textures = textures.ToArray();

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    List <UniformInformation> uniforms = new List <UniformInformation>();

                    for (int i = 0; i < uniformCount; i++)
                    {
                        UniformInformation info = new UniformInformation();

                        reader.Get(ref info.Name, Encoding.UTF8);

                        // name is for human, uniformName is a variable name after 3
                        if (version >= 3)
                        {
                            reader.Get(ref info.UniformName, Encoding.UTF8);
                        }
                        else
                        {
                            info.UniformName = info.Name;
                        }

                        reader.Get(ref info.Offset);
                        reader.Get(ref info.Priority);
                        reader.Get(ref info.Type);
                        reader.Get(ref info.DefaultValues[0]);
                        reader.Get(ref info.DefaultValues[1]);
                        reader.Get(ref info.DefaultValues[2]);
                        reader.Get(ref info.DefaultValues[3]);
                        uniforms.Add(info);
                    }

                    Uniforms = uniforms.ToArray();
                }

                if (buf[0] == 'P' &&
                    buf[1] == 'R' &&
                    buf[2] == 'M' &&
                    buf[3] == '2')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    if (version >= 2)
                    {
                        int customDataCount = 0;
                        reader.Get(ref customDataCount);

                        CustomData = new CustomDataInformation[customDataCount];

                        for (int j = 0; j < customDataCount; j++)
                        {
                            CustomData[j] = new CustomDataInformation();

                            int count = 0;
                            reader.Get(ref count);

                            for (int i = 0; i < count; i++)
                            {
                                int    lang = 0;
                                string name = null;
                                string desc = null;
                                reader.Get(ref lang);
                                reader.Get(ref name, Encoding.UTF8);
                                reader.Get(ref desc, Encoding.UTF8);
                                CustomData[j].Summaries.Add((Language)lang, name);
                                CustomData[j].Descriptions.Add((Language)lang, desc);
                            }
                        }
                    }

                    int textureCount = 0;
                    reader.Get(ref textureCount);

                    for (int j = 0; j < textureCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Textures[j].Summaries.Add((Language)lang, name);
                            Textures[j].Descriptions.Add((Language)lang, desc);
                        }
                    }

                    int uniformCount = 0;
                    reader.Get(ref uniformCount);

                    for (int j = 0; j < uniformCount; j++)
                    {
                        int count = 0;
                        reader.Get(ref count);

                        for (int i = 0; i < count; i++)
                        {
                            int    lang = 0;
                            string name = null;
                            string desc = null;
                            reader.Get(ref lang);
                            reader.Get(ref name, Encoding.UTF8);
                            reader.Get(ref desc, Encoding.UTF8);
                            Uniforms[j].Summaries.Add((Language)lang, name);
                            Uniforms[j].Descriptions.Add((Language)lang, desc);
                        }
                    }
                }

                if (buf[0] == 'G' &&
                    buf[1] == 'E' &&
                    buf[2] == 'N' &&
                    buf[3] == 'E')
                {
                    var temp = new byte[BitConverter.ToInt32(buf, 4)];
                    if (br.Read(temp, 0, temp.Length) != temp.Length)
                    {
                        return(false);
                    }

                    var reader = new BinaryReader(temp);

                    reader.Get(ref Code, Encoding.UTF8);
                }
            }

            return(true);
        }