Skip to main content
gamedev.net
🔒 Locked

something like picking objects

Started by Elqno Jun 5, 2009 at 3:10 PM 1 replies 650+ views
Original Post
Elqno
Elqno
Hello there, In general I had looked for some post related with I am doing now, but I couldn't find anything (maybe the topic query is wrong, and it has a special name...), I hope the people that is reading this will understand me and will have time to give me a hand. The problem is the next, I'm doing a simple RTS, and what I did so far is the picking objects (which is working without problems), so with it, I can pick any character/building/etc, but now I got myself a challenge which I tried but I can't come with a solution, when a character (small fighter) is selected, I want to do that when clicking with the right button of the mouse at any place over the land/field of the game, this fighter will go there, I don't have problem with the right mouse button or doing an alghorithm finding the shortest path, my problem is that I don't know how to get the coordinates of the field object, I don't know if Picking Objects will be usefull at this point, because i don't wanna choose the field, I just wanna obtain the coordinates, like the fighter is at 0,0,0 (this coordinates are saved in the fighter's class), and I right click in a right upper side (that means that the new coordinates will be positive), so I hope i descibed already my problem very good. If does make a difference I'm programming using Glut and OpenGL. In summary: getting the 3D coordinates of the field (e.g. -100 in X and Z, to 100 in X and Z, Y = 0), by the clicking of the mouse (which gives of course just the x and y coordinates). Thxs so far for reading my post :)
Waterwalker
Waterwalker
If you have already picking functionality up and running I assume you can project a ray to 3d space from a 2d mouse position? Now you only need to do a ray against X intersection with your fields whereas X is the approximate shape closes to your fields such as a rectangle in 3d space. This intersection test returns a 3d position where you ray hits your fields.
------------------------------------I always enjoy being rated up by you ...
Elqno
Elqno
thank you very much with the help, I swear I couldn't come with an idea of how to do it. Sometimes is hard to think individually...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.