예제 #1
0
        public static MaterialEntry Read(BundleEntry entry)
        {
            MaterialEntry result = new MaterialEntry();

            List <BundleDependency> dependencies = entry.GetDependencies();

            foreach (BundleDependency dependency in dependencies)
            {
                ulong id = dependency.EntryID;

                //DebugTimer t = DebugTimer.Start("LoadDep");
                BundleEntry descEntry1 = entry.Archive.GetEntryByID(id);
                if (descEntry1 == null)
                {
                    string file = BundleCache.GetFileByEntryID(id);
                    if (!string.IsNullOrEmpty(file))
                    {
                        BundleArchive archive = BundleArchive.Read(file);
                        descEntry1 = archive.GetEntryByID(id);
                    }
                }
                //t.StopLog();

                //DebugTimer t2 = DebugTimer.Start("LoadTextureState");
                if (descEntry1 != null && descEntry1.Type == EntryType.TextureState)
                {
                    TextureState state = TextureState.Read(descEntry1);

                    result.TextureStates.Add(state);
                }
                //t2.StopLog();
            }

            MemoryStream  ms = entry.MakeStream();
            BinaryReader2 br = new BinaryReader2(ms);

            br.BigEndian = entry.Console;

            // TODO: Read Material

            br.Close();
            ms.Close();

            result.Color = Color.White;

            if (result.TextureStates.Count > 0)
            {
                result.DiffuseMap = result.TextureStates[0].Texture;
            }
            if (result.TextureStates.Count > 1)
            {
                result.NormalMap = result.TextureStates[1].Texture;
            }
            if (result.TextureStates.Count > 2)
            {
                result.SpecularMap = result.TextureStates[2].Texture;
            }

            return(result);
        }
예제 #2
0
        public static TextureState Read(BundleEntry entry)
        {
            TextureState result = new TextureState();

            List <BundleDependency> dependencies = entry.GetDependencies();

            foreach (BundleDependency dependency in dependencies)
            {
                ulong id = dependency.EntryID;

                if (TextureCache.Contains(id))
                {
                    result.Texture = TextureCache.GetTexture(id);
                }
                else
                {
                    BundleEntry descEntry1 = entry.Archive.GetEntryByID(id);
                    if (descEntry1 == null)
                    {
                        string file = BundleCache.GetFileByEntryID(id);
                        if (!string.IsNullOrEmpty(file))
                        {
                            BundleArchive archive = BundleArchive.Read(file);
                            if (archive != null)
                            {
                                descEntry1 = archive.GetEntryByID(id);
                            }
                        }
                    }

                    if (descEntry1 != null && descEntry1.Type == EntryType.Texture)
                    {
                        if (entry.Console)
                        {
                            result.Texture = GameImage.GetImagePS3(descEntry1.EntryBlocks[0].Data, descEntry1.EntryBlocks[1].Data);
                        }
                        else
                        {
                            result.Texture = GameImage.GetImage(descEntry1.EntryBlocks[0].Data, descEntry1.EntryBlocks[1].Data);
                        }

                        if (result.Texture != null)
                        {
                            TextureCache.AddToCache(id, result.Texture);
                        }

                        break;
                    }
                }
            }

            MemoryStream  ms = entry.MakeStream();
            BinaryReader2 br = new BinaryReader2(ms);

            br.BigEndian = entry.Console;

            // TODO: Read Texture State

            br.Close();
            ms.Close();

            return(result);
        }