private void DumpMesh(uint id)
        {
            EmbeddedFile file = DataProvider.Instance.PortalDatReader.LocateFile(id);
            ComplexMesh  mesh = new ComplexMesh(file);

            mesh.ReadComplexMesh();
            try
            {
                file.PrepareFileForReading();
                rtbMeshDump.Clear();
                rtbMeshDump.AppendText(String.Format("Flags: 0x{1:X2}  Count: {2}{0}{0}", Environment.NewLine, mesh.Flags, mesh.SimpleMeshCount));
                WriteLineNumber(0, 0);
                for (int i = 0; i < file.m_debugData.Length; i++)
                {
                    if (i != 0 && i % 8 == 0)
                    {
                        // line break;
                        rtbMeshDump.AppendText(Environment.NewLine);
                        WriteLineNumber(i / 8, i * 4);
                    }
                    rtbMeshDump.AppendText(String.Format("{0:X8} ", file.m_debugData[i]));
                }
                rtbMeshDump.AppendText(String.Format("{0}{0}", Environment.NewLine));
                WriteLineNumber(0, 0);
                for (int i = 0; i < file.m_debugDataFloats.Length; i++)
                {
                    if (i != 0 && i % 8 == 0)
                    {
                        // line break;
                        rtbMeshDump.AppendText(Environment.NewLine);
                        WriteLineNumber(i / 8, i * 4);
                    }
                    rtbMeshDump.AppendText(String.Format("{0,8:0.00000} ", file.m_debugDataFloats[i]));
                }
            }
            finally
            {
                file.FileReadingComplete();
            }
        }
Example #2
0
        public List <EmbeddedFileEntry> GetComplexMeshListBySimpleMeshID(uint simpleMeshID)
        {
            List <EmbeddedFileEntry> rawList    = GetComplexMeshList();
            List <EmbeddedFileEntry> resultList = new List <EmbeddedFileEntry>();

            foreach (EmbeddedFileEntry entry in rawList)
            {
                try
                {
                    ComplexMesh mesh = LoadComplexMesh(entry.FileID);
                    foreach (uint id in mesh.SimpleMeshIDs)
                    {
                        if (id == simpleMeshID)
                        {
                            resultList.Add(entry);
                            break;
                        }
                    }
                }
                catch (Exception) { }
            }
            return(resultList);
        }
Example #3
0
        public static void TestComplexMeshes()
        {
            DatReader reader = DataProvider.Instance.PortalDatReader;

            //EmbeddedFile file = reader.LocateFile(0x0200001e);
            EmbeddedFile file = reader.LocateFile(0x020000A1);

            //EmbeddedFile file = reader.LocateFile(0x0200012c);
            if (file == null)
            {
                Console.WriteLine("File not found.");
            }
            else
            {
                Console.WriteLine("File found, has length of {0}.", file.FileLength);

                // dump the file data

                byte[] data = reader.RetrieveFileData(file);
                Dump(data, "mesh 0x" + file.FileId.ToString("X8"));

                ComplexMesh mesh = new ComplexMesh(file);
                mesh.ReadComplexMesh();

                //TreeOutput.OutputTree(@"D:\", mesh, mesh.ID);

                List <EmbeddedFileEntry> fileList = MeshProvider.Instance.GetComplexMeshList();
                fileList.Sort();
                uint             minS = UInt32.MinValue, minF = 0;
                List <CMDBGData> dbgList = new List <CMDBGData>();
                foreach (EmbeddedFileEntry fileEntry in fileList)
                {
                    try
                    {
                        if (fileEntry.Size == 164)
                        {
                            TryComplexMesh(reader, fileEntry.FileID);
                            //Debugger.Break();
                        }
                        if (fileEntry.Size > minS)
                        {
                            minS = fileEntry.Size;
                            minF = fileEntry.FileID;
                        }
                        ComplexMesh listMesh = TryComplexMesh(reader, fileEntry.FileID);
                        dbgList.Add(new CMDBGData(fileEntry.FileID, fileEntry.Size, listMesh.Flags, listMesh.SimpleMeshCount));
                    }
                    catch (Exception)
                    {
                        //Debugger.Break();
                        //Console.WriteLine("Failed on object 0x{0:X8}, error: {1}", fileEntry.FileID, ex.Message);
                    }
                }
                dbgList.Sort();

                FileInfo exportFile = new FileInfo(Settings.TreeExportDir + "\\complex_listing.txt");
                if (exportFile.Exists)
                {
                    exportFile.Delete();
                }
                using (FileStream stream = exportFile.OpenWrite())
                {
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.WriteLine(String.Format("Flag\tCount\tSize\tID"));
                        foreach (CMDBGData dbgData in dbgList)
                        {
                            writer.WriteLine(String.Format("{1:X1}\t{3:000}\t{4:000}\t{2:X8}", writer.NewLine, dbgData.Flags, dbgData.ID, dbgData.SimpleCount, dbgData.Size));
                        }
                    }
                }

                //Debugger.Break();
            }
        }