You can't use cameraproject here so the above is nonsense!
As you're talking about purely 2d coords you have no option but to store the coords of the viewports as you create them and use a rectsoverlap to see which one is being selected. See below for example.
Graphics3D 800,600,32,1
Type CamT
Field Camera
Field x, y
Field sx, sy
End Type
Global Cam1 = CAMERAcreate( 0,0,400,300 ) : CameraClsColor Cam1, 200,50,50
Global Cam2 = CAMERAcreate( 400,0,400,300 ) : CameraClsColor Cam2, 50,50,200
Global Cam3 = CAMERAcreate( 0,300,400,300 ) : CameraClsColor Cam3, 50,200,50
Global Cam4 = CAMERAcreate( 400,300,400,300 ) : CameraClsColor Cam4, 150,150,0
While Not KeyHit(1)
ThisCamera = CAMERAselected( MouseX(), MouseY() )
RenderWorld()
Text MouseX(), MouseY(), "X", 1, 1
Text 0,0, ThisCamera
Flip
Wend
;=============================================================
;=============================================================
;=============================================================
Function CAMERAcreate( x, y, sx, sy )
c.CamT = New CamT
c\Camera = CreateCamera()
CameraViewport c\Camera, x , y , sx , sy
c\x = x
c\y = y
c\sx = sx
c\sy = sy
Return c\Camera
End Function
;=============================================================
;=============================================================
;=============================================================
Function CAMERAselected( x, y )
Found = 0
For c.CamT = Each CamT
If RectsOverlap( x, y, 1, 1, c\x, c\y, c\sx, c\sy )
Found = c\Camera
EndIf
Next
Return Found
End Function
|