8 Picking
Chuck Walbourn редактировал(а) эту страницу 2022-04-26 16:45:12 -07:00
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