| degrees
= 0.0174532925 // (radians per degree) angle = view.fieldOfView * degrees * 0.5 if view.width < view.height then distance = (view.width * 0.5) / tan(angle) else distance = (view.height * 0.5) / tan(angle) end if view.camera.position.Z = distance view.hither = distance - 10 view.yon = distance + 10 |
| In
order to get the pick to work correctly, you have to apply a scaling factor
that depends on both the screen size and the view size and position. In
RB code, it looks like this: #If TargetWin32 x2 = x * Screen(0).width / Rb3DSpace1.width - Rb3DSpace1.left y2 = y * Screen(0).height / Rb3DSpace1.height - Rb3DSpace1.top #Else x2 = x // All works as expected on the Mac y2 = y #Endif // // (and then pass x2, y2 to the picking function) So, for both X and Y, we have to multiply by the ratio of the screen size to view size, and then subtract off the top/left of the view (so that the coordinates are now relative to the view rather than the window). On the Mac none of that is necessary; we just pass in window coordinates and it works. |
| RB3DSpace2.Objects = RB3DSpace1.Objects |