我在透视投影中看到了远裁剪平面之外的对象 ,我认为这不是它应该如何工作的,所以有人可以解释一下为什么我在这个例子中看到远裁剪平面之外的对象,例如网格。
顺便说一句,正交投影效果很好
我从这个演示中清除了所有形状,并通过更改Luna Frank Shapes Demo中的以下代码添加了两个网格
void ShapesApp::BuildRenderItems()
{
auto gridRitem = std::make_unique<RenderItem>();
gridRitem->World = MathHelper::Identity4x4();
gridRitem->ObjCBIndex = 0;
gridRitem->Geo = mGeometries["shapeGeo"].get();
gridRitem->PrimitiveType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
gridRitem->IndexCount = gridRitem->Geo->DrawArgs["grid"].IndexCount;
gridRitem->StartIndexLocation = gridRitem->Geo->DrawArgs["grid"].StartIndexLocation;
gridRitem->BaseVertexLocation = gridRitem->Geo->DrawArgs["grid"].BaseVertexLocation;
mAllRitems.push_back(std::move(gridRitem));
gridRitem = std::make_unique<RenderItem>();
XMStoreFloat4x4(&gridRitem->World, XMMatrixTranslation(0,-1002,0)* XMMatrixRotationRollPitchYaw(1.5708, 0, 0));;
gridRitem->ObjCBIndex = 1;
gridRitem->Geo = mGeometries["shapeGeo"].get();
gridRitem->PrimitiveType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
gridRitem->IndexCount = gridRitem->Geo->DrawArgs["grid"].IndexCount;
gridRitem->StartIndexLocation = gridRitem->Geo->DrawArgs["grid"].StartIndexLocation;
gridRitem->BaseVertexLocation = gridRitem->Geo->DrawArgs["grid"].BaseVertexLocation;
mAllRitems.push_back(std::move(gridRitem));
gridRitem = std::make_unique<RenderItem>();
XMStoreFloat4x4(&gridRitem->World, XMMatrixTranslation(0, -1002, 0) * XMMatrixRotationRollPitchYaw(1.5708, 1.5708, 0));
gridRitem->ObjCBIndex = 2;
gridRitem->Geo = mGeometries["shapeGeo"].get();
gridRitem->PrimitiveType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
gridRitem->IndexCount = gridRitem->Geo->DrawArgs["grid"].IndexCount;
gridRitem->StartIndexLocation = gridRitem->Geo->DrawArgs["grid"].StartIndexLocation;
gridRitem->BaseVertexLocation = gridRitem->Geo->DrawArgs["grid"].BaseVertexLocation;
mAllRitems.push_back(std::move(gridRitem));
并更改网格大小
GeometryGenerator::MeshData grid = geoGen.CreateGrid(200.0f, 200.0f, 60, 40);
以及从调整大小开始的投影矩阵
XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f * MathHelper::Pi, AspectRatio(), .1f, 1000.f);
XMStoreFloat4x4(&mProj, P);
现在我仍然可以看到网格,即使它超出了远平面,即使远平面是 900,它仍然会出现在屏幕边缘的旋转中。所以我需要减少远平面或进一步移动网格,当我不断改变远平面的值时,我可以看到一个形状就像画笔一样,它隐藏了它之外的所有东西,但是随着相机旋转并且网格不再在它的后面,网格重新出现
这就是我所说的刷子的意思