0

这个想法是在显示我的DiretXTK模型后将边界框绘制为屏幕上的 2D 角。

我从 DirectXKT 中得到了边界框角std::vector<DirectX::SimpleMath::Vector3>,所以

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;

}

这些坐标无效,我在将每个角的 XYZ 转换为屏幕投影时做错了。

非常感谢你的帮助。

4

1 回答 1

1

DirectX Tool Kit wiki中,我有一个DebugDraw专门为使用DirectX Tool Kit 的 PrimitiveBatch.

请参阅此主题页面

您可能还想查看Collision示例。

于 2021-06-06T19:15:16.157 回答