• Advertisement
Sign in to follow this  

Mesh.Intersect Not Picking

This topic is 4741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an interesting problem with mesh.intersect that I am helping someone can help me out with. I have a managed C# program that is building an array of meshes that it is displaying inside of a windows form. The meshes display just fine, but when I try to pick a mesh, I can only pick the last mesh that was added to the array. I can drag the meshes around inside of the form (translating them), and I can always pick the last mesh in the array no matter where it is in the form, but I cannot ever pick any of the other meshes in the array. Here is the picking code on the form: private void Pick() { System.Drawing.Point ptCursor = new Point (System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y); ptCursor = this.PointToClient(ptCursor); Microsoft.DirectX.Vector3 vPickRayOrig = new Microsoft.DirectX.Vector3(ptCursor.X, ptCursor.Y, 0.0f); vPickRayOrig.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World); Microsoft.DirectX.Vector3 vPickRayFar = new Microsoft.DirectX.Vector3(ptCursor.X, ptCursor.Y, 1.0f); vPickRayFar.Unproject(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World); vPickRayFar.Subtract(vPickRayOrig); int i = 0; foreach (cspanel panelx in panelArray) { Microsoft.DirectX.Direct3D.IntersectInformation hitInfo = new Microsoft.DirectX.Direct3D.IntersectInformation(); if(panelx.Pick(vPickRayFar, vPickRayOrig, ref hitInfo)) { i++; } } statusBar1.Text = string.Format("{0}\t", i); } and here is the Pick method from the panel class public bool Pick(Vector3 vPickRayFar, Vector3 vPickRayOrig, ref Microsoft.DirectX.Direct3D.IntersectInformation hitInfo) { if ( panelMesh.Intersect ( vPickRayOrig, vPickRayFar, out hitInfo ) == true) { return true; } else { return false; } } Can anyone help me out? I would really appreciate it as this problem has stumped me for two nights.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement