예제 #1
0
        private static Model ReadModel(uint pointer)
        {
            bool bSpecial = false;

            pbs.Seek(pointer, System.IO.SeekOrigin.Begin);
            uint header = MakiExtended.UintLittleEndian(pbs.ReadUInt());

            if (header != 0x01000100)
            {
                Console.WriteLine("WARNING- THIS STAGE IS DIFFERENT! It has weird object section. INTERESTING, TO REVERSE!");
                bSpecial = true;
            }
            ushort verticesCount = pbs.ReadUShort();

            Vertex[] vertices = new Vertex[verticesCount];
            for (int i = 0; i < verticesCount; i++)
            {
                vertices[i] = ReadVertex();
            }
            if (bSpecial && Memory.encounters[Memory.battle_encounter].bScenario == 20)
            {
                return(new Model());
            }
            pbs.Seek((pbs.Tell() % 4) + 4, System.IO.SeekOrigin.Current);
            ushort trianglesCount = pbs.ReadUShort();
            ushort quadsCount     = pbs.ReadUShort();

            pbs.Seek(4, System.IO.SeekOrigin.Current);
            Triangle[] triangles = new Triangle[trianglesCount];
            Quad[]     quads     = new Quad[quadsCount];
            if (trianglesCount > 0)
            {
                for (int i = 0; i < trianglesCount; i++)
                {
                    triangles[i] = ReadTriangle();
                }
            }
            if (quadsCount > 0)
            {
                for (int i = 0; i < quadsCount; i++)
                {
                    quads[i] = ReadQuad();
                }
            }
            return(new Model()
            {
                vertices = vertices,
                triangles = triangles,
                quads = quads
            });
        }
예제 #2
0
        private void ReadSkeleton()
        {
            ms.Seek(pBase + pBones, SeekOrigin.Begin);

            if (ms.Position > ms.Length)
            {
                return; //error handler
            }
            bones = new Bone[cSkeletonBones];
            for (int i = 0; i < cSkeletonBones; i++)
            {
                bones[i] = MakiExtended.ByteArrayToStructure <Bone>(br.ReadBytes(64));
            }

            return;
        }
예제 #3
0
        public ArchiveWorker(string path)
        {
            _path = MakiExtended.GetUnixFullPath(path);
            string root = Path.GetDirectoryName(_path);
            string file = Path.GetFileNameWithoutExtension(_path);
            string fi   = MakiExtended.GetUnixFullPath($"{Path.Combine(root, file)}{Memory.Archives.B_FileIndex}");
            string fl   = MakiExtended.GetUnixFullPath($"{Path.Combine(root, file)}{Memory.Archives.B_FileList}");

            if (!File.Exists(fi))
            {
                throw new Exception($"There is no {file}.fi file!\nExiting...");
            }
            if (!File.Exists(fl))
            {
                throw new Exception($"There is no {file}.fl file!\nExiting...");
            }
            FileList = ProduceFileLists();
        }
예제 #4
0
        private void ReadGeometry()
        {
            ms.Seek(pBase + pVertices, SeekOrigin.Begin);
            if (ms.Position > ms.Length || pVertices + ms.Position > ms.Length) //pvert error handler
            {
                return;                                                         //error handler
            }
            vertices = new Vector4[cVertices];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = new Vector4(br.ReadInt16(), br.ReadInt16(), br.ReadInt16(), br.ReadInt16());
            }

            ms.Seek(pBase + pFaces, SeekOrigin.Begin);
            List <Face> face = new List <Face>();

            for (int i = 0; i < cFaces; i++)
            {
                face.Add(MakiExtended.ByteArrayToStructure <Face>(br.ReadBytes(64)));
            }
            faces = face.ToArray();
            return;
        }
예제 #5
0
 public static byte[] GetBinaryFile(string archiveName, string fileName)
 {
     byte[] isComp = GetBin(MakiExtended.GetUnixFullPath(archiveName), fileName);
     return(isComp == null ? null : _compressed?LZSS.DecompressAll(isComp, (uint)isComp.Length, (int)_unpackedFileSize) : isComp);
 }
예제 #6
0
        private static byte GetClutId(ushort clut)
        {
            ushort bb = MakiExtended.UshortLittleEndian(clut);

            return((byte)(((bb >> 14) & 0x03) | (bb << 2) & 0x0C));
        }