private void GlDrawer_MouseWheel(object sender, MouseEventArgs e) { float zoomK = 10; var cur = PointToClient(Cursor.Position); MouseRay mr = new MouseRay(cur.X, cur.Y, Camera); var camera = Camera; if (ClientRectangle.IntersectsWith(new Rectangle(PointToClient(Cursor.Position), new Size(1, 1)))) { if (e.Delta > 0) { var dir = camera.CamTo - camera.CamFrom; dir = mr.Dir; dir.Normalize(); camera.CamFrom += dir * zoomK; camera.CamTo += dir * zoomK; } else { var dir = camera.CamTo - camera.CamFrom; dir = mr.Dir; dir.Normalize(); camera.CamFrom -= dir * zoomK; camera.CamTo -= dir * zoomK; } } }
private void throwBoxToolStripMenuItem_Click(object sender, EventArgs e) { var bx = CreateOdeBox(new Ode.Net.Vector3(0, 0, 15), 1.5f); var pos = drawer.PointToClient(contextMenuStrip1.Bounds.Location); var mr = new MouseRay(pos.X, pos.Y, drawer.Camera); var d = mr.Dir; d.Normalize(); bx.Position = new Ode.Net.Vector3(mr.Start.X, mr.Start.Y, mr.Start.Z); d *= 150; bx.Body.LinearVelocity = new Ode.Net.Vector3(d.X, d.Y, d.Z); }