Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DirectoryInfo InputDir  = new DirectoryInfo(config.InputDir);
            DirectoryInfo OutputDir = new DirectoryInfo(config.OutputDir);

            try
            {
                if (!InputDir.Exists)
                {
                    InputDir.Create(); Logger.log("The input dir was not found and was created.", Logger.Type.WARNING, InputDir.FullName);
                }
                if (!OutputDir.Exists)
                {
                    OutputDir.Create(); Logger.log("The output dir was not found and was created.", Logger.Type.WARNING, OutputDir.FullName);
                }
                foreach (FileInfo file in InputDir.GetFiles())
                {
                    if (file.Name.Contains(".adt"))
                    {
                        Files.WOTLK.ADT adt = new Files.WOTLK.ADT(file.FullName);

                        if (config.GroundEffectsAdding && !adt.ADTfileInfo.Name.Contains("#"))
                        {
                            adt = effectsAdder.AddGroundEffects(adt);
                        }
                        new Files.BFA.ADT(adt).WriteFile(OutputDir);
                        new Files.BFA.OBJ0(adt).WriteFile(OutputDir);
                        new Files.BFA.OBJ1(adt).WriteFile(OutputDir);
                        new Files.BFA.TEX0(adt).WriteFile(OutputDir);
                        Logger.hr();
                    }
                }

                Logger.log("Done...", Logger.Type.INFO, "Many thanks to wowdev.wiki. You have done the real work!");
                System.Threading.Thread.Sleep(3000);
            }
            catch (Exception e)
            {
                Logger.log(e.Message, Logger.Type.ERROR, e.StackTrace);
            }
        }
Ejemplo n.º 2
0
        public Files.WOTLK.ADT AddGroundEffects(Files.WOTLK.ADT old)
        {
            if (GroundEffects != null)
            {
                bool hasBeenAdded = false;

                for (int x = 0; x < old.MTEX.Textures.Count; x++)
                {
                    old.MTEX.Textures[x] = old.MTEX.Textures[x].Replace("\\", "/");
                }

                for (int x = 0; x < old.MCNKs.Count; x++)
                {
                    if (old.MCNKs[x].Mcly != null)
                    {
                        for (int y = 0; y < old.MCNKs[x].Mcly.Entries.Count; y++)
                        {
                            Files.Structs.MCLYentry entry = old.MCNKs[x].Mcly.Entries[y];
                            try
                            {
                                entry.Detailtextureid = (uint)GroundEffects.Find(
                                    a => a.TexturePath.Replace("\\", "/") == old.MTEX.Textures[(int)entry.Textid]
                                    ).GroundEffectTextureID;
                                hasBeenAdded = true;
                            }
                            catch
                            {
                                entry.Detailtextureid = 0;
                            }
                            old.MCNKs[x].Mcly.Entries[y] = entry;
                        }
                    }

                    //Console.WriteLine("bevor:{0}", x);
                    //print_low_quality_map(old.MCNKs[x].MCHeader.GroundEffectsMap);

                    //Thanks to Mjollna(modcraft.io)! I use your code for this.
                    if (hasBeenAdded)
                    {
                        for (int y = 0; y < old.MCNKs[x].MCHeader.GroundEffectsMap.Length; y++)
                        {
                            old.MCNKs[x].MCHeader.GroundEffectsMap[y] = 0x0;
                        }

                        for (int layer = 1; layer < old.MCNKs[x].Mcly.Entries.Count; layer++)
                        {
                            byte[] amap = getAlphaMap(old.MCNKs[x], layer);

                            for (int a = 0; a < 8; a++)
                            {
                                for (int b = 0; b < 8; b++)
                                {
                                    int sum = 0;
                                    for (int c = 0; c < 8; c++)
                                    {
                                        for (int d = 0; d < 8; d++)
                                        {
                                            sum += amap[(a * 8 + c) * 64 + (b * 8 + d)];
                                        }
                                    }

                                    if (sum > 120 * 8 * 8)
                                    {
                                        int array_index = (a * 8 + b) / 4;
                                        int bit_index   = ((a * 8 + b) % 4) * 2; // -6

                                        old.MCNKs[x].MCHeader.GroundEffectsMap[array_index] |= Convert.ToByte(((layer & 3) << bit_index));
                                    }
                                }
                            }
                        }
                    }
                    //Console.WriteLine("after:{0}", x);
                    //print_low_quality_map(old.MCNKs[x].MCHeader.GroundEffectsMap);
                }

                if (hasBeenAdded)
                {
                    Logger.log("Added Groundeffects", Logger.Type.INFO, old.ADTfileInfo.Name);
                }
            }

            return(old);
        }