Page 1 of 1

[RESOLVED] Mouse click coords

Posted: Thu Dec 06, 2018 10:40 pm
by JeeHell

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.

Jean Luc

Re: Mouse click coords

Posted: Thu Dec 06, 2018 11:46 pm
by BenBaron
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

Re: Mouse click coords

Posted: Fri Dec 07, 2018 3:29 am
by Beau Hollis
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. ... 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. ... 01f576c9bf

If you want to get the input messages directly, you can register a WindowPlugin and handle the OnUserInput callback. ... bebcc4a096

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


Re: Mouse click coords

Posted: Fri Dec 07, 2018 2:46 pm
by JeeHell
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?

Re: Mouse click coords

Posted: Sat Dec 08, 2018 2:24 am
by Beau Hollis
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.

Re: Mouse click coords

Posted: Sat Dec 08, 2018 7:17 am
by JeeHell
Not necessarily in VC since I need to find the terrain location picked.

Re: Mouse click coords

Posted: Mon Dec 10, 2018 2:33 pm
by JeeHell
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?

Re: Mouse click coords

Posted: Tue Dec 11, 2018 3:44 am
by Beau Hollis
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.

Re: Mouse click coords

Posted: Tue Dec 11, 2018 10:50 pm
by JeeHell
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;
DWORD interrogRes;

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

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

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?

Re: Mouse click coords

Posted: Wed Dec 12, 2018 1:46 am
by Beau Hollis
You might be hitting the aircraft itself. I believe you can pass in an object id to exclude it.

Re: Mouse click coords

Posted: Fri Dec 14, 2018 8:34 am
by JeeHell
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.