/// <summary> /// Handle keys /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F2) { Parameters.ToggleVSync(); } if (e.Key == Keys.F5) { Reload(); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } }
/// <summary> /// Handle keys for each demo /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F2) { Parameters.VSyncInterval = (Parameters.VSyncInterval == 0) ? 1 : 0; } if (e.Key == Keys.F5) { Game.Instance.Reload(); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } }
void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.LeftShift) { angularVelocity *= 3; upDownVelocity *= 3; } if (e.Key == Keys.W) { latitude += latitude > 85 ? 0 : latVelocity * GameTime.Elapsed.Milliseconds; } if (e.Key == Keys.S) { latitude -= latitude < -85 ? 0 : latVelocity * GameTime.Elapsed.Milliseconds; } if (e.Key == Keys.A) { longitude -= lonVelocity * GameTime.Elapsed.Milliseconds; } if (e.Key == Keys.D) { longitude += lonVelocity * GameTime.Elapsed.Milliseconds; } if (e.Key == Keys.Space) { altitude += upDownVelocity * GameTime.Elapsed.Milliseconds / 3; } if (e.Key == Keys.C) { altitude -= upDownVelocity * GameTime.Elapsed.Milliseconds / 3; } }
void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.Up) { if (Config.SPEED >= 10) { Config.SPEED = Config.SPEED + 5; } else if (Config.SPEED >= 2) { Config.SPEED = Config.SPEED + 1; } else { Config.SPEED = (float)(Math.Round((double)Config.SPEED + 0.1f, 1)); } } if (e.Key == Keys.Down) { if (Config.SPEED > 10) { Config.SPEED = Config.SPEED - 5; } else if (Config.SPEED > 2) { Config.SPEED = Config.SPEED - 1; } else { Config.SPEED = (float)(Math.Round((double)Config.SPEED - 0.1f, 1)); } } }
void keyboardHandler(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.OemPlus) { commandQueue.Enqueue(1); } if (e.Key == Keys.OemMinus) { commandQueue.Enqueue(-1); } }
void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (Game.InputDevice.IsKeyDown(Keys.LeftButton)) { if (ParticleList.Count > 0) { var cam = Game.GetService <OrbitCamera>(); StereoEye stereoEye = Fusion.Graphics.StereoEye.Mono; var viewMtx = cam.GetViewMatrix(stereoEye); var projMtx = cam.GetProjectionMatrix(stereoEye); var inp = Game.InputDevice; int w = Game.GraphicsDevice.DisplayBounds.Width; int h = Game.GraphicsDevice.DisplayBounds.Height; param.MouseX = 2.0f * (float)inp.MousePosition.X / (float)w - 1.0f; param.MouseY = -2.0f * (float)inp.MousePosition.Y / (float)h + 1.0f; simulationBufferSrc.GetData(injectionBufferCPU); foreach (var part in injectionBufferCPU) { var worldPos = new Vector4(part.Position, 1); var viewPos = Vector4.Transform(worldPos, viewMtx); var projPos = Vector4.Transform(viewPos, projMtx); projPos /= projPos.W; if ((Math.Abs(projPos.X /*/ projPos.Z */ - param.MouseX) < 0.02f) && (Math.Abs(projPos.Y /*/ projPos.Z */ - param.MouseY) < 0.02f)) { Console.WriteLine(part.Size0 + " Size"); break; } } } } if (Game.InputDevice.IsKeyDown(Keys.Q)) { Pause(); } if (Game.InputDevice.IsKeyDown(Keys.B)) { AddMaxParticles(); } }
/// <summary> /// Handle keys for each demo /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } }
void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.P) { if (!_isPaused) { pausedTime = gameTime; } else { queue.delay(gameTime - pausedTime); } _isPaused = !_isPaused; } if (e.Key == Keys.Q) { _isStepByStep = !_isStepByStep; } if (e.Key == Keys.Space) { _nextStep = true; } }
/// <summary> /// Handle keys /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F5) { Reload(); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } if (e.Key == Keys.P) // pause/unpause { var gs = GetService <GraphSystem>(); if (gs.Paused) { gs.Unpause(); } else { gs.Pause(); } } if (e.Key == Keys.F) // focus on a node { var cam = GetService <GreatCircleCamera>(); var pSys = GetService <GraphSystem>(); if (nodeSelected) { pSys.Focus(selectedNodeIndex, cam); } } if (e.Key == Keys.LeftButton) { var pSys = GetService <GraphSystem>(); Point cursor = InputDevice.MousePosition; int selNode = 0; if (nodeSelected = pSys.ClickNode(cursor, StereoEye.Mono, 0.025f, out selNode)) { selectedNodeIndex = selNode; var protein = protGraph.GetProtein(selectedNodeIndex); var inEdges = protGraph.GetIncomingInteractions(protein.Name); var outEdges = protGraph.GetOutcomingInteractions(protein.Name); string protName = ((NodeWithText)protGraph.Nodes[selNode]).Text; Console.WriteLine("id = " + selNode + " name: " + protein.Name + ": "); Console.WriteLine("incoming:"); foreach (var ie in inEdges) { Console.WriteLine(ie.Item1.GetInfo()); } Console.WriteLine("outcoming:"); foreach (var oe in outEdges) { Console.WriteLine(oe.Item1.GetInfo()); } Console.WriteLine(); } } if (e.Key == Keys.R) { ResetGraph(); } //if (e.Key == Keys.Q) //{ // Graph graph = GetService<GraphSystem>().GetGraph(); // graph.WriteToFile("../../../../graph.gr"); // Log.Message("Graph saved to file"); //} if (e.Key == Keys.D1) { action1(); } if (e.Key == Keys.D2) { action2(); } if (e.Key == Keys.D3) { action3(); } if (e.Key == Keys.D4) { action4(); } if (e.Key == Keys.D5) { action5(); } if (e.Key == Keys.D6) { action6(); } }
/// <summary> /// Handle keys /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F5) { Reload(); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } if (e.Key == Keys.K) { if (simulationSpeed < 100) { simulationSpeed = simulationSpeed + 5; } iterationTimer = 0; } if (e.Key == Keys.L) { if (simulationSpeed > 10) { simulationSpeed = simulationSpeed - 5; } iterationTimer = 0; } // if (e.Key == Keys.I) if (e.Key == Keys.LeftButton) { GetService <ParticleSystem>().AddMaxParticles(); iterationTimer = simulationSpeed - 10; startSimulation = true; } if (e.Key == Keys.Q) { iterationTimer = 0; } if (e.Key == Keys.B) { iterationTimer = 0; } }
/// <summary> /// Handle keys for each demo /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { if (e.Key == Keys.F1) { DevCon.Show(this); } if (e.Key == Keys.F2) { Parameters.ToggleVSync(); } if (e.Key == Keys.F5) { Reload(); } if (e.Key == Keys.F12) { GraphicsDevice.Screenshot(); } if (e.Key == Keys.Escape) { Exit(); } if (e.Key == Keys.T) { foreach (var box in space.Entities) { box.AngularMomentum *= 10.1f; } } // pause physics if (e.Key == Keys.P) { if (flag) { flag = false; } else { flag = true; } } // shoot box from camera if (e.Key == Keys.LeftButton) { Vector3Fusion vector = GetService <Camera>().FreeCamPosition; Box box = new Box(new Vector3BEPU(vector.X, vector.Y, vector.Z), 1, 1, 1, 1); Vector3Fusion velocity = 10 * GetService <Camera>().GetCameraMatrix(StereoEye.Mono).Forward; box.LinearVelocity = new Vector3BEPU(velocity.X, velocity.Y, velocity.Z); box.Tag = RandomExt.NextColor(random); space.Add(box); } // add new box somewhere if (e.Key == Keys.O) { Vector3Fusion vector = RandomExt.NextVector3(random, new Vector3Fusion(-10, 20, -10), new Vector3Fusion(10, 30, 10)); Box box = new Box(new Vector3BEPU(vector.X, vector.Y, vector.Z), 1, 1, 1, 1); box.Tag = RandomExt.NextColor(random); space.Add(box); } }
void InputDevice_KeyDown(object sender, Fusion.Input.InputDevice.KeyEventArgs e) { // if (e.Key == Keys.LeftButton) if (e.Key == Keys.I) { Console.WriteLine("LEFT BUTTON"); var cam = Game.GetService <OrbitCamera>(); StereoEye stereoEye = Fusion.Graphics.StereoEye.Mono; var viewMtx = cam.GetViewMatrix(stereoEye); var projMtx = cam.GetProjectionMatrix(stereoEye); var inp = Game.InputDevice; int w = Game.GraphicsDevice.DisplayBounds.Width; int h = Game.GraphicsDevice.DisplayBounds.Height; param.MouseX = 2.0f * (float)inp.MousePosition.X / (float)w - 1.0f; param.MouseY = -2.0f * (float)inp.MousePosition.Y / (float)h + 1.0f; //foreach (var part in injectionBufferCPU) for (int i = 0; i < cfg.BankNodes; i++) { var part = injectionBufferCPU[i]; var worldPos = new Vector4(part.Position, 1); var viewPos = Vector4.Transform(worldPos, viewMtx); var projPos = Vector4.Transform(viewPos, projMtx); if ((Math.Abs(projPos.X / projPos.Z - param.MouseX) < 0.02f) && (Math.Abs(projPos.Y / projPos.Z - param.MouseY) < 0.2f)) { Console.WriteLine("Matched!"); currentParticle = part.Id; Console.WriteLine(currentParticle); } } } if (e.Key == Keys.Q) { Pause(); } if (e.Key == Keys.B) { changelayout(); Console.WriteLine("B"); Pause(); } if (e.Key == Keys.V) { StopDrawindLinks(); Console.WriteLine("V"); } if (e.Key == Keys.M) { drawPlot(1); } }