Picking 3D lines in managed DirectX

Started by
2 comments, last by gwihlidal 18 years, 2 months ago
Hi all! I am working on a finite element mesh visualisation project. I had it all worked out and then i came to the topic of PICKING. The problem is that my 3D object cosists of lines (beam elements) not triangles - i draw them using indexed buffer like: Device.DrawIndexedPrimitives(PrimitiveType.LineList, ... I know how to pick a triangle using Mesh class but how to pick a line??? Am a supposed to create thin triangles from my lines? I am using managed DirectX 9 and C#. Thx...
Advertisement
You can create lines using degenerate triangles if you want - but I don't think that'll help in this case. Lines only appear as part of the rasterization rules - I don't think the pure mathematical routines will actually "see" them when it comes to picking. Or, more importantly, the accuracy of pixel coordinates (where the mouse was clicked) and the line will probably yield a whole lot of no-hits.

I would suggest you look into writing your own routine rather than using D3DX.

Ideally use some sort of heirarchical arrangement to reduce processing and then then use point-point distance to try and find the closest minimum on one of the mesh's lines.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I thought of creating a mesh of thin triangles only for picking. The drawing would still be done with primitives - lines. That way a little broader triangles could be used (because they would not be drawn) and the picking would be easier - larger area for the user to "hit" the line.

The problem is that the meshes consist of approximately 100.000 elements and more so using triangles for picking would greatly increase the number of required vertices - the picking would be very slow.

So I will probably have to do the picking calculations on my own. But I am conserned about the speed of such process.
All you need to do is convert your screen space coordinate (X, Y mouse click) into world space (X, Y, Z). Turn the value into a normalized ray that goes into your screen and then do line intersection tests.

<shameless_plug>My upcoming book shows how to convert from screen space to world space a couple of ways in Managed Direct3D - http://www.getdbook.com</shameless_plug>

=)

~Graham

This topic is closed to new replies.

Advertisement