Hi
Looking through the forum and testing different parameters to the screen2world command I ended up with this that works perfect on Windows but on iPad the Y-coord is wrong making the lines miss by a significant distance (to high). I can add the difference but why does this behave different on iPad vs Windows when the screen is in both tests set to 1024x768 (portrait) ? The aspect ratio of the height and width seems correct in both cases compared to 1024 x 768 screen).
(the test-program just draws a line from 0,0,0 to mousepointer on windows. On iPad it draws a line/polygon using the multitouch feature).
Regards
Eirik
Looking through the forum and testing different parameters to the screen2world command I ended up with this that works perfect on Windows but on iPad the Y-coord is wrong making the lines miss by a significant distance (to high). I can add the difference but why does this behave different on iPad vs Windows when the screen is in both tests set to 1024x768 (portrait) ? The aspect ratio of the height and width seems correct in both cases compared to 1024 x 768 screen).
(the test-program just draws a line from 0,0,0 to mousepointer on windows. On iPad it draws a line/polygon using the multitouch feature).
Code (glbasic) Select
// --------------------------------- //
// Project: MyTest
// Start: Saturday, January 14, 2012
// IDE Version: 10.231
SETCURRENTDIR("Media")
SYSTEMPOINTER TRUE
CLEARSCREEN
LOCAL points#[]
DIM points#[20][3]
WHILE TRUE
X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, 100, 0, 0, 0
LOCAL mouse%, mx%, my%, b1%, b2%, maxMouse%, currentMouse%
LOCAL wx#, wy#, wz#, lastX%, lastY%
maxMouse = GETMOUSECOUNT()
currentMouse = 0
FOR mouse = 0 TO maxMouse - 1
SETACTIVEMOUSE mouse
MOUSESTATE mx, my, b1, b2
IF b1
lastX = mx
lastY = my
X_SCREEN2WORLD mx, my, 1, wx#, wy#, wz#
points[currentMouse][0] = wx# / 10.0
points[currentMouse][1] = wy# / 10.0
points[currentMouse][2] = wz#
INC currentMouse, 1
ENDIF
NEXT
LOCAL drawMouse%
IF currentMouse > 1
FOR drawMouse = 0 TO currentMouse - 2
X_LINE points[drawMouse][0], points[drawMouse][1], 0, points[drawMouse+1][0], points[drawMouse+1][1], 0, 5, RGB(255, 0, 0)
NEXT
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, points[0][0], points[0][1], 0, 5, RGB(255, 0, 0)
ELSE
X_LINE points[currentMouse - 1][0], points[currentMouse - 1][1], 0, 0,0,0, 5, RGB(0, 255, 0)
ENDIF
X_MAKE2D
PRINT "Mouse : " + maxMouse, 10, 10
PRINT "Current : " + currentMouse, 10, 20
PRINT "Last : " + lastX + ", " + lastY, 10, 30
LOCAL index%
FOR index = 0 TO currentMouse - 1
PRINT "Coords : " + points[index][0] + " , " + points[index][1] + ", " + points[index][2], 10, 40 + index * 10
NEXT
SHOWSCREEN
WEND
END
Regards
Eirik