예제 #1
0
            public static TMTerrainDesc Read(StreamReader data, StreamWriter outputData, bool write = true)
            {
                TMTerrainDesc obj = new TMTerrainDesc();

                obj.terrainType = Utils.readAndWriteUInt32(data, outputData, write);
                obj.terrainTex  = TerrainTex.Read(data, outputData, write);

                return(obj);
            }
예제 #2
0
            public static TexMerge Read(StreamReader data, StreamWriter outputData, bool write = true)
            {
                TexMerge obj = new TexMerge();

                obj.CornerTerrainMaps  = new List <TerrainAlphaMap>();
                obj.SideTerrainMaps    = new List <TerrainAlphaMap>();
                obj.RoadMaps           = new List <RoadAlphaMap>();
                obj.TerrainDescription = new List <TMTerrainDesc>();

                //obj.BaseTexSize = Utils.readAndWriteUInt32(data, outputData, write);
                obj.BaseTexSize = Utils.readAndWriteUInt32(data, outputData, false);
                outputData.BaseStream.Write(BitConverter.GetBytes((uint)256), 0, 4);

                uint num_corner_terrain_maps = Utils.readAndWriteUInt32(data, outputData, write);

                for (uint i = 0; i < num_corner_terrain_maps; i++)
                {
                    obj.CornerTerrainMaps.Add(TerrainAlphaMap.Read(data, outputData, write));
                }

                uint num_side_terrain_maps = Utils.readAndWriteUInt32(data, outputData, write);

                for (uint i = 0; i < num_side_terrain_maps; i++)
                {
                    obj.SideTerrainMaps.Add(TerrainAlphaMap.Read(data, outputData, write));
                }

                uint num_road_maps = Utils.readAndWriteUInt32(data, outputData, write);

                for (uint i = 0; i < num_road_maps; i++)
                {
                    obj.RoadMaps.Add(RoadAlphaMap.Read(data, outputData, write));
                }

                uint num_terrain_desc = Utils.readAndWriteUInt32(data, outputData, write);

                for (uint i = 0; i < num_terrain_desc; i++)
                {
                    obj.TerrainDescription.Add(TMTerrainDesc.Read(data, outputData, write));
                }

                //TMTerrainDesc BarrenRock = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Grassland = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Ice = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc LushGrass = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc MarshSparseSwamp = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc MudRichDirt = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc ObsidianPlain = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc PackedDirt = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc PatchyDirt = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc PatchyGrassland = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc SandYellow = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc SandGrey = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc SandRockStrewn = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc SedimentaryRock = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc SemiBarrenRock = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Snow = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc WaterRunning = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc WaterStandingFresh = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc WaterShallowSea = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc WaterShallowStillSea = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc WaterDeepSea = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Forestfloor = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc FauxWaterRunning = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc SeaSlime = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc Argila = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Volcano1 = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Volcano2 = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc BlueIce = TMTerrainDesc.Read(data, outputData, false);

                //TMTerrainDesc Moss = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc DarkMoss = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc olthoi = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc DesolateLands = TMTerrainDesc.Read(data, outputData, false);
                //TMTerrainDesc Road = TMTerrainDesc.Read(data, outputData, false);

                //BarrenRock.terrainTex = Snow.terrainTex;
                //Grassland.terrainTex.TexGID = 0x0500146B;
                ////LushGrass.terrainTex = Snow.terrainTex;
                ////PatchyDirt.terrainTex = Snow.terrainTex;
                //PatchyGrassland.terrainTex = Snow.terrainTex;
                ////Forestfloor.terrainTex = Ice.terrainTex;
                //WaterRunning.terrainTex = BlueIce.terrainTex;
                //WaterStandingFresh.terrainTex = BlueIce.terrainTex;

                //BarrenRock.Write(outputData);
                //Grassland.Write(outputData);
                //Ice.Write(outputData);
                //LushGrass.Write(outputData);

                //MarshSparseSwamp.Write(outputData);
                //MudRichDirt.Write(outputData);
                //ObsidianPlain.Write(outputData);
                //PackedDirt.Write(outputData);

                //PatchyDirt.Write(outputData);
                //PatchyGrassland.Write(outputData);
                //SandYellow.Write(outputData);
                //SandGrey.Write(outputData);

                //SandRockStrewn.Write(outputData);
                //SedimentaryRock.Write(outputData);
                //SemiBarrenRock.Write(outputData);
                //Snow.Write(outputData);

                //WaterRunning.Write(outputData);
                //WaterStandingFresh.Write(outputData);
                //WaterShallowSea.Write(outputData);
                //WaterShallowStillSea.Write(outputData);

                //WaterDeepSea.Write(outputData);
                //Forestfloor.Write(outputData);
                //FauxWaterRunning.Write(outputData);
                //SeaSlime.Write(outputData);

                //Argila.Write(outputData);
                //Volcano1.Write(outputData);
                //Volcano2.Write(outputData);
                //BlueIce.Write(outputData);

                //Moss.Write(outputData);
                //DarkMoss.Write(outputData);
                //olthoi.Write(outputData);
                //DesolateLands.Write(outputData);
                //Road.Write(outputData);

                return(obj);
            }
예제 #3
0
        //In DM the 130F0000 is the equivalent of ToD 13000000 and the DM's 13000000 is possibly used for software rendering
        static public void convert(string filename)
        {
            StreamReader inputFile = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read));

            if (inputFile == null)
            {
                Console.WriteLine("Unable to open {0}", filename);
                return;
            }
            StreamWriter outputFile = new StreamWriter(new FileStream("./130F0000 - World Info - DM.bin", FileMode.Create, FileAccess.Write));

            if (outputFile == null)
            {
                Console.WriteLine("Unable to open 130F0000 - World Info - Winter.bin");
                return;
            }

            Console.WriteLine("Converting region file to winter...");

            byte[] buffer = new byte[1024];

            uint   fileHeader;
            uint   loaded;
            uint   timeStamp;
            string regionName;
            uint   partsMask;
            uint   unknown1;
            uint   unknown2;
            uint   unknown3;
            uint   unknown4;
            uint   unknown5;
            uint   unknown6;
            uint   unknown7;

            LandDefs landDef;
            GameTime gameTime;
            uint     next;

            SkyDesc     skyInfo;
            SoundDesc   soundInfo;
            SceneDesc   sceneInfo;
            TerrainDesc terrainInfo;
            RegionMisc  regionMisc;

            fileHeader = Utils.readAndWriteUInt32(inputFile, outputFile);
            if (fileHeader != 0x13000000 && fileHeader != 0x130F0000)
            {
                Console.WriteLine("Invalid header, aborting.");
                return;
            }

            loaded     = Utils.readAndWriteUInt32(inputFile, outputFile);
            timeStamp  = Utils.readAndWriteUInt32(inputFile, outputFile);
            regionName = Utils.readAndWriteString(inputFile, outputFile);
            partsMask  = Utils.readAndWriteUInt32(inputFile, outputFile);

            unknown1 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown2 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown3 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown4 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown5 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown6 = Utils.readAndWriteUInt32(inputFile, outputFile);
            unknown7 = Utils.readAndWriteUInt32(inputFile, outputFile);

            landDef  = LandDefs.Read(inputFile, outputFile);
            gameTime = GameTime.Read(inputFile, outputFile);

            next = Utils.readAndWriteUInt32(inputFile, outputFile);

            if ((next & 0x10) > 0)
            {
                skyInfo = SkyDesc.Read(inputFile, outputFile);
            }

            if ((next & 0x01) > 0)
            {
                soundInfo = SoundDesc.Read(inputFile, outputFile);
            }

            if ((next & 0x02) > 0)
            {
                sceneInfo = SceneDesc.Read(inputFile, outputFile);
            }

            terrainInfo = TerrainDesc.Read(inputFile, outputFile);

            if ((next & 0x0200) > 0)
            {
                regionMisc = RegionMisc.Read(inputFile, outputFile);
            }

            StreamWriter outputFile2 = new StreamWriter(new FileStream("./130F0000 - Terrain Textures - DM.txt", FileMode.Create, FileAccess.Write));

            if (outputFile2 == null)
            {
                Console.WriteLine("Unable to open 130F0000 - Terrain Textures - DM.txt");
                return;
            }

            //for (int i = 0; i < terrainInfo.LandSurfaces.texMerge.CornerTerrainMaps.Count; i++)
            //{
            //    TerrainAlphaMap cornerTerrainMap = terrainInfo.LandSurfaces.texMerge.CornerTerrainMaps[i];

            //    outputFile2.WriteLine("{0}", cornerTerrainMap.TexGID.ToString("x"));
            //    outputFile2.Flush();
            //}

            //for (int i = 0; i < terrainInfo.LandSurfaces.texMerge.SideTerrainMaps.Count; i++)
            //{
            //    TerrainAlphaMap sideTerrainMap = terrainInfo.LandSurfaces.texMerge.SideTerrainMaps[i];

            //    outputFile2.WriteLine("{0}", sideTerrainMap.TexGID.ToString("x"));
            //    outputFile2.Flush();
            //}

            //for (int i = 0; i < terrainInfo.LandSurfaces.texMerge.RoadMaps.Count; i++)
            //{
            //    RoadAlphaMap roadMap = terrainInfo.LandSurfaces.texMerge.RoadMaps[i];

            //    outputFile2.WriteLine("{0}", roadMap.RoadTexGID.ToString("x"));
            //    outputFile2.Flush();
            //}

            for (int i = 0; i < terrainInfo.LandSurfaces.texMerge.TerrainDescription.Count; i++)
            {
                TMTerrainDesc desc         = terrainInfo.LandSurfaces.texMerge.TerrainDescription[i];
                string        terrainName  = "Unknown";
                uint          terrainColor = 0;
                if (i < terrainInfo.TerrainTypes.Count)
                {
                    terrainName  = terrainInfo.TerrainTypes[(int)desc.terrainType].TerrainName;
                    terrainColor = terrainInfo.TerrainTypes[(int)desc.terrainType].TerrainColor;
                }
                else if (i == 31)
                {
                    terrainName  = "Unused";
                    terrainColor = 0;
                }
                else if (i == 32)
                {
                    terrainName  = "Road";
                    terrainColor = 0;
                }

                terrainName = terrainName.PadLeft(20);

                outputFile2.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}", desc.terrainType, terrainName, desc.terrainTex.TexGID.ToString("x8"), desc.terrainTex.TexTiling, desc.terrainTex.DetailTexGID.ToString("x8"),
                                      desc.terrainTex.DetailTexTiling, desc.terrainTex.MaxVertBright, desc.terrainTex.MaxVertHue, desc.terrainTex.MaxVertSaturate, desc.terrainTex.MinVertBright,
                                      desc.terrainTex.MinVertHue, desc.terrainTex.MinVertSaturate);

                //outputFile2.WriteLine("{0}\t{1}", terrainName, desc.terrainTex.TexGID.ToString("x8"));
                outputFile2.Flush();
            }
            outputFile2.Close();

            inputFile.Close();

            outputFile.Flush();
            outputFile.Close();
            Console.WriteLine("Done");
        }