Jump to content
  • Advertisement
Sign in to follow this  
M@tej

Picking 3D lines in managed DirectX

This topic is 4652 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

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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!