/// <summary> /// The model viewer_ mouse downx. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void ModelViewer_MouseDownx(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { cam.change(e.X, e.Y); } }
/// <summary> /// The model viewer_ mouse down. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void ModelViewer_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { cam.change(e.X, e.Y); } // if (cam.mousenavigation == Camera.MouseNavigationTypes.None) // { // cam.StartMouseNavigation(e); // } // cam.NavigateByMouseTrackball(e); }
/// <summary> /// The model viewer_ mouse downx. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void ModelViewer_MouseDownx(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { #region Check for collision intersection of Surfaces // This takes our mouse cursor and creates a line directly into the screen (2D -> 3D) Vector3 s = Vector3.Unproject(new Vector3(e.X, e.Y, 0), render.device.Viewport, render.device.Transform.Projection, render.device.Transform.View, Matrix.Identity); Vector3 d = Vector3.Unproject(new Vector3(e.X, e.Y, 1), render.device.Viewport, render.device.Transform.Projection, render.device.Transform.View, Matrix.Identity); Vector3 rPosition = s; Vector3 rDirection = Vector3.Normalize(d - s); // Used to find the nearest polygon IntersectInformation iiClosest = new IntersectInformation(); iiClosest.Dist = 10000; // Set a very far off distance for (int x = 0; x < bsp.BSPRawDataMetaChunks.Length; x++) { //check for intersection IntersectInformation ii; for (int xx = 0; xx < bsp.BSPRawDataMetaChunks[x].Indices.Length; xx += 3) { Geometry.IntersectTri( bsp.BSPRawDataMetaChunks[x].Vertices[bsp.BSPRawDataMetaChunks[x].Indices[xx + 0]], bsp.BSPRawDataMetaChunks[x].Vertices[bsp.BSPRawDataMetaChunks[x].Indices[xx + 1]], bsp.BSPRawDataMetaChunks[x].Vertices[bsp.BSPRawDataMetaChunks[x].Indices[xx + 2]], rPosition, rDirection, out ii); if (ii.Dist != 0) { if (iiClosest.Dist > ii.Dist) { iiClosest = ii; } else { continue; } // holds the surface # that is currently nearest currentSurface = (x << 16) + xx; break; } ; } //updateInfo(); } #endregion } if (e.Button == MouseButtons.Right) { cam.change(e.X, e.Y); } }