public void TestMultiSearchDirectoryLoad() { String fileName = "fenris.lws"; String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles\\fenris\\scenes"), Path.Combine(TestHelper.RootPath, "TestFiles\\fenris\\objects") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); //None, using the "target high quality flags caused a crash with this model. Scene scene = importer.ImportFile(fileName, PostProcessSteps.None); Assert.IsNotNull(scene); }
public void TestMultiSearchDirectoryConvert() { String fileName = Path.Combine(TestHelper.RootPath, "TestFiles\\fenris\\scenes\\fenris.lws"); String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles\\fenris\\objects") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); //Output path has to be specified fully, since we may be creating the file String outputPath = Path.Combine(TestHelper.RootPath, "TestFiles\\fenris\\fenris2.obj"); importer.ConvertFromFileToFile(fileName, PostProcessSteps.None, outputPath, "obj", PostProcessSteps.None); }
public void TestIOSystemError() { String fileName = "duckduck.dae"; //GOOSE! String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); Assert.Throws<AssimpException>(delegate() { importer.ImportFile(fileName, PostProcessSteps.None); }); }
public void TestIOSystemError() { String fileName = "duckduck.dae"; //GOOSE! String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); Assert.Throws <AssimpException>(delegate() { importer.ImportFile(fileName, PostProcessSteps.None); }); }
public void TestMultiSearchDirectoryConvert() { String fileName = Path.Combine(TestHelper.RootPath, "TestFiles/fenris/scenes/fenris.lws"); String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles/fenris/objects") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); //Output path has to be specified fully, since we may be creating the file String outputPath = Path.Combine(TestHelper.RootPath, "TestFiles/fenris/fenris2.obj"); importer.ConvertFromFileToFile(fileName, PostProcessSteps.None, outputPath, "obj", PostProcessSteps.None); }
public void TestMultiSearchDirectoryLoad() { String fileName = "fenris.lws"; String[] searchPaths = { Path.Combine(TestHelper.RootPath, "TestFiles/fenris/scenes"), Path.Combine(TestHelper.RootPath, "TestFiles/fenris/objects") }; FileIOSystem ioSystem = new FileIOSystem(searchPaths); AssimpContext importer = new AssimpContext(); importer.SetIOSystem(ioSystem); //None, using the "target high quality flags caused a crash with this model. Scene scene = importer.ImportFile(fileName, PostProcessSteps.None); Assert.IsNotNull(scene); }
protected override void LoadContent() { FileIOSystem.LoadGameSettings(ref this._gameSettings); this.IsMouseVisible = false; this.Window.AllowUserResizing = false; this.Window.IsBorderless = this._gameSettings.Borderless; this._graphics.PreferredBackBufferWidth = (int)this._gameSettings.Resolution.X; this._graphics.PreferredBackBufferHeight = (int)this._gameSettings.Resolution.Y; this._graphics.SynchronizeWithVerticalRetrace = this._gameSettings.Vsync; this.IsFixedTimeStep = this._gameSettings.Vsync; this._graphics.ApplyChanges(); this._camera = new Camera(GraphicsDevice.Viewport, GraphicsDevice.Viewport.Bounds.Center.ToVector2(), 0f, 1f); this._spriteBatch = new SpriteBatch(GraphicsDevice); this._debugText = Content.Load <SpriteFont>(DevConstants.FontAssets.Debug); this._currentState = new TitleState(Content); }
public void TestIOSystem_ImportObj() { String dir = Path.Combine(TestHelper.RootPath, "TestFiles"); LogStream.IsVerboseLoggingEnabled = true; ConsoleLogStream log = new ConsoleLogStream(); log.Attach(); using (AssimpContext importer = new AssimpContext()) { FileIOSystem iOSystem = new FileIOSystem(dir); importer.SetIOSystem(iOSystem); //Using stream does not use the IO system... using (Stream fs = File.OpenRead(Path.Combine(dir, "sphere.obj"))) { Scene scene = importer.ImportFileFromStream(fs, "obj"); Assert.IsTrue(scene != null); Assert.IsTrue(scene.HasMeshes); Assert.IsTrue(scene.HasMaterials); //No material file, so the mesh will always use the default material Assert.IsTrue(scene.Materials[scene.Meshes[0].MaterialIndex].Name == "DefaultMaterial"); } //Using custom IO system requires us to pass in the file name, assimp will ask the io system to get a stream Scene scene2 = importer.ImportFile("sphere.obj"); Assert.IsTrue(scene2 != null); Assert.IsTrue(scene2.HasMeshes); Assert.IsTrue(scene2.HasMaterials); //Should have found a material with the name "SphereMaterial" in the mtl file Assert.IsTrue(scene2.Materials[scene2.Meshes[0].MaterialIndex].Name == "SphereMaterial"); } }
public ILevel Update(GameTime gameTime, Camera camera, ref GameSettings gameSettings, KeyboardState currentKey, KeyboardState prevKey, MouseState currentMouse, MouseState prevMouse) { if (currentKey.IsKeyDown(Keys.Escape) && prevKey.IsKeyUp(Keys.Escape)) { return(null); } if (currentKey.IsKeyDown(Keys.Up) && prevKey.IsKeyUp(Keys.Up)) { _selectedOption -= 1; if (_selectedOption < 0) { _selectedOption = Enum.GetNames(typeof(Options)).Length - 1; } if (_selectedOption > Enum.GetNames(typeof(Options)).Length - 1) { _selectedOption = 0; } } if (currentKey.IsKeyDown(Keys.Down) && prevKey.IsKeyUp(Keys.Down)) { _selectedOption += 1; if (_selectedOption < 0) { _selectedOption = Enum.GetNames(typeof(Options)).Length - 1; } if (_selectedOption > Enum.GetNames(typeof(Options)).Length - 1) { _selectedOption = 0; } } if (currentKey.IsKeyDown(Keys.Left) && prevKey.IsKeyUp(Keys.Left) && _optionItems[_selectedOption].OptionsCollection != null) { _optionItems[_selectedOption].Selection -= 1; if (_optionItems[_selectedOption].Selection < 0) { _optionItems[_selectedOption].Selection = _optionItems[_selectedOption].OptionsCollection.Count - 1; } if (_optionItems[_selectedOption].Selection >= _optionItems[_selectedOption].OptionsCollection.Count) { _optionItems[_selectedOption].Selection = 0; } } if (currentKey.IsKeyDown(Keys.Right) && prevKey.IsKeyUp(Keys.Right) && _optionItems[_selectedOption].OptionsCollection != null) { _optionItems[_selectedOption].Selection += 1; if (_optionItems[_selectedOption].Selection < 0) { _optionItems[_selectedOption].Selection = _optionItems[_selectedOption].OptionsCollection.Count - 1; } if (_optionItems[_selectedOption].Selection >= _optionItems[_selectedOption].OptionsCollection.Count) { _optionItems[_selectedOption].Selection = 0; } } if (currentKey.IsKeyDown(Keys.Enter) && prevKey.IsKeyUp(Keys.Enter)) { switch (_selectedOption) { case (int)Options.ACCEPT_CHANGES: this._gameSettings.Resolution = (Vector2)_optionItems[(int)Options.RESOLUTION].OptionsCollection[_optionItems[(int)Options.RESOLUTION].Selection]; this._gameSettings.Borderless = (bool)_optionItems[(int)Options.BORDERLESS_WINDOW].OptionsCollection[_optionItems[(int)Options.BORDERLESS_WINDOW].Selection]; this._gameSettings.Vsync = (bool)_optionItems[(int)Options.VSYNC].OptionsCollection[_optionItems[(int)Options.VSYNC].Selection]; FileIOSystem.SaveGameSettings(ref this._gameSettings); return(null); case (int)Options.DEFAULT_SETTINGS: FileIOSystem.ResetGameSettings(); FileIOSystem.LoadGameSettings(ref gameSettings); return(new GameSettingsLevel(ref gameSettings)); case (int)Options.CANCEL: return(null); } } return(this); }