troubleshooting Question

pick object with mouse - Direct3D

Avatar of jhshukla
jhshuklaFlag for United States of America asked on
Game ProgrammingC#Editors IDEs
7 Comments1 Solution3900 ViewsLast Modified:
How can I determine which object is drawn at a particular pixel?
Currently my program calls DrawUserPrimitives, which takes in as data CustomVertex.PositionColored[].
since z-buffer is enabled there must be easy way to determine the polygon at the pixel. but that still leaves the challenge to determine the array from which it came. Seems like I must use some other API to render the objects.

my other option is to compute on-screen bounds of the object. precision is not important. an approximate rectangular box is acceptable. this seems to be simpler but tedious on my part.

Then there is the issue of dragging the object around. The object moves along a horizontal surface. So this time I have to compute world coordinate from screen coordinate.

how should I go about solving this?

btw, I am using .NET 2.0 managed DirectX libs.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros