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.

DarkBASIC Professional Discussion / question about pick screen

Author
Message
Southside Games
15
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 2nd Jan 2014 02:23
Hello.

for a birds eye view game I'm doing I would like objects to be positioned were the mouse would land on the ground. I used pick screen and ignored the y value. But this does not give a true position.

so to ask in an RTS perspective how can I click on a peace of ground and get true world cords?

Thanks
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 2nd Jan 2014 05:47 Edited at: 2nd Jan 2014 11:01
This is taken directly from the help file for pick screen:

Quote: "The resulting 3D coordinate is not a world position, but a relative 3D vector from the current camera position. The world coordinate can be obtained by adding the camera position to the resulting vector."
Southside Games
15
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 2nd Jan 2014 06:27 Edited at: 2nd Jan 2014 08:16
I did add the camera position. The thing is that it's accurate when the mouse is close to the bottom of the screen. but as it gets to the upper corners it starts to fall short. I'm sure it has to do with the distance as the camera is at a 45 degree angle. I'm just not sure how to add in the distance multiplier that would take effect as the mouse hovers over a farther out part of the plane.

I added a photo. the cube is the object that represents the 3d cord. the circle is were the mouse is.

Attachments

Login to view attachments
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 2nd Jan 2014 11:01 Edited at: 2nd Jan 2014 11:07
The pick screen command requires that you specify a distance perimeter, yet because your camera isn't orthographic you don't know the exact distance from the camera to your ground object (at that screen location). The location you clicked was farther away than the distance value you passed to pick screen. Greater distance means larger values for the X and Z components of the resulting vector. I'm terrible at explaining this kind of thing, but I've attached an image which hopefully illustrates the issue.

That aside, the pick screen command wasn't intended for this kind of thing. Try using Pick Object() instead and you will have better luck.

Attachments

Login to view attachments
Southside Games
15
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 2nd Jan 2014 19:31
Ah that worked. Also the picture was very helpful in explaining the situation. Thanks for the help.
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 2nd Jan 2014 19:40
Awesome, glad I could help

Login to post a reply

Server time is: 2025-05-15 08:11:31
Your offset time is: 2025-05-15 08:11:31