Skip to content

Picking

Chuck Walbourn edited this page Apr 26, 2022 · 8 revisions
Getting Started for DX11 Getting Started for DX12

This lesson covers performing picking in 3D.

Ray casting

You can find an older tutorial on 3D picking using ray/object tests at Rastertek that uses the deprecated D3DXMath library. Note that instead of a 'roll your own' RaySphereIntersect you can use BoundingSphere from DirectXCollision.h with the following method to do the ray-sphere test:

bool Intersects(FXMVECTOR Origin, FXMVECTOR Direction, float& Dist) const;

Also remember that the default view coordinates for DirectX Tool Kit is "right-handed" viewing coordinates and the Rastertek tutorials follow the older DirectX style of "left-handed" viewing coordinates. This requires reversing the Z direction of the ray.

You can also review the Direct3D 10 era "picking" sample from the legacy DirectX SDK.

Next lesson: Mixing SimpleMath and DirectXMath

Further reading

DirectMath Programmer's Guide
DirectXMath Collision sample for Win32, UWP, XDK, GDK

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXTex

DirectXMath

Win2D

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

Clone this wiki locally