Exemplo n.º 1
0
            public void SetUp()
            {
                DataDirectory = TestContext.Parameters["dataDirectory"];
                FgdDirectory  = TestContext.Parameters["fgdDirectory"];

                string ericwFilename = Path.Combine(FgdDirectory, "quake4ericwTools.fgd");
                var    ericw         = new QuakeFgd(ericwFilename);

                string instanceFilename = Path.Combine(FgdDirectory, "func_instance.fgd");
                var    instance         = new QuakeFgd(instanceFilename);

                Fgd = new List <DefinitionDictionary>()
                {
                    ericw, instance
                }.Stack();

                string  paletteName = "palette-quake.lmp";
                Stream  stream      = Assembly.GetAssembly(typeof(MainForm)).GetResourceStream(paletteName);
                Palette palette     = new Palette().LoadQuakePalette(stream);

                string wadFilename = Path.Combine(DataDirectory, "test.wad");

                Textures = new Wad2(wadFilename, palette);
            }
Exemplo n.º 2
0
        public void SetUp()
        {
            var list = new List <string>()
            {
                "@baseclass = Appearflags [",
                "	spawnflags(Flags) =",
                "	[",
                "		256 : \"Not in Easy\" : 0 : \"Will not spawn for EASY skill\"",
                "		512 : \"Not in Normal\" : 0",
                "		1024 : \"Not in Hard\" : 0",
                "		2048 : \"Not in Deathmatch\" : 0 : \"Will not spawn for DEATHMATCH skill\"",
                "	]",
                "]",
                "",
                "@baseclass = Target [ target(target_destination) : \"Target\" ]",
                "",
                "@baseclass = Item",
                "[",
                "	message(string) : \"Message\"",
                "]",
                "",
                "@baseclass size(0 0 0, 32 32 32) color(80 0 200) base(Item, Appearflags, Target) = Ammo",
                "[",
                "	spawnflags(flags) = ",
                "	[",
                "		1 : \"Large box\" : 0",
                "	]",
                "]",
                "",
                "@SolidClass color(128 128 230)base(ModelLight) = func_detail : \"Detail brush. Ignored by vis so can speed up compile times consideratbly. Also allows you to set new compiler lighting options on brushes. DOES NOT SEAL MAPS FROM VOID\" []",
                "",
                "@baseclass = ModelLight",
                "[",
                "	_minlight(integer) : \"Min light\" :  : \"Set the minimum light level for any surface of the brush model. Default 0\"",
                "	_mincolor(color255) : \"Min light color R G B\" : \"255 255 255\" : \"Specify red(r), green(g) and blue(b) components for the colour of the minlight. RGB component values are between 0 and 255 (between 0 and 1 is also accepted). Default is white light (255 255 255)\"",
                "	_shadow(integer) : \"Shadows\" :  : \"If n is 1, this model will cast shadows on other models and itself (i.e. '_shadow' implies '_shadowself'). Note that this doesn’t magically give Quake dynamic lighting powers, so the shadows will not move if the model moves. Func_detail ONLY - If set to -1, light will pass through this brush model. Default 0\"",
                "	_shadowself(integer) : \"Self Shadow\" :  : \"If n is 1, this model will cast shadows on itself if one part of the model blocks the light from another model surface. This can be a better compromise for moving models than full shadowing. Default 0\"",
                "	_dirt(integer) : \"Dirt mapping (override)\" :  : \"For brush models, -1 prevents dirtmapping on the brush model. Useful it the bmodel touches or sticks into the world, and you want to those ares from turning black. Default 0\"",
                "	_phong(choices) : \"Enable Phong shading\" : 0 =",
                "	[",
                "		0: \"No\"",
                "		1: \"Yes\"",
                "	]",
                "	_phong_angle(integer) : \"Phong shading angle\" :  : \"Enables phong shading on faces of this model with a custom angle. Adjacent faces with normals this many degrees apart (or less) will be smoothed. Consider setting '_anglescale' to '1' on lights or worldspawn to make the effect of phong shading more visible. Use the '-phongdebug' command-line flag to save the interpolated normals to the lightmap for previewing (use 'r_lightmap 1' or 'gl_lightmaps 1' in your engine to preview.)\"",
                "]",
                "",
                "@BaseClass = FakeThingToTestChoices",
                "[",
                "	_phony(choices) : \"I am a banana\" = [",
                "		0: \"My\"",
                "		1 :\"spoon\"",
                "	]",
                "]",
                "",
                "@PointClass = ambient_custom_rain : \"Play a rain sound. Always starts off and must be triggered. NOTE - If you re-trigger(ex button) this entity off it will not restart henceforth.\"[",
                "	count(choices) : \"Type of Rain\" = [",
                "	   0 : \"Default\"",
                "",
                "	   1 : \"Fast Dripping\"",
                "",
                "	   2 : \"Dowmpour(def)\"",
                "	]",
                "	volume(choices) : \"Volume\" :  : \"Volume of sound  (0.1->1,(def=1).\" = [",
                "		0.1 : \"Barely Audible\"",
                "		0.2 : \"0.2\"",
                "		0.3 : \"0.3\"",
                "		0.4 : \"0.4\"",
                "		0.5 : \"0.5\"",
                "		0.6 : \"0.6\"",
                "		0.7 : \"0.7\"",
                "		0.8 : \"0.8\"",
                "		0.9 : \"0.9\"",
                "		1.0 : \"Full Volume(def)\"",
                "	]",
                "]",
                "",
                "@SolidClass = trigger_touchsound : \"Trigger Touch Sounds\"[",
                "	spawnflags(flags) = [",
                "		4 : \"World Geo\"",
                "		8 : \"Drain\"",
                "	]",
                "	message(choices) : \"Sounds\" = [",
                "		1 : \"Water (DEF)\"",
                "		2 : \"Slime\"",
                "		3 : \"Lava\"",
                "		4 : \"Silent\"",
                "		5 : \"Custom\"",
                "	]",
                "	noise(sound) : \"Custom Touch Sound\"",
                "	noise1(sound) : \"Custom Exit Sound\"",
                "	noise2(sound) : \"Custom Drain Sound\"",
                "	speed(integer) : \"Drain Time\"",
                "	yaw_speed(integer) : \"Drain Movement\"",
                "	super_time(integer) : \"Time delay playing drain sound\"",
                "	water_alpha(integer) : \"Liquid Alpha\"",
                "]"
            };

            var stream = new MemoryStream();
            var sw     = new StreamWriter(stream);

            sw.Write(String.Join("\n", list));
            sw.Flush();
            stream.Position = 0;

            Fgd = new QuakeFgd(stream);

            sw.Close();
        }
Exemplo n.º 3
0
            public void SuperfluousFace()
            {
                // In this case, the side with exit02_2 as its texture is an
                // invalid, extra side, which doesn't produce an actual polygon.
                var raw = new List <string>()
                {
                    "{",
                    "\"_phong\" \"1\"" +
                    "\"classname\" \"func_detail\"",
                    "{",
                    "( -2272 1104 832 ) ( -2256 1104 832 ) ( -2272 1024 832 ) ceiling5 0 32 0 1.000000 1.000000" +
                    "( -2272 1104 832 ) ( -2272 1040 832 ) ( -2264 1040 800 ) city2_5 0 32 0 1.000000 1.000000" +
                    "( -2240 1024 832 ) ( -2240 1104 832 ) ( -2240 1104 800 ) comp1_6 0 32 0 1.000000 1.000000" +
                    "( -2272 1040 832 ) ( -2256 1024 832 ) ( -2248 1024 800 ) cop1_1 8 32 0 0.700000 1.000000" +
                    "( -2256 1024 832 ) ( -2240 1024 832 ) ( -2240 1024 800 ) dr05_2 0 32 0 -1.000000 1.000000" +
                    "( -2264 1104 688 ) ( -2264 1080 688 ) ( -2208 1104 688 ) exit02_2 0 32 0 1.000000 1.000000" +
                    "( -2240 1104 832 ) ( -2272 1104 832 ) ( -2264 1104 800 ) floor01_5 0 32 0 1.000000 1.000000",
                    "}",
                    "}"
                };

                var rawFgd = new List <string>()
                {
                    "@SolidClass color(128 128 230)base(ModelLight) = func_detail : \"Detail brush. Ignored by vis so can speed up compile times consideratbly. Also allows you to set new compiler lighting options on brushes. DOES NOT SEAL MAPS FROM VOID\" []",
                    "",
                    "@baseclass = ModelLight",
                    "[",
                    "	_minlight(integer) : \"Min light\" :  : \"Set the minimum light level for any surface of the brush model. Default 0\"",
                    "	_mincolor(color255) : \"Min light color R G B\" : \"255 255 255\" : \"Specify red(r), green(g) and blue(b) components for the colour of the minlight. RGB component values are between 0 and 255 (between 0 and 1 is also accepted). Default is white light (255 255 255)\"",
                    "	_shadow(integer) : \"Shadows\" :  : \"If n is 1, this model will cast shadows on other models and itself (i.e. '_shadow' implies '_shadowself'). Note that this doesn’t magically give Quake dynamic lighting powers, so the shadows will not move if the model moves. Func_detail ONLY - If set to -1, light will pass through this brush model. Default 0\"",
                    "	_shadowself(integer) : \"Self Shadow\" :  : \"If n is 1, this model will cast shadows on itself if one part of the model blocks the light from another model surface. This can be a better compromise for moving models than full shadowing. Default 0\"",
                    "	_dirt(integer) : \"Dirt mapping (override)\" :  : \"For brush models, -1 prevents dirtmapping on the brush model. Useful it the bmodel touches or sticks into the world, and you want to those ares from turning black. Default 0\"",
                    "	_phong(choices) : \"Enable Phong shading\" : 0 =",
                    "	[",
                    "		0: \"No\"",
                    "		1: \"Yes\"",
                    "	]",
                    "	_phong_angle(integer) : \"Phong shading angle\" :  : \"Enables phong shading on faces of this model with a custom angle. Adjacent faces with normals this many degrees apart (or less) will be smoothed. Consider setting '_anglescale' to '1' on lights or worldspawn to make the effect of phong shading more visible. Use the '-phongdebug' command-line flag to save the interpolated normals to the lightmap for previewing (use 'r_lightmap 1' or 'gl_lightmaps 1' in your engine to preview.)\"",
                    "]"
                };

                var stream = new MemoryStream();
                var sw     = new StreamWriter(stream);

                foreach (var line in rawFgd)
                {
                    sw.WriteLine(line);
                }
                sw.Flush();
                stream.Position = 0;

                var fgd = new QuakeFgd(stream);

                // The assertions below are really just icing on the cake; the
                // important part is successfully instantiating a QuakeMapObject
                // without throwing any exceptions.
                var qmo = new QuakeMapObject(new QuakeBlock(raw, 0, fgd), fgd);

                Assert.That(qmo.KeyVals.Count, Is.EqualTo(2));

                Assert.That(qmo.Renderables[0].Vertices.Count, Is.EqualTo(24));

                var indexCount = 0;

                foreach (var polygon in qmo.Renderables[0].Polygons)
                {
                    indexCount += polygon.Indices.Count;
                }

                Assert.That(indexCount, Is.EqualTo(36));
            }