Jump to content
  • Advertisement
Sign in to follow this  
derek7

my picking solution .

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

so look if there are any problem. usually use picking ray. but my step: 1. get shape in screen of every object in world space/view space. 2. see if cursor point is in shape? 3. if cursor in mutiply shape, see which object is closet to origin. so why not use these step instead of useing picking ray?

Share this post


Link to post
Share on other sites
Advertisement
Quote:

original post by derek7
so look if there are any problem.
usually use picking ray.

but my step:
1. get shape in screen of every object in world space/view space.
2. see if cursor point is in shape?
3. if cursor in mutiply shape, see which object is closet to origin.

so why not use these step instead of useing picking ray?


Actually, your method is very similar to what OpenGL (glu) implementations use... they first reduce the viewport to the pixels under and around the cursor (I think it's the 3x3 area around the pointer) and render everything, doing the transformations and culling, then using the depth test to keep track of which "name" is currently on top.

Plus, this is usually done in hardware so you don't bog down your CPU with transformation calculations and culling routines that many video cards are specially built to handle. It's a little kludgy to set up, (and hint: name something for the background before passing anything to the pipeline to avoid some hard to track bugs) but it works. You could even code it up yourself if you don't want to use the GLU library...

If you have some domain-specific knowledge about the objects in your game, you can even do some additional culling for things that you know aren't going to be picked. Picking ray works, too, though... since button clicks don't happen most frequently, this isn't where I would optimize unless you need those extra microseconds of input latency back. For instance, if you knew that there would be many many pickable objects, or if you were concerned about what the cursor is hovering over... still, GLU seems to work fine for picking.

[Note: hmmm... it's weird that some topics have posts that can only be seen during a reply action. Maybe a bug in the ASP or DB code?]

Share this post


Link to post
Share on other sites
Quote:
Original post by void*
(I think it's the 3x3 area around the pointer)

Actually you can specify the region, so it could be anything you'd like, not just 3x3.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!