Jump to content

  • Log In with Google      Sign In   
  • Create Account


Picking 2d image rotated


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
2 replies to this topic

#1 Krauser   Members   -  Reputation: 124

Like
0Likes
Like

Posted 20 June 2013 - 02:13 AM

Hi!

I am getting 2d rendering with scale, rotation and traslation of texture (I made this by filling the vertex/index buffer to get a rectangle where my texture is rendered). Now, I'm going to check when the mouse is on texture by coordinates. 

For example: 

if(curPos.x > positionX && curPos.y > positionY && curPos.x < positionX + imgWidth && curPos.y < positionY + imgHeight)
{
     return true;
}

Obviously,when I rotate my textures, it isn't correct. How can I do?

Sorry for English.


Edited by Krauser, 20 June 2013 - 02:22 AM.


Sponsor:

#2 belfegor   Crossbones+   -  Reputation: 2359

Like
0Likes
Like

Posted 20 June 2013 - 03:25 AM

I have an idea but I am not sure if it work since i didn't try it, you can rotate mouse position (center being image center) by same amount to bring everything to be axis aligned, and then test your image rectangle against that position.


Edited by belfegor, 20 June 2013 - 03:28 AM.


#3 Waterlimon   Crossbones+   -  Reputation: 2355

Like
0Likes
Like

Posted 20 June 2013 - 04:25 AM

Generally, you do it as follows:

 

1.Take the series of transformations to get the object on screen (eg. translate->rotate->scale based on aspect ratio = screen x,y)

 

2.Reverse it (screen x,y(mouse pos!) -> inverse scale based on aspect ratio -> inverse rotation -> inverse translation)

 

3.Receive object-local coordinate


Waterlimon (imagine this is handwritten please)





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