private static void LoadScene(string levelName)
        {
            var path = PhyConfiguration.GetValue("ModDir");

            string[] searchPath =
            {
                "",
                "downloaded",
                string.Format(@"../{0}_schinese",           path),
                string.Format(@"../{0}_schinese/downloaded",path)
            };
            string filePath = null;

            foreach (var i in searchPath)
            {
                filePath = Path.Combine(path, i, levelName);
                if (File.Exists(filePath))
                {
                    Debug.LogLine("Load map {0}", filePath);

                    var bspLoader = new BspLoader(filePath);

                    _kinematicsManager?.Clear();
                    _kinematicsManager = new KinematicsManager(bspLoader.Models);
                    _sceneStaticObjects.Add(BulletHelper.CreateStaticBody(Matrix.Translation(0, 0, 0),
                                                                          new BvhTriangleMeshShape(bspLoader.Models[0], true),
                                                                          BWorld.Instance));
                    return;
                }
            }
            throw new FileNotFoundException(string.Format("Cannot found map file {0} on these paths: {1}",
                                                          levelName,
                                                          "\n" + string.Join("\n", searchPath)));
        }
Exemple #2
0
        public void TestExportTextureToBitmap()
        {
            // Given
            var fileName     = @"C:\Sierra\Half-Life\valve\maps\hldemo1.bsp";
            var wadFileNames = new string[] { @"C:\Sierra\Half-Life\valve\halflife.wad" };

            var loader = new BspLoader(fileName);
            var map    = loader.Load();

            var wadLoader = new WadLoader(map, fileName, wadFileNames);
            var textures  = wadLoader.Load();

            if (!Directory.Exists("Textures"))
            {
                Directory.CreateDirectory("Textures");
            }

            // When
            foreach (var texture in textures)
            {
                using (var bitmap = TexUtil.PixelsToTexture(texture.TextureData, texture.Width, texture.Height, 4))
                {
                    bitmap.Save("Textures\\" + texture.Name + ".bmp");
                }
            }

            // Then
            foreach (var texture in textures)
            {
                var isExisting = File.Exists("Textures\\" + texture.Name + ".bmp");

                Assert.IsTrue(isExisting);
            }
        }