Actually, when you use the oDBInput.MouseX and oDBInput.MouseY, the pickobject gets the object based on the mousex and Y in the window, regardless of window position, I have tested this.
Using oDB3D.GetPickDistance you can limit the selection by range from camera.
The code I posted earlier in the thread will allow the pickobject to work in windowed mode, no issue. If you want to limit your return range, thats simple also.
This is what I am using (Method simplified for example):
Private Function locateObject() As Integer
Dim testObj As Integer = oDB3D.PickObject(oDBInput.MouseX, oDBInput.MouseY, 1, 1000)
If oDB3D.GetPickDistance < 8 Then
Return testObj
Else
Return 0
End If
End Function
Since my game works in meters, I want to know if the object is less than 8 meters away, or I don't want to select it (or make it selectable)
If you want to know more about the window, where it is located on the users desktop and its dimensions, you need the following code:
(part taken from MSDN, simply create yourself a new module in your vb.net and give it this information)
Option Explicit On
Imports System.Runtime.InteropServices
Module modHWND
Friend Structure POINTAPI
Public x As Integer
Public y As Integer
End Structure
Friend Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Friend Structure WINDOWPLACEMENT
Public Length As Integer
Public flags As Integer
Public showCmd As Integer
Public ptMinPosition As POINTAPI
Public ptMaxPosition As POINTAPI
Public rcNormalPosition As RECT
End Structure
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Friend Function returnPlacement(ByVal inHwnd As Long) As WINDOWPLACEMENT
Dim wp As WINDOWPLACEMENT
wp.Length = Marshal.SizeOf(wp)
Dim x As Integer
x = GetWindowPlacement(inHwnd, wp)
Return wp
End Function
End Module
rcNormalPosition will contain what you are looking for, if you want to see the results of the capture, modify your game loop with this:
'Game loop
Dim tmpWndLocal As WINDOWPLACEMENT
Dim gameHwnd As Long
gameHwnd = oDBDisplay.GetHWND
'rcNormalPosition Top,Left,Bottom,Right
While oDBP.LoopGDK()
tmpWndLocal = returnPlacement(gameHwnd)
oDBDisplay.SetWindowTitle("Top: " & CStr(tmpWndLocal.rcNormalPosition.Top) & " Left: " & CStr(tmpWndLocal.rcNormalPosition.Left) & _
" Bottom: " & CStr(tmpWndLocal.rcNormalPosition.Bottom) & " Right: " & CStr(tmpWndLocal.rcNormalPosition.Right))
' Sync the loop
oDBCore.Sync()
End While
I see no degradation in FPS with a call to this function on every loop. Although I would recommend a timer instead or a thread that has a heartbeat attached to it to monitor your window states.
Hope this helps.