2D picking theory

Started by
4 comments, last by sgt_barnes 11 years, 5 months ago
Hi,

so I'm trying to pick 2D quads. I read this paper (http://www.dyn-lab.c...-selection.html), 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
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

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


oh ok smile.png
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?

oh ok smile.png
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?


Exactly!

[quote name='Yours3!f' timestamp='1351539003' post='4995136']
oh ok smile.png
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?


Exactly!
[/quote]

omg just tried it out, works pixel perfect!!! BIG thank you!
Hehehe! Very good!
I get this euphoric feeling every time when something involving "heavy math" starts working all of a sudden! laugh.png

This topic is closed to new replies.

Advertisement