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 / 2D mouse position into a 3D coordinate

Author
Message
txc2004
8
Years of Service
User Offline
Joined: 28th Nov 2015
Location: Greece
Posted: 11th Feb 2016 19:55 Edited at: 14th Feb 2016 12:59
Hello to all!

The code bellow get the 3d coordinates from Mouse Screen X,Y...
On Flat Terrain everything work amazing Pixel Perfect, on any Camera Angle/Rotate/Height/Distance!

But for random terrain is not good.

Exist side solutions, but,
if anyone, some time, who know from DarkGDK or Trigonometry and can make to work with original way, that is very usefull.



Thank's!

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 21st Feb 2016 01:57
I dont use GDK.net so I'm not sure if it contains the PickObject() command but give this a shot:

txc2004
8
Years of Service
User Offline
Joined: 28th Nov 2015
Location: Greece
Posted: 25th Feb 2016 13:08 Edited at: 7th Mar 2016 12:01
Hello my friend,
Thanks for the answer!

I know this solution from darkbasic pro, exist the PickObject() command:
DarkGDK.Basic3D.Object3D.Pick(DarkGDK.IO.Mouse.X, DarkGDK.IO.Mouse.Y, someObject, someObject)

but, on DarkGDK not working with terrain, because terrain is Terrain and not Object!
DarkGDK see this two like different things:

Dim oTerrain As DarkGDK.World.Terrain
Dim someObject As DarkGDK.Basic3D.Object3D

Im ok for now, i found side solution, with Ray Casting,
i put the code on next thread for other people who needed...
txc2004
8
Years of Service
User Offline
Joined: 28th Nov 2015
Location: Greece
Posted: 25th Feb 2016 13:56 Edited at: 7th Mar 2016 11:47
Get 3D coordinates from 2D mouse position on Random Terrain!

How work the Ray Cacting, is very simple and can use from any language.
Just make some Ray with Cylinders and check witch one is closer on Terrain Height, the rest is easy.

This is sample code, put your desired properties on the cylinders and you can write the code with your way.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-19 21:14:24
Your offset time is: 2024-04-19 21:14:24