Im doing some work using ray-picking in a DirectX project and I just wondered whether there was an actual 'ray' object type? (rather than just storing direction/origin variables)
I know I could create something like
struct ray
{
D3DXVECTOR3 direction
D3DXVECTOR3 origin
};
but does anything already exist? Im currently working in DX9 but I am open to answers in newer versions of DirectX.
Rather than use legacy D3DXmath, you should consider DirectXMath, although that library also just takes an origin position and a direction vector to represent a ray for the
BoundingSphere,BoundingBox,BoundingOrientedBox, andBoundingFrustumclasses and theTriangleTestsnamespaceSee the DirectXMath Programming Guide on MSDN, particularly Working with D3DXMath
You can also use the SimpleMath wrapper in DirectX Tool Kit, which has a
Rayclass defined.