Ejemplo n.º 1
0
        public void IsWritingBackCorrectly(string fileName) => File.OpenRead($"Imaging/res/{fileName}.tm2").Using(x =>
                                                                                                                  Helpers.AssertStream(x, stream =>
        {
            var images = Tm2.Read(stream);

            var newStream = new MemoryStream();
            Tm2.Write(newStream, images);

            return(newStream);
        }));
Ejemplo n.º 2
0
        public static void Write(Stream stream, Pmp pmp)
        {
            stream.Position = 0;
            BinaryMapping.WriteObject <Header>(stream, pmp.header);

            for (int i = 0; i < pmp.objectInfo.Count; i++)
            {
                BinaryMapping.WriteObject <ObjectInfo>(stream, pmp.objectInfo[i]);
            }

            List <Pmo> nPmoList = pmp.PmoList;

            nPmoList.Sort((l, r) => l.PMO_StartPosition.CompareTo(r.PMO_StartPosition));

            for (int p = 0; p < nPmoList.Count; p++)
            {
                uint off = (uint)stream.Position;
                stream.Seek(0x44 + (p * 0x30), SeekOrigin.Begin);
                stream.Write(off);
                stream.Seek(0, SeekOrigin.End);

                BinaryMapping.WriteObject <Pmo.Header>(stream, nPmoList[p].header);

                for (int g = 0; g < nPmoList[p].textureInfo.Length; g++)
                {
                    BinaryMapping.WriteObject <Pmo.TextureInfo>(stream, nPmoList[p].textureInfo[g]);
                }

                Pmo.WriteMeshData(stream, nPmoList[p]);
            }

            uint pos = (uint)stream.Position;

            stream.Seek(0x1C, SeekOrigin.Begin);
            stream.Write(pos);
            stream.Seek(0, SeekOrigin.End);

            for (int tl = 0; tl < pmp.TextureList.Count; tl++)
            {
                BinaryMapping.WriteObject <PMPTextureInfo>(stream, pmp.TextureList[tl]);
            }

            for (int td = 0; td < pmp.TextureList.Count; td++)
            {
                uint       sPos = (uint)stream.Position;
                List <Tm2> l    = new List <Tm2>();
                l.Add(pmp.TextureDataList[td]);
                Tm2.Write(stream, l);

                stream.Seek(pos + (td * 0x20), SeekOrigin.Begin);
                stream.Write(sPos);
                stream.Seek(0, SeekOrigin.End);
            }
        }
Ejemplo n.º 3
0
 public static void WriteTextureData(Stream stream, Pmo pmo)
 {
     // Write textures.
     for (int t = 0; t < pmo.texturesData.Count; t++)
     {
         pmo.TextureOffsets.Add((uint)stream.Position);
         List <Tm2> tm2list = new List <Tm2>();
         tm2list.Add(pmo.texturesData[t]);
         Tm2.Write(stream, tm2list);
     }
 }
Ejemplo n.º 4
0
        public static void Write(Stream stream, Pmp pmp)
        {
            stream.Position = 0;
            BinaryMapping.WriteObject <Header>(stream, pmp.header);

            for (int i = 0; i < pmp.objectInfo.Count; i++)
            {
                BinaryMapping.WriteObject <ObjectInfo>(stream, pmp.objectInfo[i]);
            }

            List <Pmo> nPmoList = pmp.PmoList;

            nPmoList.Sort((l, r) => l.PMO_StartPosition.CompareTo(r.PMO_StartPosition));

            for (int p = 0; p < nPmoList.Count; p++)
            {
                BinaryMapping.WriteObject <Pmo.Header>(stream, nPmoList[p].header);

                for (int g = 0; g < nPmoList[p].textureInfo.Length; g++)
                {
                    BinaryMapping.WriteObject <Pmo.TextureInfo>(stream, nPmoList[p].textureInfo[g]);
                }

                Pmo.WriteMeshData(stream, nPmoList[p]);
            }

            for (int tl = 0; tl < pmp.TextureList.Count; tl++)
            {
                BinaryMapping.WriteObject <PMPTextureInfo>(stream, pmp.TextureList[tl]);
            }

            for (int td = 0; td < pmp.TextureList.Count; td++)
            {
                List <Tm2> l = new List <Tm2>();
                l.Add(pmp.TextureDataList[td]);
                Tm2.Write(stream, l);
            }
        }