public static void LoadMsbRegionsDS1(string mapName)
        {
            var cylinder = new DbgPrimWireCylinder(
                location: Transform.Default,
                range: 1.0f,
                height: 1,
                numSegments: 12,
                color: Color.Cyan);

            var sphere = new DbgPrimWireSphere(Transform.Default, 1f, 12, 12, Color.Red);

            var point = new DbgPrimWireSphere(Transform.Default, 0.25f, 4, 4, Color.Lime);

            var box = new DbgPrimWireBox(Transform.Default, Vector3.One, Color.Yellow);

            var msb = DataFile.LoadFromFile <MSB>(InterrootLoader.GetInterrootPath($@"map\MapStudio\{mapName}.msb"));

            foreach (var msbBox in msb.Regions.Boxes)
            {
                var newBox = box.Instantiate(msbBox.Name, new Transform(msbBox.PosX, msbBox.PosY, msbBox.PosZ,
                                                                        MathHelper.ToRadians(msbBox.RotX), MathHelper.ToRadians(msbBox.RotY), MathHelper.ToRadians(msbBox.RotZ),
                                                                        msbBox.WidthX, msbBox.HeightY, msbBox.DepthZ));
                DBG.AddPrimitive(newBox);
            }

            foreach (var msbSphere in msb.Regions.Spheres)
            {
                var newSphere = sphere.Instantiate(msbSphere.Name, new Transform(msbSphere.PosX, msbSphere.PosY, msbSphere.PosZ,
                                                                                 MathHelper.ToRadians(msbSphere.RotX), MathHelper.ToRadians(msbSphere.RotY), MathHelper.ToRadians(msbSphere.RotZ),
                                                                                 msbSphere.Radius, msbSphere.Radius, msbSphere.Radius));
                DBG.AddPrimitive(newSphere);
            }

            foreach (var msbCylinder in msb.Regions.Cylinders)
            {
                var newCylinder = cylinder.Instantiate(msbCylinder.Name, new Transform(msbCylinder.PosX, msbCylinder.PosY, msbCylinder.PosZ,
                                                                                       MathHelper.ToRadians(msbCylinder.RotX), MathHelper.ToRadians(msbCylinder.RotY), MathHelper.ToRadians(msbCylinder.RotZ),
                                                                                       msbCylinder.Radius, msbCylinder.Height, msbCylinder.Radius));
                DBG.AddPrimitive(newCylinder);
            }

            foreach (var msbPoint in msb.Regions.Points)
            {
                var newPoint = point.Instantiate(msbPoint.Name, new Transform(msbPoint.PosX, msbPoint.PosY, msbPoint.PosZ,
                                                                              MathHelper.ToRadians(msbPoint.RotX), MathHelper.ToRadians(msbPoint.RotY), MathHelper.ToRadians(msbPoint.RotZ)));
            }
        }
Example #2
0
        public static void AddMapTexBXF4(int area, IProgress <double> prog)
        {
            var dir = InterrootLoader.GetInterrootPath($"map\\m{area:D2}");

            if (!Directory.Exists(dir))
            {
                return;
            }
            var mapTpfFileNames = Directory.GetFiles(dir, "*.tpfbhd");
            int fileIndex       = 0;

            foreach (var t in mapTpfFileNames)
            {
                BXF4 bxf = null;
                lock (_lock_IO)
                {
                    bxf = BXF4.Read(t, t.Substring(0, t.Length - 7) + ".tpfbdt");
                }

                for (int i = 0; i < bxf.Files.Count; i++)
                {
                    if (bxf.Files[i].Name.Contains(".tpf"))
                    {
                        var tpf = SoulsFormats.TPF.Read(bxf.Files[i].Bytes);

                        foreach (var tn in tpf.Textures)
                        {
                            AddFetch(tpf, tn.Name);
                        }

                        tpf = null;
                    }
                    GFX.ModelDrawer.RequestTextureLoad();
                    // Report each subfile as a tiny part of the bar
                    prog?.Report((1.0 * fileIndex / mapTpfFileNames.Length) + ((1.0 / mapTpfFileNames.Length) * ((i + 1.0) / bxf.Files.Count)));
                }
                bxf = null;

                fileIndex++;
                prog?.Report((1.0 * fileIndex / mapTpfFileNames.Length));
            }

            GFX.ModelDrawer.RequestTextureLoad();
        }
Example #3
0
        public static void AddMapTexBXF4DS2(string area, IProgress <double> prog)
        {
            var dir = InterrootLoader.GetInterrootPath($"model\\map\\");

            if (!Directory.Exists(dir))
            {
                return;
            }

            BXF4 bxf = null;

            lock (_lock_IO)
            {
                bxf = BXF4.Read(dir + "\\t" + area.Substring(1) + ".tpfbhd", dir + "\\t" + area.Substring(1) + ".tpfbdt");
            }

            for (int i = 0; i < bxf.Files.Count; i++)
            {
                if (bxf.Files[i].Name.Contains(".tpf"))
                {
                    var tpf = TPF.Read(bxf.Files[i].Bytes);

                    foreach (var tn in tpf.Textures)
                    {
                        AddFetch(tpf, tn.Name);
                    }

                    tpf = null;
                }
                GFX.ModelDrawer.RequestTextureLoad();
                // Report each subfile as a tiny part of the bar
                prog?.Report((i + 1.0) / bxf.Files.Count);
            }
            bxf = null;

            //fileIndex++;
            //prog?.Report((1.0 * fileIndex / mapTpfFileNames.Length));

            GFX.ModelDrawer.RequestTextureLoad();
        }
Example #4
0
        static void TestMCP_MGC(string mapName)
        {
            if (InterrootLoader.Type != InterrootLoader.InterrootType.InterrootDS1)
            {
                return;
            }

            //GFX.ModelDrawer.AddMap(mapName, false);

            var box = new DbgPrimWireBox(Transform.Default, Vector3.One, Color.Red);
            var mcp = DataFile.LoadFromFile <MCP>(InterrootLoader.GetInterrootPath($@"map\{mapName}\{mapName}.mcp"));
            int bi  = 0;

            foreach (var mcpBox in mcp.Boxes)
            {
                var min    = new Vector3(mcpBox.MinX, mcpBox.MinY, mcpBox.MinZ);
                var max    = new Vector3(mcpBox.MaxX, mcpBox.MaxY, mcpBox.MaxZ);
                var size   = max - min;
                var center = min + (size / 2f);
                DBG.AddPrimitive(box.Instantiate($"Box [{(bi++)}]", new Transform(center.X, center.Y, center.Z, 0, 0, 0, size.X, size.Y, size.Z)));
            }
            var            sphere      = new DbgPrimWireSphere(Transform.Default, 0.35f, 32, 32, Color.Cyan);
            var            mcg         = DataFile.LoadFromFile <MCG>(InterrootLoader.GetInterrootPath($@"map\{mapName}\{mapName}.mcg"));
            var            lines       = new DbgPrimWire();
            List <Vector3> startPoints = new List <Vector3>();
            List <Vector3> endPoints   = new List <Vector3>();

            for (int i = 0; i < mcg.Paths.Count; i++)
            {
                var pointsThatReferenceThisShit = mcg.Points.Where(x => x.NearbyPathIndices.Contains(i)).ToList();
                startPoints.Add(new Vector3(pointsThatReferenceThisShit[0].PosX, pointsThatReferenceThisShit[0].PosY, pointsThatReferenceThisShit[0].PosZ));
                endPoints.Add(new Vector3(pointsThatReferenceThisShit[1].PosX, pointsThatReferenceThisShit[1].PosY, pointsThatReferenceThisShit[1].PosZ));
            }
            void AddPath(int pathIndex, Color col) =>
            lines.AddLine(startPoints[pathIndex], endPoints[pathIndex], col);

            void AddPathString(int pathIndex, string str, Color col)
            {
                var position = (startPoints[pathIndex] + endPoints[pathIndex]) / 2.0f;

                lines.AddDbgLabel(position, 5f, str, col);
            }

            //for (int i = 0; i < mcg.Paths.Count; i++)
            //{
            //    AddPath(i, Color.Cyan);
            //    AddPathString(i, mcg.Paths[i].GetDebugReport(), Color.Cyan);

            //    //foreach (var edgeIndex in mcg.Edges[i].OtherEdgeIndicesA)
            //    //{
            //    //    AddEdge(edgeIndex, Color.Cyan);
            //    //}

            //    //foreach (var edgeIndex in mcg.Edges[i].OtherEdgeIndicesB)
            //    //{
            //    //    AddEdge(edgeIndex, Color.Yellow);
            //    //}

            //    //break;
            //}

            float getPathLength(int pathIndex)
            {
                var start = startPoints[pathIndex];
                var end   = endPoints[pathIndex];

                return((start - end).Length());
            }

            void addPointDbg(int pointIndex)
            {
                DBG.AddPrimitive(sphere.Instantiate($"Point [{pointIndex}]", new Transform(new Vector3(mcg.Points[pointIndex].PosX, mcg.Points[pointIndex].PosY, mcg.Points[pointIndex].PosZ), Vector3.Zero)));

                int pidx = 0;

                foreach (var adjPointIndex in mcg.Points[pointIndex].NearbyPointIndices)
                {
                    DBG.AddPrimitive(sphere.Instantiate($"INDEX IN POINT'S LIST:{pidx++}, Point Near [{adjPointIndex}]", new Transform(new Vector3(mcg.Points[adjPointIndex].PosX, mcg.Points[adjPointIndex].PosY, mcg.Points[adjPointIndex].PosZ), Vector3.Zero)));
                }

                pidx = 0;
                foreach (var path in mcg.Points[pointIndex].NearbyPathIndices)
                {
                    AddPath(path, Color.Cyan);
                    AddPathString(path, $"PATH INDEX IN POINT'S LIST:{pidx++}\n{mcg.Paths[path].GetDebugReport()}\nPATH LENGTH: {getPathLength(path)}", Color.Cyan);
                }
            }

            //addPointDbg(0);
            //addPointDbg(1);
            //addPointDbg(2);

            for (int i = 0; i < mcg.Points.Count; i++)
            {
                addPointDbg(i);
            }

            DBG.AddPrimitive(lines);

            Console.WriteLine("TEST");
        }
Example #5
0
        public static void AddAllExternalDS1TexturesInBackground()
        {
            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_UDSFM_MAP", $"Loading external map textures for DS1...", prog =>
            {
                //UDSFM MAP TEX
                var dir = InterrootLoader.GetInterrootPath(@"map\tx");
                if (Directory.Exists(dir))
                {
                    var mapTpfFileNames = Directory.GetFiles(dir);
                    int i = 0;
                    foreach (var t in mapTpfFileNames)
                    {
                        AddTpfFromPath(t);
                        prog?.Report(1.0 * (++i) / mapTpfFileNames.Length);
                    }
                }
                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_UDSFM_CHR", $"Loading external boss character textures for DS1...", prog =>
            {
                // UDSFM CHR TEX
                var udsfmTexFolderPath = InterrootLoader.GetInterrootPath($@"chr");
                if (Directory.Exists(udsfmTexFolderPath))
                {
                    var subDirectories = Directory.GetDirectories(udsfmTexFolderPath);
                    int i = 0;
                    foreach (var subDir in subDirectories)
                    {
                        var chrTpfFileNames = Directory.GetFiles(subDir, "*.tpf");
                        foreach (var t in chrTpfFileNames)
                        {
                            AddTpfFromPath(t);
                        }
                        prog?.Report(1.0 * (++i) / subDirectories.Length);
                    }
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_CHRBND_9", $"Loading external character textures for DS1...", prog =>
            {
                // CHRBND-9
                var chrbndsThatEndWith9 = Directory.GetFiles(InterrootLoader.GetInterrootPath(@"chr"), "*9.chrbnd");
                foreach (var ctew9 in chrbndsThatEndWith9)
                {
                    BND entityBnd = null;
                    lock (_lock_IO)
                    {
                        entityBnd = DataFile.LoadFromFile <BND>(ctew9);
                    }
                    AddTextureBnd(entityBnd, prog);
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });

            LoadingTaskMan.DoLoadingTask($"AddAllExternalDS1TexturesInBackground_OBJBND_9", $"Loading external object textures for DS1...", prog =>
            {
                // CHRBND-9
                var chrbndsThatEndWith9 = Directory.GetFiles(InterrootLoader.GetInterrootPath(@"obj"), "*9.objbnd");
                foreach (var ctew9 in chrbndsThatEndWith9)
                {
                    BND entityBnd = null;
                    lock (_lock_IO)
                    {
                        entityBnd = DataFile.LoadFromFile <BND>(ctew9);
                    }
                    AddTextureBnd(entityBnd, prog);
                }

                GFX.ModelDrawer.RequestTextureLoad();
            });
        }