DirectX 中是否有指定的 Ray 对象

Is there a specified Ray object in DirectX

本文关键字:Ray 对象 是否 DirectX      更新时间:2023-10-16

我在 DirectX 项目中使用光线拾取做一些工作,我只是想知道是否有实际的"射线"对象类型?(而不仅仅是存储方向/原点变量)

我知道我可以创造类似的东西

struct ray
{
    D3DXVECTOR3 direction
    D3DXVECTOR3 origin
};

但是有什么已经存在吗? 我目前在DX9工作,但我对新版本的DirectX的答案持开放态度。

与其

使用传统的 D3DXmath,不如考虑 DirectXMath,尽管该库也只采用原点位置和方向向量来表示BoundingSphereBoundingBoxBoundingOrientedBoxBoundingFrustum类和TriangleTests命名空间的射线

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

请参阅 MSDN 上的 DirectXMath 编程指南,尤其是使用 D3DXMath

您还可以在 DirectX 工具包中使用 SimpleMath 包装器,该工具包定义了Ray类。