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.

AppGameKit Classic Chat / Picking a point on a surface

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 18th Apr 2017 14:59 Edited at: 18th Apr 2017 15:07
Hi,
Please watch the following video:


As you can see on the video above, the 'ObjectRayCast' command picks a point on the surface when the mouse is not over the surface since the green cube (ooo) is not too far from the camera

Bellow you can see the code


What I want to achieve, is to pick the point of the surface (X-Z, Y=0) under the mouse coordinates and not from the intersection of the ray and the plane
I think I have to calculate the intersection of the surface X-Z and the ray that is perpendicular to camera's surface, but it is hard to calculate the 3D point from the mouse coordinates
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Apr 2017 15:53 Edited at: 18th Apr 2017 16:20
The r points should be a position rather than a vector, this should work


Edit: Regarding finding the the intersection point without a ray cast you can extend the normalized mouse vector by the height of the camera to get the intersection at Y=0
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 18th Apr 2017 16:28 Edited at: 18th Apr 2017 16:37
It works!!!
Thank you very much Paul

Edit: What do you think it is faster?

The second solution also works!
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Apr 2017 22:56
The second solution will always be faster than a ray cast

Login to post a reply

Server time is: 2024-11-24 16:37:57
Your offset time is: 2024-11-24 16:37:57