Ejemplo n.º 1
0
            protected int OnExecute(CommandLineApplication app)
            {
                var isMap = Path.GetExtension(InputFile).ToLowerInvariant() == ".map";

                if (isMap)
                {
                    foreach (var entry in File.OpenRead(InputFile).Using(Bar.Read)
                             .Where(entry => false ||
                                    entry.Type == Bar.EntryType.CollisionOctalTree ||
                                    entry.Type == Bar.EntryType.CameraOctalTree ||
                                    entry.Type == Bar.EntryType.ColorOctalTree ||
                                    entry.Type == Bar.EntryType.MapCollision2 ||
                                    entry.Type == Bar.EntryType.ModelCollision
                                    )
                             )
                    {
                        Console.WriteLine($"# {entry.Name}:{entry.Index} ({entry.Type})");
                        PrintSummary(Coct.Read(entry.Stream));
                        Console.WriteLine();
                    }
                }
                else
                {
                    PrintSummary(File.OpenRead(InputFile).Using(Coct.Read));
                }

                return(0);
            }
Ejemplo n.º 2
0
        public void ReadCollision() => File.OpenRead(FileName).Using(stream =>
        {
            var collision = new CoctLogical(Coct.Read(stream));

            Assert.Equal(188, collision.CollisionMeshGroupList.Count);
            Assert.Equal(7, collision.CollisionMeshGroupList[5].Child1);
            Assert.Equal(6, collision.CollisionMeshGroupList[5].Child2);
            Assert.Equal(6, collision.CollisionMeshGroupList[5].Child2);
            Assert.Equal(-4551, collision.CollisionMeshGroupList[5].MinX);

            Assert.Equal(1, collision.CollisionMeshGroupList[5].Meshes.Count);

            Assert.Equal(99, collision.CollisionMeshGroupList[6].Meshes[0].MinY);
            Assert.Equal(-3449, collision.CollisionMeshGroupList[6].Meshes[0].MaxX);
            Assert.Equal(1, collision.CollisionMeshGroupList[6].Meshes[0].Items.Count);

            Assert.Equal(24, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex1);
            Assert.Equal(25, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex2);
            Assert.Equal(14, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex3);
            Assert.Equal(18, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex4);
            Assert.Equal(6, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co5Index);
            Assert.Equal(4, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co6Index);
            Assert.Equal(2, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co7Index);

            Assert.Equal(549, collision.VertexList.Count);
            Assert.Equal(233, collision.PlaneList.Count);
            Assert.Equal(240, collision.BoundingBoxList.Count);
            Assert.Equal(9, collision.SurfaceFlagsList.Count);
        });
Ejemplo n.º 3
0
        public void WriteCollision() => File.OpenRead(FileName).Using(x =>
                                                                      Helpers.AssertStream(x, inStream =>
        {
            var outStream = new MemoryStream();
            Coct.Read(inStream).Write(outStream);

            return(outStream);
        }));
Ejemplo n.º 4
0
        public void TestLogicalReadWrite()
        {
            File.OpenRead(FileName).Using(
                inStream =>
            {
                var outStream   = new MemoryStream();
                var coct        = Coct.Read(inStream);
                var coctLogical = new CoctLogical(coct);
                var coctBack    = coctLogical.CreateCoct();
                coctBack.Write(outStream);

                outStream.Position = 0;

                {
                    var collision = new CoctLogical(Coct.Read(outStream));

                    Assert.Equal(188, collision.CollisionMeshGroupList.Count);
                    Assert.Equal(7, collision.CollisionMeshGroupList[5].Child1);
                    Assert.Equal(6, collision.CollisionMeshGroupList[5].Child2);
                    Assert.Equal(6, collision.CollisionMeshGroupList[5].Child2);
                    Assert.Equal(-4551, collision.CollisionMeshGroupList[5].MinX);

                    Assert.Equal(1, collision.CollisionMeshGroupList[5].Meshes.Count);

                    Assert.Equal(99, collision.CollisionMeshGroupList[6].Meshes[0].MinY);
                    Assert.Equal(-3449, collision.CollisionMeshGroupList[6].Meshes[0].MaxX);
                    Assert.Equal(1, collision.CollisionMeshGroupList[6].Meshes[0].Items.Count);

                    Assert.Equal(24, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex1);
                    Assert.Equal(25, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex2);
                    Assert.Equal(14, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex3);
                    Assert.Equal(18, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Vertex4);
                    Assert.Equal(6, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co5Index);
                    Assert.Equal(4, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co6Index);
                    Assert.Equal(2, collision.CollisionMeshGroupList[7].Meshes[0].Items[0].Co7Index);

                    Assert.Equal(549, collision.VertexList.Count);
                    Assert.Equal(233, collision.PlaneList.Count);
                    Assert.Equal(240, collision.BoundingBoxList.Count);
                    Assert.Equal(9, collision.SurfaceFlagsList.Count);
                }
            }
                );
        }
Ejemplo n.º 5
0
        public void TestMapGenUtil(string inputModel)
        {
            var outMap = Path.ChangeExtension(inputModel, ".map");

            using var disposer = new FileDisposer(outMap);

            new MapGenUtil().Run(inputModel, outMap);

            var barEntries = File.OpenRead(outMap).Using(Bar.Read);

            {
                var doct   = Doct.Read(barEntries.Single(it => it.Type == Bar.EntryType.DrawOctalTree).Stream);
                var writer = new StringWriter();
                new DumpDoctUtil(doct, writer);

                var doctDumpFile = Path.ChangeExtension(inputModel, ".doct.dump");

                Assert.Equal(
                    expected: File.ReadAllText(doctDumpFile),
                    actual: writer.ToString(),
                    ignoreLineEndingDifferences: true
                    );
            }

            {
                var coct   = Coct.Read(barEntries.Single(it => it.Type == Bar.EntryType.CollisionOctalTree).Stream);
                var writer = new StringWriter();
                new DumpCoctUtil(coct, writer);

                var coctDumpFile = Path.ChangeExtension(inputModel, ".coct.dump");

                Assert.Equal(
                    expected: File.ReadAllText(coctDumpFile),
                    actual: writer.ToString(),
                    ignoreLineEndingDifferences: true
                    );
            }
        }
Ejemplo n.º 6
0
        public void ReadCollision() => File.OpenRead(FileName).Using(stream =>
        {
            var collision = Coct.Read(stream);

            Assert.Equal(188, collision.Nodes.Count);
            Assert.Equal(7, collision.Nodes[5].Child1);
            Assert.Equal(6, collision.Nodes[5].Child2);
            Assert.Equal(6, collision.Nodes[5].Child2);
            Assert.Equal(-4551, collision.Nodes[5].BoundingBox.Minimum.X);

            Assert.Equal(1, collision.Nodes[5].Meshes.Count);

            Assert.Equal(99, collision.Nodes[6].Meshes[0].BoundingBox.Minimum.Y);
            Assert.Equal(-3449, collision.Nodes[6].Meshes[0].BoundingBox.Maximum.X);
            Assert.Equal(1, collision.Nodes[6].Meshes[0].Collisions.Count);

            Assert.Equal(24, collision.Nodes[7].Meshes[0].Collisions[0].Vertex1);
            Assert.Equal(25, collision.Nodes[7].Meshes[0].Collisions[0].Vertex2);
            Assert.Equal(14, collision.Nodes[7].Meshes[0].Collisions[0].Vertex3);
            Assert.Equal(18, collision.Nodes[7].Meshes[0].Collisions[0].Vertex4);

            Assert.Equal(549, collision.VertexList.Count);
        });