Esempio n. 1
0
 public void AssetManager_Arguments_CaseInsensitive_Test()
 {
     var args = new AssetLoadArguments();
     args.Add("intKey", 5);
     Assert.AreEqual(5, args.GetValue<int>("intKey", 0));
     Assert.AreEqual(5, args.GetValue<int>("INTKEY", 0));
 }
Esempio n. 2
0
        public void World_SaveLoad_Test()
        {
            WorldExtensions.ForEach(ext =>
            {
                string name = "World";
                string fileName = name + ext;

                AssetLoadArguments args = new AssetLoadArguments();
                args.Add("cube", true);

                var world1 = new World(Device, name, AssetManager);
                world1.Skybox.SkyTexture = AssetManager.Load(@"Test\SpaceSkyCubeMap.dds", args) as CubeTexture;
                world1.DarkenBorder.IsEnabled = false;
                world1.DarkenBorder.BorderTexture = AssetManager.Load(@"Engine\ScreenBorderFadeout.dds") as Texture;
                world1.Glow.IsEnabled = false;
                world1.Glow.RadialBlurScaleFactor = 1.0f;
                world1.Glow.BlurWidth = 7.0f;
                world1.Glow.GlowIntensity = 0.6f;
                world1.Glow.HighlightIntensity = 0.3f;
                world1.Save(fileName);

                var world2 = World.Load(Device, fileName, name, AssetManager);
                Assert.AreEqual(name, world2.Name);
                Assert.AreEqual(world1.Skybox.SkyTexture, world2.Skybox.SkyTexture);
                Assert.AreEqual(world1.DarkenBorder.IsEnabled, world2.DarkenBorder.IsEnabled);
                Assert.AreEqual(world1.DarkenBorder.BorderTexture, world2.DarkenBorder.BorderTexture);
                Assert.AreEqual(world1.Glow.IsEnabled, world2.Glow.IsEnabled);
                Assert.AreEqual(world1.Glow.RadialBlurScaleFactor, world2.Glow.RadialBlurScaleFactor);
                Assert.AreEqual(world1.Glow.BlurWidth, world2.Glow.BlurWidth);
                Assert.AreEqual(world1.Glow.GlowIntensity, world2.Glow.GlowIntensity);
                Assert.AreEqual(world1.Glow.HighlightIntensity, world2.Glow.HighlightIntensity);
            });
        }
Esempio n. 3
0
        public void AssetManager_Arguments_GetValue_Test()
        {
            var args = new AssetLoadArguments();

            args.Add("intKey", 5);
            Assert.AreEqual(5, args.GetValue<int>("intKey", 0));

            args.Add("stringKey", "text");
            Assert.AreEqual("text", args.GetValue<string>("stringKey", ""));
        }
Esempio n. 4
0
        public void SceneManager_SetWorld_Test()
        {
            var sceneMgr = new SceneManager(Device, AssetManager);

            var world = new World(Device, "world", AssetManager);
            var args = new AssetLoadArguments();
            args.Add("cube", true);
            world.Skybox.SkyTexture = AssetManager.Load(@"Test\SpaceSkyCubeMap.dds", args) as CubeTexture;

            sceneMgr.World = world;
            Assert.AreEqual(world, sceneMgr.World);
        }
Esempio n. 5
0
 public object Load(Device device, string filePath, AssetLoadArguments args, string name, AssetManager assetManager)
 {
     bool loadHierarchy = args.GetValue<bool>("loadHierarchy", false);
     //if (loadHierarchy)
     //{
     //    return new BoneMesh(this.device, this, fullPath, name);
     //}
     //else
     {
         return Mesh.CreateFromXFile(device, assetManager, filePath, name);
     }
 }
Esempio n. 6
0
        public void AssetManager_Arguments_Equality_Test()
        {
            var actual = new AssetLoadArguments();
            actual.Add("Key", 5);

            var expected = new AssetLoadArguments();
            expected.Add("key", 5);
            Assert.AreEqual(expected, actual);

            expected = new AssetLoadArguments();
            expected.Add("Key", 5.0f);
            Assert.AreNotEqual(expected, actual);

            expected = new AssetLoadArguments();
            expected.Add("Key", "five");
            Assert.AreNotEqual(expected, actual);

            expected = new AssetLoadArguments();
            expected.Add("NotKey", 5);
            Assert.AreNotEqual(expected, actual);
        }
Esempio n. 7
0
        public void DirectXMeshFactory_Test()
        {
            Assert.AreEqual(typeof(DirectXMesh), AssetManager.GetAssetType("sample.x"));

            // Normal mesh
            string path = @"Test\tiger.x";
            Mesh mesh = AssetManager.Load(path) as Mesh;
            Assert.IsNotNull(mesh);
            Assert.AreEqual(path, mesh.Name);

            // Reload with changing option
            var args = new AssetLoadArguments();
            args.Add("loadHierarchy", true);
            Assert.AreNotEqual(mesh, AssetManager.Load(TestHelpers.SampleDirectXMeshPath, args) as Mesh);

            //// Bone-mesh
            //args = new Arguments();
            //args.Add("loadHierarchy", true);
            //path = @"Test\viking3.x";
            //BoneMesh boneMesh = resMgr.Load(path, args) as BoneMesh;
            //Assert.IsNotNull(boneMesh);
            //Assert.AreEqual(path, boneMesh.Name);
        }
Esempio n. 8
0
        public void TextureFactory_Test()
        {
            Assert.AreEqual(typeof(Texture), AssetManager.GetAssetType("sample.jpg"));
            Assert.AreEqual(typeof(Texture), AssetManager.GetAssetType("sample.bmp"));
            Assert.AreEqual(typeof(Texture), AssetManager.GetAssetType("sample.dds"));
            Assert.AreEqual(typeof(Texture), AssetManager.GetAssetType("sample.tga"));
            Assert.AreEqual(typeof(Texture), AssetManager.GetAssetType("sample.png"));

            string path = @"Test\SpaceSkyCubeMap.dds";
            var texture = AssetManager.Load(path) as Texture;
            Assert.IsNotNull(texture);
            Assert.AreEqual(path, texture.Name);

            // Load as cube texture
            var args = new AssetLoadArguments();
            args.Add("cube", true);
            var cubeTex = AssetManager.Load(path, args) as CubeTexture;
            Assert.IsNotNull(cubeTex);
            Assert.AreNotEqual(texture, cubeTex);
            Assert.AreEqual(path, cubeTex.Name);

            // Loading non-cube texture as cube texture fails
            Assert.IsNull(AssetManager.Load(@"Test\DefaultColor.dds"));
        }
Esempio n. 9
0
 public object Load(Device device, string filePath, AssetLoadArguments args, string name, AssetManager assetManager)
 {
     return Font.Load(device, filePath, name, assetManager);
 }
Esempio n. 10
0
 public object Load(Device device, string filePath, AssetLoadArguments args, string name, AssetManager assetManager)
 {
     bool cube = args.GetValue<bool>("cube", false);
     if (cube)
     {
         return new CubeTexture(device, filePath, name);
     }
     else
     {
         return new Texture(device, filePath, name);
     }
 }
Esempio n. 11
0
 public object Load(Device device, string filePath, AssetLoadArguments args, string name, AssetManager assetManager)
 {
     return new Shader(device, filePath, name);
 }
Esempio n. 12
0
 public void AssetManager_Arguments_GetNonExistingValue_Test()
 {
     var args = new AssetLoadArguments();
     Assert.AreEqual(-9132, args.GetValue<int>("invalidKey", -9132));
 }
Esempio n. 13
0
 public object Load(Device device, string filePath, AssetLoadArguments args, string name, AssetManager assetManager)
 {
     return new AssetMock();
 }