The idea is to draw the bounding box as 2D corners on the screen after my DiretXTK model is displayed.
I got the bounding box corners form DirectXKT in a std::vector<DirectX::SimpleMath::Vector3>
, so
auto mf = m_world * m_view * m_proj;
D3D11_VIEWPORT vp;
UINT j = 1;
ctx->RSGetViewports(&j,&vp);
for (auto& c : corners)
{
DirectX::SimpleMath::Vector3 ft = DirectX::XMVector3Transform(c, mf);
float scalex = vp.Width / 2;
float scaley = vp.Height / 2;
float screenx = ft.x * scalex;
float screeny = ft.y * scaley;
}
These coordinates are invalid, something wrong I'm doing in the transforming the XYZ of each corner to the screen projection.
Thanks a lot for your help.
In the DirectX Tool Kit wiki, I have a
DebugDraw
helper which is specifically designed for drawing DirectXMath bounding volumes using DirectX Tool Kit'sPrimitiveBatch
.See this topic page.