Jump to content


- - - - -

help calculating


4 replies to this topic

#1 john_lin

    New Member

  • Members
  • Pip
  • 3 posts

Posted 19 December 2012 - 09:49 PM

http://www.gamedev.n...lculating-this/

Hi guys ,
Please check the above link . I don't know how to post images here . Any one know how to calculate this and solve this issuel.Thanks in advance.

john lin

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationBellevue, WA

Posted 19 December 2012 - 10:01 PM

This type of problem is called "unprojection", "ray casting", or "picking". Googling for those terms will probably provide you some useful links.

The basic idea is to use the mouse click position to generate a ray in the 3D world space. It will start at the camera and pass through the pixel you clicked. Then you find where the ray intersects the scene. In your case you'd do a ray-plane intersection with the ground plane, and use the coordinates of the intersection point to tell which tile was clicked.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 john_lin

    New Member

  • Members
  • Pip
  • 3 posts

Posted 20 December 2012 - 05:06 AM

@reedbeta thanks for your reply . I have to do it in 2D space so ray cast is not possible . Is there any way to take mouse click position and calculate this to get in return which tile is selected ? ex: (0,0) for Top_Left tile . thank you

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationBellevue, WA

Posted 20 December 2012 - 06:03 AM

If you define a 2D polygon for the outline of each tile in the image, you can use a point-in-polygon test (google it) to see whether the mouse is over a given tile.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 john_lin

    New Member

  • Members
  • Pip
  • 3 posts

Posted 20 December 2012 - 09:13 PM

thank you for response reedbeta

how the peoples used to calculate the input(mouse click) to select tiles in farm vile like games . I really need that farm vile like solution please help me guys . thank you





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users