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
rx as float
ry as float
rz as float
hit as integer
rx = Get3DVectorXFromScreen(thePointer.x, thePointer.y) * 100.0
ry = Get3DVectorYFromScreen(thePointer.x, thePointer.y) * 100.0
rz = Get3DVectorZFromScreen(thePointer.x, thePointer.y) * 100.0
hit = ObjectRayCast(g.obj, GetCameraX(1), GetCameraY(1), GetCameraZ(1), rx, ry, rz)
SetObjectPosition(ooo, rx, ry, rz)
if hit = 1
Print("x=" + str(GetObjectRayCastX(0)) + ", y=" + str(GetObjectRayCastY(0)) + ", z=" + str(GetObjectRayCastZ(0)))
endif
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