Jump to content

  • Log In with Google      Sign In   
  • Create Account

2D picking theory


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 28 October 2012 - 12:01 PM

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

Edited by Yours3!f, 28 October 2012 - 12:02 PM.


Sponsor:

#2 sgt_barnes   Members   -  Reputation: 621

Like
1Likes
Like

Posted 29 October 2012 - 02:41 AM

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

#3 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 29 October 2012 - 01:30 PM

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 Posted Image
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, 29 October 2012 - 01:32 PM.


#4 sgt_barnes   Members   -  Reputation: 621

Like
0Likes
Like

Posted 30 October 2012 - 01:58 AM

oh ok Posted Image
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!

#5 Yours3!f   Members   -  Reputation: 1397

Like
0Likes
Like

Posted 30 October 2012 - 02:02 PM


oh ok Posted Image
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!


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

#6 sgt_barnes   Members   -  Reputation: 621

Like
0Likes
Like

Posted 31 October 2012 - 03:00 AM

Hehehe! Very good!
I get this euphoric feeling every time when something involving "heavy math" starts working all of a sudden! Posted Image




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS