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
Please log in or register to post a reply.
This type of problem is called “unprojection”, “ray casting”, or
“picking”. Googling for those terms will probably provide you some
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
@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
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.
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
A simple trick for this kind of thing is to assign each separate thing
you want to select a unique color, then render the scene to a hidden
buffer. When the user clicks, find what color is under the mouse at the
point - this tells you what they clicked on. So long as your scene is
not too expensive to render and has less than 16 million different
things to select, this can be a pretty good solution that avoids
raycasting. If you have a fixed 2D image that you’re selecting from,
then it also lets you have odd-shaped selection areas since you just
have to paint out the map of the various hotspots.