Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK .NET / How to get mouse coordinates on map (not on screen)

Author
Message
Chess
17
Years of Service
User Offline
Joined: 25th Mar 2007
Location: Québec, Canada
Posted: 17th Oct 2009 19:15 Edited at: 17th Oct 2009 23:05
Hi!

I have a not-so simple question... I'd like to be able to get mouse coordinates on a 3D map (not on screen) to be able to select an object but I cannot figure how to do it?

I hope you understand what I am talking of, you know, we often see this in map-maker programs or in rpg... Sometimes, it is used to move a character in a map, also.

Hope someone can give me a hand to understand how it works.. Thanks to you!


--Edit--

Hum. I think the best way to do it would be to use the mouse as a 3D Object which I move on the map. At this point, I've added a sphere (for the mouse "pointer") as a limb to the player, because if I do move or rotate the player, the mouse should follow the movement and to move the mouse, I would use the offset of the limb.

Now, the true question comes, how can I calculate the offset needed when I do move the mouse?

--> If you think of a better way to do it than limbs, please tell me.

--Edit--
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Oct 2009 17:29
Here is how I have it. This code is not tested as it's currently being converted from DBP, but the principle is there.

1. Make a cone for the mouse...



2. This bit checks for mouse movement. cx and cy are populated with MouseMoveX and MouseMoveY. It uses pickobject to get the point on my terrain, and also records the change in position in terrain terms, rather than 2D mouse terms. The camera can be up to 5000 units away from the terrain, it can be fine tuned for performance if necessary.



From this code, I can position the cursor on the terrain, and I can also use the movement difference to do other things (such as smooth the cursor movement).

Hope this helps, and works as it did in DBP!

Chess
17
Years of Service
User Offline
Joined: 25th Mar 2007
Location: Québec, Canada
Posted: 21st Oct 2009 04:34
Thank you, BatVink! I wasn't able to make it works yet, but I'm still working on it. At least, the concept of PickScreen gave me a good clue on how to do it the way I want.
Cujo Canada
14
Years of Service
User Offline
Joined: 8th Nov 2009
Location:
Posted: 29th Dec 2009 21:20
whats that code in DBP?

http://i342.photobucket.com/albums/o430/CaptainEllipsis/Sigs%20and%20Wallpapers/MetroidPrime3wallpaperv3.png

Login to post a reply

Server time is: 2024-04-19 06:17:30
Your offset time is: 2024-04-19 06:17:30