protected override void Initialize() { //DualMarchingSquaresNeilson.MarchingSquaresTableGenerator.PrintCaseTable(); ModelIndex = -1; if (ModelIndex > -1) { Sampler.ReadData(Models[ModelIndex], Resolution); } float n = SimplexNoise.Noise(0, 0); RState = new RasterizerState(); RState.CullMode = (Sampler.ImageData != null ? CullMode.CullCounterClockwiseFace : CullMode.CullClockwiseFace); GraphicsDevice.RasterizerState = RState; graphics.PreferredBackBufferWidth = 1600; graphics.PreferredBackBufferHeight = 900; graphics.PreferMultiSampling = true; graphics.ApplyChanges(); IsMouseVisible = true; effect = new BasicEffect(GraphicsDevice); QualityIndex = 0; NextAlgorithm(); effect.VertexColorEnabled = true; Camera = new Camera(GraphicsDevice, new Vector3(-Resolution, Resolution, -Resolution), 1f); if (SelectedAlgorithm.Is3D) { Camera.Update(true); effect.View = Camera.View; } last_state = Keyboard.GetState(); DrawMode = Isosurface.DrawModes.Mesh; WireframeMode = WireframeModes.Fill; base.Initialize(); }
protected override void Update(GameTime gameTime) { // Allows the game to exit if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } if (!last_state.IsKeyDown(Keys.Space) && Keyboard.GetState().IsKeyDown(Keys.Space)) { QualityIndex = (QualityIndex + 1) % Qualities.Length; UpdateQuality(); } if (!last_state.IsKeyDown(Keys.Tab) && Keyboard.GetState().IsKeyDown(Keys.Tab)) { NextAlgorithm(); } if (!last_state.IsKeyDown(Keys.F) && Keyboard.GetState().IsKeyDown(Keys.F)) { SelectedAlgorithm = (ISurfaceAlgorithm)Activator.CreateInstance(SelectedAlgorithm.GetType(), GraphicsDevice, Resolution, TileSize); ModelIndex = (ModelIndex + 1) % Models.Length; Sampler.ReadData(Models[ModelIndex], Resolution); UpdateQuality(); } if (!last_state.IsKeyDown(Keys.D1) && Keyboard.GetState().IsKeyDown(Keys.D1)) { if (DrawMode != DrawModes.Mesh) { DrawMode ^= DrawModes.Mesh; } } if (!last_state.IsKeyDown(Keys.D2) && Keyboard.GetState().IsKeyDown(Keys.D2)) { if (DrawMode != DrawModes.Outline) { DrawMode ^= DrawModes.Outline; } } if (!last_state.IsKeyDown(Keys.D3) && Keyboard.GetState().IsKeyDown(Keys.D3)) { if (WireframeMode == WireframeModes.Fill) { WireframeMode = WireframeModes.Fill | WireframeModes.Wireframe; } else if (WireframeMode == (WireframeModes.Fill | WireframeModes.Wireframe)) { WireframeMode = WireframeModes.Wireframe; } else { WireframeMode = WireframeModes.Fill; } if (WireframeMode != (WireframeModes.Fill | WireframeModes.Wireframe)) { RState = new RasterizerState(); RState.CullMode = CullMode.None; RState.FillMode = (WireframeMode == WireframeModes.Fill ? FillMode.Solid : FillMode.WireFrame); GraphicsDevice.RasterizerState = RState; } } if (!last_state.IsKeyDown(Keys.C) && Keyboard.GetState().IsKeyDown(Keys.C)) { Camera.MouseLocked = !Camera.MouseLocked; } if (!last_state.IsKeyDown(Keys.M) && Keyboard.GetState().IsKeyDown(Keys.M)) { if (SelectedAlgorithm.GetType() == typeof(ManifoldDC.MDC3D)) { ((ManifoldDC.MDC3D)SelectedAlgorithm).EnforceManifold = !((ManifoldDC.MDC3D)SelectedAlgorithm).EnforceManifold; UpdateQuality(); } } if (SelectedAlgorithm.Is3D) { Camera.Update(true); effect.View = Camera.View; } last_state = Keyboard.GetState(); base.Update(gameTime); }
protected override void Initialize() { DualMarchingSquaresNeilson.MarchingSquaresTableGenerator.PrintCaseTable(); float n = SimplexNoise.Noise(0, 0); RState = new RasterizerState(); RState.CullMode = CullMode.CullClockwiseFace; GraphicsDevice.RasterizerState = RState; graphics.PreferredBackBufferWidth = 1600; graphics.PreferredBackBufferHeight = 900; graphics.PreferMultiSampling = true; graphics.ApplyChanges(); IsMouseVisible = true; effect = new BasicEffect(GraphicsDevice); QualityIndex = 1; NextAlgorithm(); effect.VertexColorEnabled = true; Camera = new Camera(GraphicsDevice, new Vector3(-Resolution, Resolution, -Resolution) , 1f); if (SelectedAlgorithm.Is3D) { Camera.Update(true); effect.View = Camera.View; } last_state = Keyboard.GetState(); DrawMode = Isosurface.DrawModes.Mesh | DrawModes.Outline; WireframeMode = WireframeModes.Fill; base.Initialize(); }