void IKeyboardHandler.canvas_KeyPress(object sender, GLKeyPressEventArgs e) { bool updated = false; if (e.KeyChar == frontKey || e.KeyChar == upcaseFrontKey) { vec3 right = this.camera.GetRight(); vec3 standardFront = this.camera.UpVector.cross(right).normalize(); this.camera.Position += standardFront * this.StepLength; this.camera.Target += standardFront * this.StepLength; updated = true; } else if (e.KeyChar == backKey || e.KeyChar == upcaseBackKey) { vec3 right = this.camera.GetRight(); vec3 standardBack = right.cross(this.camera.UpVector).normalize(); this.camera.Position += standardBack * this.StepLength; this.camera.Target += standardBack * this.StepLength; updated = true; } else if (e.KeyChar == leftKey || e.KeyChar == upcaseLeftKey) { vec3 right = this.camera.GetRight(); vec3 left = (-right).normalize(); this.camera.Position += left * this.StepLength; this.camera.Target += left * this.StepLength; updated = true; } else if (e.KeyChar == rightKey || e.KeyChar == upcaseRightKey) { vec3 right = this.camera.GetRight().normalize(); this.camera.Position += right * this.StepLength; this.camera.Target += right * this.StepLength; updated = true; } else if (e.KeyChar == upKey || e.KeyChar == upcaseUpKey) { vec3 up = this.camera.UpVector.normalize(); this.camera.Position += up * this.StepLength; this.camera.Target += up * this.StepLength; updated = true; } else if (e.KeyChar == downKey || e.KeyChar == upcaseDownKey) { vec3 down = -this.camera.UpVector.normalize(); this.camera.Position += down * this.StepLength; this.camera.Target += down * this.StepLength; updated = true; } if (updated) { IGLCanvas canvas = this.canvas; if (canvas.RenderTrigger == RenderTrigger.Manual) { canvas.Repaint(); } } }
/// <summary> /// /// </summary> /// <param name="e"></param> /// <returns></returns> public static GLKeyPressEventArgs Translate(this System.Windows.Forms.KeyPressEventArgs e) { var args = new GLKeyPressEventArgs(e.KeyChar); args.Handled = e.Handled; return(args); }
void WinGLCanvas_KeyPress(object sender, KeyPressEventArgs e) { GLEventHandler <GLKeyPressEventArgs> KeyPress = this.glKeyPress; if (KeyPress != null) { GLKeyPressEventArgs arg = e.Translate(); KeyPress(sender, arg); } }