• Advertisement
Sign in to follow this  

2D picking theory

This topic is 1907 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,

so I'm trying to pick 2D quads. I read this paper ([url="http://www.dyn-lab.com/articles/pick-selection.html"]http://www.dyn-lab.c...-selection.html[/url]), and I fully understand the theory behind it, however I have a little problem.
All the 2D quads I render start from a quad that is defined like this:

-1, 1..........1, 1
.
.
.
-1,-1..........1,-1

this quad gets translated rotated and scaled, so that it appers on screen where and how I want it. Now the problem is that in the paper, it says that I should do the picking in object space. Now in object space all of the quads are the same right? Because I essentially render the same quad over and over again. So my question is, do I have to transform all the quads into normalized device coordinates, so that I can do picking?
Or is it unnecessary?

Best regards,
Yours3!f Edited by Yours3!f

Share this post


Link to post
Share on other sites
Advertisement
Hello Yours3!f,

yes, that would work. But it makes everything needlessly complicated.

You where right when you said that all your quads are the same in object space. But the picking location isn't... ;-)

So what the article meant, I think, was that you could transform the PICKING LOCATION into the object space FOR EACH OBJECT, then perform a simple min/max test with that object. No need to transform four corners just so you end up with a totally ugly general rectangle inclusion test.

Regards,
Tilmann

Share this post


Link to post
Share on other sites
[quote name='sgt_barnes' timestamp='1351500066' post='4994978']
Hello Yours3!f,

yes, that would work. But it makes everything needlessly complicated.

You where right when you said that all your quads are the same in object space. But the picking location isn't... ;-)

So what the article meant, I think, was that you could transform the PICKING LOCATION into the object space FOR EACH OBJECT, then perform a simple min/max test with that object. No need to transform four corners just so you end up with a totally ugly general rectangle inclusion test.

Regards,
Tilmann
[/quote]

oh ok [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
so I just need to perform this:
for all quads
vec4 objspace_mouse_pos = inv_mvp_of_quad * vec4(mouse_x, mouse_y, 0, 1);
[...]

right? Edited by Yours3!f

Share this post


Link to post
Share on other sites
[quote name='Yours3!f' timestamp='1351539003' post='4995136']
oh ok [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
so I just need to perform this:
for all quads
vec4 objspace_mouse_pos = inv_mvp_of_quad * vec4(mouse_x, mouse_y, 0, 1);
[...]

right?
[/quote]

Exactly!

Share this post


Link to post
Share on other sites
[quote name='sgt_barnes' timestamp='1351583904' post='4995325']
[quote name='Yours3!f' timestamp='1351539003' post='4995136']
oh ok [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
so I just need to perform this:
for all quads
vec4 objspace_mouse_pos = inv_mvp_of_quad * vec4(mouse_x, mouse_y, 0, 1);
[...]

right?
[/quote]

Exactly!
[/quote]

omg just tried it out, works pixel perfect!!! BIG thank you!

Share this post


Link to post
Share on other sites
Hehehe! Very good!
I get this euphoric feeling every time when something involving "heavy math" starts working all of a sudden! [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]

Share this post


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

  • Advertisement