Ejemplo n.º 1
0
        public void LoadE1M1()
        {
            using (var wad = new Wad(WadPath.Doom1))
            {
                var flats      = new FlatLookup(wad, true);
                var textures   = new TextureLookup(wad, true);
                var map        = wad.GetLumpNumber("E1M1");
                var vertices   = Vertex.FromWad(wad, map + 4);
                var sectors    = Sector.FromWad(wad, map + 8, flats);
                var sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs       = Seg.FromWad(wad, map + 5, vertices, lines);
                var subsectors = Subsector.FromWad(wad, map + 6, segs);

                Assert.AreEqual(239, subsectors.Length);

                Assert.AreEqual(8, subsectors[0].SegCount);
                for (var i = 0; i < 8; i++)
                {
                    Assert.IsTrue(segs[subsectors[0].FirstSeg + i] == segs[0 + i]);
                }

                Assert.AreEqual(1, subsectors[54].SegCount);
                for (var i = 0; i < 1; i++)
                {
                    Assert.IsTrue(segs[subsectors[54].FirstSeg + i] == segs[181 + i]);
                }

                Assert.AreEqual(2, subsectors[238].SegCount);
                for (var i = 0; i < 2; i++)
                {
                    Assert.IsTrue(segs[subsectors[238].FirstSeg + i] == segs[745 + i]);
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats      = new FlatLookup(wad, true);
                var textures   = new TextureLookup(wad, true);
                var map        = wad.GetLumpNumber("MAP01");
                var vertices   = Vertex.FromWad(wad, map + 4);
                var sectors    = Sector.FromWad(wad, map + 8, flats);
                var sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs       = Seg.FromWad(wad, map + 5, vertices, lines);
                var subsectors = Subsector.FromWad(wad, map + 6, segs);

                Assert.AreEqual(194, subsectors.Length);

                Assert.AreEqual(4, subsectors[0].SegCount);
                for (var i = 0; i < 4; i++)
                {
                    Assert.IsTrue(segs[subsectors[0].FirstSeg + i] == segs[i]);
                }

                Assert.AreEqual(4, subsectors[57].SegCount);
                for (var i = 0; i < 4; i++)
                {
                    Assert.IsTrue(segs[subsectors[57].FirstSeg + i] == segs[179 + i]);
                }

                Assert.AreEqual(4, subsectors[193].SegCount);
                for (var i = 0; i < 4; i++)
                {
                    Assert.IsTrue(segs[subsectors[193].FirstSeg + i] == segs[597 + i]);
                }
            }
        }
Ejemplo n.º 3
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats    = new DummyFlatLookup(wad);
                var textures = new DummyTextureLookup(wad);
                var map      = wad.GetLumpNumber("MAP01");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs     = Seg.FromWad(wad, map + 5, vertices, lines);

                Assert.AreEqual(601, segs.Length);

                Assert.IsTrue(segs[0].Vertex1 == vertices[9]);
                Assert.IsTrue(segs[0].Vertex2 == vertices[316]);
                Assert.AreEqual(ToRadian(-32768), segs[0].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[0].LineDef == lines[8]);
                Assert.IsTrue((segs[0].LineDef.Flags & LineFlags.TwoSided) != 0);
                Assert.IsTrue(segs[0].FrontSector == segs[0].LineDef.FrontSide.Sector);
                Assert.IsTrue(segs[0].BackSector == segs[0].LineDef.BackSide.Sector);
                Assert.AreEqual(0, segs[0].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[42].Vertex1 == vertices[26]);
                Assert.IsTrue(segs[42].Vertex2 == vertices[320]);
                Assert.AreEqual(ToRadian(-22209), segs[42].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[42].LineDef == lines[33]);
                Assert.IsTrue((segs[42].LineDef.Flags & LineFlags.TwoSided) != 0);
                Assert.IsTrue(segs[42].FrontSector == segs[42].LineDef.BackSide.Sector);
                Assert.IsTrue(segs[42].BackSector == segs[42].LineDef.FrontSide.Sector);
                Assert.AreEqual(0, segs[42].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[103].Vertex1 == vertices[331]);
                Assert.IsTrue(segs[103].Vertex2 == vertices[329]);
                Assert.AreEqual(ToRadian(16384), segs[103].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[103].LineDef == lines[347]);
                Assert.IsTrue((segs[103].LineDef.Flags & LineFlags.TwoSided) == 0);
                Assert.IsTrue(segs[103].FrontSector == segs[103].LineDef.FrontSide.Sector);
                Assert.IsTrue(segs[103].BackSector == null);
                Assert.AreEqual(64, segs[103].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[600].Vertex1 == vertices[231]);
                Assert.IsTrue(segs[600].Vertex2 == vertices[237]);
                Assert.AreEqual(ToRadian(-16384), segs[600].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[600].LineDef == lines[271]);
                Assert.IsTrue((segs[600].LineDef.Flags & LineFlags.TwoSided) != 0);
                Assert.IsTrue(segs[600].FrontSector == segs[600].LineDef.BackSide.Sector);
                Assert.IsTrue(segs[600].BackSector == segs[600].LineDef.FrontSide.Sector);
                Assert.AreEqual(0, segs[600].Offset.ToDouble(), delta);
            }
        }
Ejemplo n.º 4
0
        public void LoadE1M1()
        {
            using (var wad = new Wad(WadPath.Doom1))
            {
                var flats    = new DummyFlatLookup(wad);
                var textures = new DummyTextureLookup(wad);
                var map      = wad.GetLumpNumber("E1M1");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs     = Seg.FromWad(wad, map + 5, vertices, lines);

                Assert.AreEqual(747, segs.Length);

                Assert.IsTrue(segs[0].Vertex1 == vertices[132]);
                Assert.IsTrue(segs[0].Vertex2 == vertices[133]);
                Assert.AreEqual(ToRadian(4156), segs[0].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[0].LineDef == lines[160]);
                Assert.IsTrue((segs[0].LineDef.Flags & LineFlags.TwoSided) != 0);
                Assert.IsTrue(segs[0].FrontSector == segs[0].LineDef.FrontSide.Sector);
                Assert.IsTrue(segs[0].BackSector == segs[0].LineDef.BackSide.Sector);
                Assert.AreEqual(0, segs[0].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[28].Vertex1 == vertices[390]);
                Assert.IsTrue(segs[28].Vertex2 == vertices[131]);
                Assert.AreEqual(ToRadian(-32768), segs[28].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[28].LineDef == lines[480]);
                Assert.IsTrue((segs[0].LineDef.Flags & LineFlags.TwoSided) != 0);
                Assert.IsTrue(segs[28].FrontSector == segs[28].LineDef.BackSide.Sector);
                Assert.IsTrue(segs[28].BackSector == segs[28].LineDef.FrontSide.Sector);
                Assert.AreEqual(0, segs[28].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[744].Vertex1 == vertices[446]);
                Assert.IsTrue(segs[744].Vertex2 == vertices[374]);
                Assert.AreEqual(ToRadian(-16384), segs[744].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[744].LineDef == lines[452]);
                Assert.IsTrue((segs[744].LineDef.Flags & LineFlags.TwoSided) == 0);
                Assert.IsTrue(segs[744].FrontSector == segs[744].LineDef.FrontSide.Sector);
                Assert.IsTrue(segs[744].BackSector == null);
                Assert.AreEqual(154, segs[744].Offset.ToDouble(), delta);

                Assert.IsTrue(segs[746].Vertex1 == vertices[374]);
                Assert.IsTrue(segs[746].Vertex2 == vertices[368]);
                Assert.AreEqual(ToRadian(-13828), segs[746].Angle.ToRadian(), delta);
                Assert.IsTrue(segs[746].LineDef == lines[451]);
                Assert.IsTrue((segs[746].LineDef.Flags & LineFlags.TwoSided) == 0);
                Assert.IsTrue(segs[746].FrontSector == segs[746].LineDef.FrontSide.Sector);
                Assert.IsTrue(segs[746].BackSector == null);
                Assert.AreEqual(0, segs[746].Offset.ToDouble(), delta);
            }
        }
Ejemplo n.º 5
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats    = new DummyFlatLookup(wad);
                var textures = new DummyTextureLookup(wad);
                var map      = wad.GetLumpNumber("MAP01");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);

                Assert.AreEqual(370, lines.Length);

                Assert.IsTrue(lines[0].Vertex1 == vertices[0]);
                Assert.IsTrue(lines[0].Vertex2 == vertices[1]);
                Assert.IsTrue((int)lines[0].Flags == 1);
                Assert.IsTrue((int)lines[0].Special == 0);
                Assert.IsTrue(lines[0].Tag == 0);
                Assert.IsTrue(lines[0].FrontSide == sides[0]);
                Assert.IsTrue(lines[0].BackSide == null);
                Assert.IsTrue(lines[0].FrontSector == sides[0].Sector);
                Assert.IsTrue(lines[0].BackSector == null);

                Assert.IsTrue(lines[75].Vertex1 == vertices[73]);
                Assert.IsTrue(lines[75].Vertex2 == vertices[74]);
                Assert.IsTrue((int)lines[75].Flags == 4);
                Assert.IsTrue((int)lines[75].Special == 103);
                Assert.IsTrue(lines[75].Tag == 4);
                Assert.IsTrue(lines[75].FrontSide == sides[97]);
                Assert.IsTrue(lines[75].BackSide == sides[98]);
                Assert.IsTrue(lines[75].FrontSector == sides[97].Sector);
                Assert.IsTrue(lines[75].BackSector == sides[98].Sector);

                Assert.IsTrue(lines[369].Vertex1 == vertices[293]);
                Assert.IsTrue(lines[369].Vertex2 == vertices[299]);
                Assert.IsTrue((int)lines[369].Flags == 21);
                Assert.IsTrue((int)lines[369].Special == 0);
                Assert.IsTrue(lines[369].Tag == 0);
                Assert.IsTrue(lines[369].FrontSide == sides[527]);
                Assert.IsTrue(lines[369].BackSide == sides[528]);
                Assert.IsTrue(lines[369].FrontSector == sides[527].Sector);
                Assert.IsTrue(lines[369].BackSector == sides[528].Sector);
            }
        }
Ejemplo n.º 6
0
        public void LoadE1M1()
        {
            using (var wad = new Wad(WadPath.Doom1))
            {
                var flats    = new DummyFlatLookup(wad);
                var textures = new DummyTextureLookup(wad);
                var map      = wad.GetLumpNumber("E1M1");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);

                Assert.AreEqual(486, lines.Length);

                Assert.IsTrue(lines[0].Vertex1 == vertices[0]);
                Assert.IsTrue(lines[0].Vertex2 == vertices[1]);
                Assert.IsTrue((int)lines[0].Flags == 1);
                Assert.IsTrue((int)lines[0].Special == 0);
                Assert.IsTrue(lines[0].Tag == 0);
                Assert.IsTrue(lines[0].FrontSide == sides[0]);
                Assert.IsTrue(lines[0].BackSide == null);
                Assert.IsTrue(lines[0].FrontSector == sides[0].Sector);
                Assert.IsTrue(lines[0].BackSector == null);

                Assert.IsTrue(lines[136].Vertex1 == vertices[110]);
                Assert.IsTrue(lines[136].Vertex2 == vertices[111]);
                Assert.IsTrue((int)lines[136].Flags == 28);
                Assert.IsTrue((int)lines[136].Special == 63);
                Assert.IsTrue(lines[136].Tag == 3);
                Assert.IsTrue(lines[136].FrontSide == sides[184]);
                Assert.IsTrue(lines[136].BackSide == sides[185]);
                Assert.IsTrue(lines[136].FrontSector == sides[184].Sector);
                Assert.IsTrue(lines[136].BackSector == sides[185].Sector);

                Assert.IsTrue(lines[485].Vertex1 == vertices[309]);
                Assert.IsTrue(lines[485].Vertex2 == vertices[294]);
                Assert.IsTrue((int)lines[485].Flags == 12);
                Assert.IsTrue((int)lines[485].Special == 0);
                Assert.IsTrue(lines[485].Tag == 0);
                Assert.IsTrue(lines[485].FrontSide == sides[664]);
                Assert.IsTrue(lines[485].BackSide == sides[665]);
                Assert.IsTrue(lines[485].FrontSector == sides[664].Sector);
                Assert.IsTrue(lines[485].BackSector == sides[665].Sector);
            }
        }
Ejemplo n.º 7
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats    = new FlatLookup(wad, true);
                var textures = new TextureLookup(wad, false);
                var map      = wad.GetLumpNumber("MAP01");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);

                Assert.AreEqual(529, sides.Length);

                Assert.AreEqual(0, sides[0].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[0].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[0].TopTexture);
                Assert.AreEqual(0, sides[0].BottomTexture);
                Assert.AreEqual("BRONZE1", textures[sides[0].MiddleTexture].Name);
                Assert.IsTrue(sides[0].Sector == sectors[9]);

                Assert.AreEqual(0, sides[312].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[312].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[312].TopTexture);
                Assert.AreEqual(0, sides[312].BottomTexture);
                Assert.AreEqual("DOORTRAK", textures[sides[312].MiddleTexture].Name);
                Assert.IsTrue(sides[312].Sector == sectors[31]);

                Assert.AreEqual(24, sides[512].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[512].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[512].TopTexture);
                Assert.AreEqual(0, sides[512].BottomTexture);
                Assert.AreEqual("SUPPORT2", textures[sides[512].MiddleTexture].Name);
                Assert.IsTrue(sides[512].Sector == sectors[52]);

                Assert.AreEqual(0, sides[528].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[528].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[528].TopTexture);
                Assert.AreEqual(0, sides[528].BottomTexture);
                Assert.AreEqual(0, sides[528].MiddleTexture);
                Assert.IsTrue(sides[528].Sector == sectors[11]);
            }
        }
Ejemplo n.º 8
0
        public void LoadE1M1()
        {
            using (var wad = new Wad(WadPath.Doom1))
            {
                var flats    = new FlatLookup(wad, true);
                var textures = new TextureLookup(wad, false);
                var map      = wad.GetLumpNumber("E1M1");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);

                Assert.AreEqual(666, sides.Length);

                Assert.AreEqual(0, sides[0].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[0].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[0].TopTexture);
                Assert.AreEqual(0, sides[0].BottomTexture);
                Assert.AreEqual("DOOR3", textures[sides[0].MiddleTexture].Name);
                Assert.IsTrue(sides[0].Sector == sectors[30]);

                Assert.AreEqual(32, sides[480].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[480].RowOffset.ToDouble(), delta);
                Assert.AreEqual("EXITSIGN", textures[sides[480].TopTexture].Name);
                Assert.AreEqual(0, sides[480].BottomTexture);
                Assert.AreEqual(0, sides[480].MiddleTexture);
                Assert.IsTrue(sides[480].Sector == sectors[70]);

                Assert.AreEqual(0, sides[650].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(88, sides[650].RowOffset.ToDouble(), delta);
                Assert.AreEqual("STARTAN3", textures[sides[650].TopTexture].Name);
                Assert.AreEqual("STARTAN3", textures[sides[650].BottomTexture].Name);
                Assert.AreEqual(0, sides[650].MiddleTexture);
                Assert.IsTrue(sides[650].Sector == sectors[1]);

                Assert.AreEqual(0, sides[665].TextureOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[665].RowOffset.ToDouble(), delta);
                Assert.AreEqual(0, sides[665].TopTexture);
                Assert.AreEqual(0, sides[665].BottomTexture);
                Assert.AreEqual(0, sides[665].MiddleTexture);
                Assert.IsTrue(sides[665].Sector == sectors[23]);
            }
        }
Ejemplo n.º 9
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats    = new FlatLookup(wad, true);
                var textures = new TextureLookup(wad, true);
                var map      = wad.GetLumpNumber("MAP01");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);
                var reject   = Reject.FromWad(wad, map + 9, sectors);

                foreach (var sector in sectors)
                {
                    Assert.IsFalse(reject.Check(sector, sector));
                }

                foreach (var line in lines)
                {
                    if (line.BackSector != null)
                    {
                        Assert.IsFalse(reject.Check(line.FrontSector, line.BackSector));
                    }
                }

                foreach (var s1 in sectors)
                {
                    foreach (var s2 in sectors)
                    {
                        var result1 = reject.Check(s1, s2);
                        var result2 = reject.Check(s2, s1);
                        Assert.AreEqual(result1, result2);
                    }
                }

                Assert.IsTrue(reject.Check(sectors[10], sectors[49]));
                Assert.IsTrue(reject.Check(sectors[7], sectors[36]));
                Assert.IsTrue(reject.Check(sectors[17], sectors[57]));
            }
        }
Ejemplo n.º 10
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats      = new FlatLookup(wad, true);
                var textures   = new TextureLookup(wad, true);
                var map        = wad.GetLumpNumber("MAP01");
                var vertices   = Vertex.FromWad(wad, map + 4);
                var sectors    = Sector.FromWad(wad, map + 8, flats);
                var sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs       = Seg.FromWad(wad, map + 5, vertices, lines);
                var subsectors = Subsector.FromWad(wad, map + 6, segs);
                var nodes      = Node.FromWad(wad, map + 7, subsectors);

                Assert.AreEqual(193, nodes.Length);

                Assert.AreEqual(64, nodes[0].X.ToDouble(), delta);
                Assert.AreEqual(1024, nodes[0].Y.ToDouble(), delta);
                Assert.AreEqual(0, nodes[0].Dx.ToDouble(), delta);
                Assert.AreEqual(-64, nodes[0].Dy.ToDouble(), delta);
                Assert.AreEqual(1173, nodes[0].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(960, nodes[0].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(-64, nodes[0].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(64, nodes[0].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(1280, nodes[0].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(1024, nodes[0].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(64, nodes[0].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(128, nodes[0].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(32770, nodes[0].Children[0] + 0x10000);
                Assert.AreEqual(32771, nodes[0].Children[1] + 0x10000);

                Assert.AreEqual(640, nodes[57].X.ToDouble(), delta);
                Assert.AreEqual(856, nodes[57].Y.ToDouble(), delta);
                Assert.AreEqual(-88, nodes[57].Dx.ToDouble(), delta);
                Assert.AreEqual(-16, nodes[57].Dy.ToDouble(), delta);
                Assert.AreEqual(856, nodes[57].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(840, nodes[57].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(552, nodes[57].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(640, nodes[57].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(856, nodes[57].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(760, nodes[57].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(536, nodes[57].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(704, nodes[57].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(32829, nodes[57].Children[0] + 0x10000);
                Assert.AreEqual(56, nodes[57].Children[1]);

                Assert.AreEqual(96, nodes[192].X.ToDouble(), delta);
                Assert.AreEqual(1280, nodes[192].Y.ToDouble(), delta);
                Assert.AreEqual(32, nodes[192].Dx.ToDouble(), delta);
                Assert.AreEqual(0, nodes[192].Dy.ToDouble(), delta);
                Assert.AreEqual(1280, nodes[192].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-960, nodes[192].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(-1304, nodes[192].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(2072, nodes[192].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(2688, nodes[192].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(1280, nodes[192].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(-1304, nodes[192].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(2072, nodes[192].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(147, nodes[192].Children[0]);
                Assert.AreEqual(191, nodes[192].Children[1]);
            }
        }
Ejemplo n.º 11
0
        public void LoadE1M1()
        {
            using (var wad = new Wad(WadPath.Doom1))
            {
                var flats      = new FlatLookup(wad, true);
                var textures   = new TextureLookup(wad, true);
                var map        = wad.GetLumpNumber("E1M1");
                var vertices   = Vertex.FromWad(wad, map + 4);
                var sectors    = Sector.FromWad(wad, map + 8, flats);
                var sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
                var segs       = Seg.FromWad(wad, map + 5, vertices, lines);
                var subsectors = Subsector.FromWad(wad, map + 6, segs);
                var nodes      = Node.FromWad(wad, map + 7, subsectors);

                Assert.AreEqual(238, nodes.Length);

                Assert.AreEqual(1784, nodes[0].X.ToDouble(), delta);
                Assert.AreEqual(-3448, nodes[0].Y.ToDouble(), delta);
                Assert.AreEqual(-240, nodes[0].Dx.ToDouble(), delta);
                Assert.AreEqual(64, nodes[0].Dy.ToDouble(), delta);
                Assert.AreEqual(-3104, nodes[0].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-3448, nodes[0].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(1520, nodes[0].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(2128, nodes[0].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(-3384, nodes[0].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-3448, nodes[0].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(1544, nodes[0].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(1784, nodes[0].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(32768, nodes[0].Children[0] + 0x10000);
                Assert.AreEqual(32769, nodes[0].Children[1] + 0x10000);

                Assert.AreEqual(928, nodes[57].X.ToDouble(), delta);
                Assert.AreEqual(-3360, nodes[57].Y.ToDouble(), delta);
                Assert.AreEqual(0, nodes[57].Dx.ToDouble(), delta);
                Assert.AreEqual(256, nodes[57].Dy.ToDouble(), delta);
                Assert.AreEqual(-3104, nodes[57].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-3360, nodes[57].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(928, nodes[57].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(1344, nodes[57].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(-3104, nodes[57].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-3360, nodes[57].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(704, nodes[57].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(928, nodes[57].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(32825, nodes[57].Children[0] + 0x10000);
                Assert.AreEqual(56, nodes[57].Children[1]);

                Assert.AreEqual(2176, nodes[237].X.ToDouble(), delta);
                Assert.AreEqual(-2304, nodes[237].Y.ToDouble(), delta);
                Assert.AreEqual(0, nodes[237].Dx.ToDouble(), delta);
                Assert.AreEqual(-256, nodes[237].Dy.ToDouble(), delta);
                Assert.AreEqual(-2048, nodes[237].Bbox[0][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-4064, nodes[237].Bbox[0][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(-768, nodes[237].Bbox[0][Box.Left].ToDouble(), delta);
                Assert.AreEqual(2176, nodes[237].Bbox[0][Box.Right].ToDouble(), delta);
                Assert.AreEqual(-2048, nodes[237].Bbox[1][Box.Top].ToDouble(), delta);
                Assert.AreEqual(-4864, nodes[237].Bbox[1][Box.Bottom].ToDouble(), delta);
                Assert.AreEqual(2176, nodes[237].Bbox[1][Box.Left].ToDouble(), delta);
                Assert.AreEqual(3808, nodes[237].Bbox[1][Box.Right].ToDouble(), delta);
                Assert.AreEqual(131, nodes[237].Children[0]);
                Assert.AreEqual(236, nodes[237].Children[1]);
            }
        }
Ejemplo n.º 12
0
        public void LoadMap01()
        {
            using (var wad = new Wad(WadPath.Doom2))
            {
                var flats    = new FlatLookup(wad, true);
                var textures = new TextureLookup(wad, true);
                var map      = wad.GetLumpNumber("MAP01");
                var vertices = Vertex.FromWad(wad, map + 4);
                var sectors  = Sector.FromWad(wad, map + 8, flats);
                var sides    = SideDef.FromWad(wad, map + 3, textures, sectors);
                var lines    = LineDef.FromWad(wad, map + 2, vertices, sides);
                var blockMap = BlockMap.FromWad(wad, map + 10, lines);

                {
                    var minX = vertices.Select(v => v.X.ToDouble()).Min();
                    var maxX = vertices.Select(v => v.X.ToDouble()).Max();
                    var minY = vertices.Select(v => v.Y.ToDouble()).Min();
                    var maxY = vertices.Select(v => v.Y.ToDouble()).Max();

                    Assert.AreEqual(blockMap.OriginX.ToDouble(), minX, 64);
                    Assert.AreEqual(blockMap.OriginY.ToDouble(), minY, 64);
                    Assert.AreEqual((blockMap.OriginX + BlockMap.MapBlockSize * blockMap.Width).ToDouble(), maxX, 128);
                    Assert.AreEqual((blockMap.OriginY + BlockMap.MapBlockSize * blockMap.Height).ToDouble(), maxY, 128);
                }

                var spots = new List <Tuple <int, int> >();
                for (var blockY = -2; blockY < blockMap.Height + 2; blockY++)
                {
                    for (var blockX = -2; blockX < blockMap.Width + 2; blockX++)
                    {
                        spots.Add(Tuple.Create(blockX, blockY));
                    }
                }

                var random = new Random(666);

                for (var i = 0; i < 50; i++)
                {
                    var ordered = spots.OrderBy(spot => random.NextDouble()).ToArray();

                    var total = 0;

                    foreach (var spot in ordered)
                    {
                        var blockX = spot.Item1;
                        var blockY = spot.Item2;

                        var minX  = double.MaxValue;
                        var maxX  = double.MinValue;
                        var minY  = double.MaxValue;
                        var maxY  = double.MinValue;
                        var count = 0;

                        blockMap.IterateLines(
                            blockX,
                            blockY,
                            line =>
                        {
                            if (count != 0)
                            {
                                minX = Math.Min(Math.Min(line.Vertex1.X.ToDouble(), line.Vertex2.X.ToDouble()), minX);
                                maxX = Math.Max(Math.Max(line.Vertex1.X.ToDouble(), line.Vertex2.X.ToDouble()), maxX);
                                minY = Math.Min(Math.Min(line.Vertex1.Y.ToDouble(), line.Vertex2.Y.ToDouble()), minY);
                                maxY = Math.Max(Math.Max(line.Vertex1.Y.ToDouble(), line.Vertex2.Y.ToDouble()), maxY);
                            }
                            count++;
                            return(true);
                        },
                            i + 1);

                        if (count > 1)
                        {
                            Assert.IsTrue(minX <= (blockMap.OriginX + BlockMap.MapBlockSize * (blockX + 1)).ToDouble());
                            Assert.IsTrue(maxX >= (blockMap.OriginX + BlockMap.MapBlockSize * blockX).ToDouble());
                            Assert.IsTrue(minY <= (blockMap.OriginY + BlockMap.MapBlockSize * (blockY + 1)).ToDouble());
                            Assert.IsTrue(maxY >= (blockMap.OriginY + BlockMap.MapBlockSize * blockY).ToDouble());
                        }

                        total += count;
                    }

                    Assert.AreEqual(lines.Length, total);
                }
            }
        }