Picking Sample

Related Links


The Camera Picking sample demonstrates how to access the Camera System within Prepar3D and do custom 3D picking. It also illustrates visualize the picking results using DirectX11 rendering

The source code for the sample can be found at:

<Prepar3D SDK Path>\PDK General Samples\MousePicking

About the Camera Picking Sample

The Camera Picking Sample is a somewhat advanced example that demonstrates both camera picking and custom rendering. This example demonstrates how to make picking requests on a window similar to those used by the core input system to map mouse input into the virtual cockpit. The result of these pick requests is then used to determine if an interactive element was hit and how far away from the camera it is. This hit data is then visualized using custom D3D11 rendering in an effect plugin. The camera's view and projection matrix are used to correlate the custom rendering with the cockpit.

Setting Up the Project

To build the project:

  1. Open the SDK Samples.sln found in the SDK at <Prepar3D SDK Path>\ with Visual Studio 2017.
  2. The <Prepar3D SDK Path>\Inc\PDK\ folder should already be set up in the project settings using relative paths. If this project folder is moved outside the SDK structure, the settings must be updated accordingly.
  3. Right-click on Solution. Select Build to begin building the Sample.

NOTE: Paths denoted with < > represent paths on your machine that may vary based on your installation. Please ensure you have input these paths correctly, as failure to do so may cause the build to fail.

Installing the Camera Picking Example

This section discusses installation of the Camera Picking Sample.

  1. Copy the MousePicking folder in the output directory to the "%USERPROFILE%\Prepar3D v4 Add-ons" directory.

  2. Run Prepar3D and verify the add-on is created at startup. If not, please refer to the Troubleshooting & Limitations section below.
If the MousePicking add-on has been properly added to Prepar3D, the plugin can be used in Prepar3D as follows:
  1. Switch to a virtual cockpit view
  2. Right click, select Custom Camera -> Save Location
  3. In the Manage Camera Views menu, enter a name such as "PickTest" in the Name field.
  4. In the Camera Effects section, click on the Effects drop-down
  5. Select MousePickingTest from the list
  6. Clack Add and then Save
  7. Right click, select Custom Camera -> PickTest (or whatever name was given to the custom camera)
There should be 4 colored squares that draw whenever the point they represent passes a VC picking hit test.

Troubleshooting & Limitations