Mouse click coords

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Mouse click coords

Postby JeeHell » Thu Dec 06, 2018 10:40 pm

Hello,

I very probably am overlooking a plain stupid thing, but is there a simple way in simconnect or PDK module to retrieve the mouse click view window coordinates?
In other words, when I click on a view, I want to know the X,Y pixel coordinates in that view.

Thanks
Jean Luc

BenBaron
Posts: 36
Joined: Fri Jan 16, 2015 7:51 am

Re: Mouse click coords

Postby BenBaron » Thu Dec 06, 2018 11:46 pm

Hi Jean Luc,

did you take a look into the PDK documentation? The "Window and Camera Services" could provide you with answers. I guess, you could implement your own version of IWindowPlugin on an IWindow, intercept the mouse click window messages and work from there. I don't know if there is an easier way for this, but this is what I'd try.

Greets, Benny

User avatar
Beau Hollis
Lockheed Martin
Posts: 1861
Joined: Wed Oct 06, 2010 3:25 pm

Re: Mouse click coords

Postby Beau Hollis » Fri Dec 07, 2018 3:29 am

There is a picking sample in the PDK. That's a good place to start. You can request custom pick points, or you can get the result of the mouse pick done by the app by using pick id 0.
http://www.prepar3d.com/SDKv4/sdk/pdk_a ... 9452aa61e0

The PickResult sctruct gives you the location, distance, and mouse message id associated with the pick. We use the PDK for the VR mouse cursor emulation, and custom pick requests for the new gaze selection capability. There are convenient functions for converting between ScreenCoord and LLADegreesMeters. If you need to offset relative to the pick location or get that point relative to the user aircraft, you can use the ApplyBodyRelativeOffset and CalculateBodyRelativeOffset functions.
http://www.prepar3d.com/SDKv4/sdk/pdk_a ... 01f576c9bf

If you want to get the input messages directly, you can register a WindowPlugin and handle the OnUserInput callback.
http://www.prepar3d.com/SDKv4/sdk/pdk_a ... bebcc4a096

For panels and gauges, there a number of ways to handle mouse input using C++, XML, and Scaleform.

Thanks
Beau Hollis
Prepar3D Software Architect

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Re: Mouse click coords

Postby JeeHell » Fri Dec 07, 2018 2:46 pm

Hello Beau, BenBaron,

thanks to both of you for the answer.

I tried the PickResult route, with the Pick ID=0. But my GetPickResults always return with a distance of 0.0 meters, so this is not pointing to the correct world pick location, but only at my own position (offset by the X,Y pixels....). Any idea?

User avatar
Beau Hollis
Lockheed Martin
Posts: 1861
Joined: Wed Oct 06, 2010 3:25 pm

Re: Mouse click coords

Postby Beau Hollis » Sat Dec 08, 2018 2:24 am

Are you in the VC? We have some other functions for doing a ray cast into the terrain and objects. The pick result will typically only get filled with distance info if you hit something in the VC.
Beau Hollis
Prepar3D Software Architect

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Re: Mouse click coords

Postby JeeHell » Sat Dec 08, 2018 7:17 am

Not necessarily in VC since I need to find the terrain location picked.

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Re: Mouse click coords

Postby JeeHell » Mon Dec 10, 2018 2:33 pm

I am trying to use the Iraytracemanager.
I cannot find much info in the PDK documentation. I suppose there is a way from the view matrix to find the unit vector I need?

User avatar
Beau Hollis
Lockheed Martin
Posts: 1861
Joined: Wed Oct 06, 2010 3:25 pm

Re: Mouse click coords

Postby Beau Hollis » Tue Dec 11, 2018 3:44 am

Yes. I think grabbing the 3rd row from the view matrix would probably do the trick. You could grab the pitch and heading of the camera and calculate it. You could also apply a 0 0 1 xyz body relative offset then zero out the pbh of the camera location and calculate the body relative offset from it to the other point.
Beau Hollis
Prepar3D Software Architect

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Re: Mouse click coords

Postby JeeHell » Tue Dec 11, 2018 10:50 pm

Hello Beau,

I am having issues with RayTraceManager.
I tried this code:
//global variable
CComPtr<IRayTraceManagerV340> spRayTraceMgr; //Smart pointer reference to RayTraceManager
//....


//at DLL start:
//...
pPdk->QueryService(SID_RayTraceManager, IID_IRayTraceManagerV340, (void**)&spRayTraceMgr);
//...

//in a window plugin callback :
CComPtr<ICameraSystemV440> mcam440;
//...
DXYZ vWorldRadiansFeet;
DXYZ xyzWorldUnitRayDir;
DXYZ xyzWorldRes;
UINT ResObjID;
DWORD interrogRes;

mcam440->GetLLARadians(vWorldRadiansFeet.dZ, vWorldRadiansFeet.dX, vWorldRadiansFeet.dY);

xyzWorldUnitRayDir.dX = 0;
xyzWorldUnitRayDir.dZ = 0;
xyzWorldUnitRayDir.dY = 1;

spRayTraceMgr->InterrogateWorldRay(
INTEROGATIONTYPE_TERRAIN,
0,
vWorldRadiansFeet,
xyzWorldUnitRayDir,
5000.0f,
0.2f,
&ResObjID,
&xyzWorldRes,
interrogRes
);
However, no matter what values I put in the unit vector xyzWorldUnitRayDir, I get results which are very very close to the camera view LAT/LON/altitude.
I tried in all kind of views (virtual cockpit, outside view...). Is there a known issue with this function?

User avatar
Beau Hollis
Lockheed Martin
Posts: 1861
Joined: Wed Oct 06, 2010 3:25 pm

Re: Mouse click coords

Postby Beau Hollis » Wed Dec 12, 2018 1:46 am

You might be hitting the aircraft itself. I believe you can pass in an object id to exclude it.
Beau Hollis
Prepar3D Software Architect

JeeHell
Posts: 71
Joined: Sun Jan 15, 2012 11:04 pm

Re: Mouse click coords

Postby JeeHell » Fri Dec 14, 2018 8:34 am

Ok so I have been playing with the ray casting, and got it to work with a workaround.
The only way to make that work was to offset(by a very small distance such as 0.000001m) the LLA of the cast source to another position than the camera LLA itself, otherwise it would always hit something located on the same plane as the camera.
Even using the exclude ObjectID did not work (I tried many things...). So I think there is very probably an issue there.

On another note, using topdown view the GetFOV call returns bad data. I initially thought you were using an orthographic projection which would have made the FOVs undefined, but then the projection matrix still looked like a perspective matrix. I derived FOVs using that matrix, and I could compute correct FOVs.


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 4 guests