大家好,我正处于一个真正的绑定中,我目前正在使用 Frank d Luna http://www.d3dcoder.net/d3d11.htm使用 DirectX11 进行 3d 游戏编程中的 directx11 教程 Shapes 示例,我目前正在尝试添加一个我可以独立于第一个立方体放置的第二个立方体,我创建了它,当我构建项目时,两个立方体现在都消失了,我认为问题出在几何生成器上。
请帮忙 :(
void ShapesApp::BuildGeometryBuffers()
{ GeometryGenerator::MeshData 框;
//added
GeometryGenerator::MeshData boxtwo;
GeometryGenerator::MeshData grid;
GeometryGenerator::MeshData sphere;
GeometryGenerator::MeshData cylinder;
GeometryGenerator geoGen;
geoGen.CreateBox(1.0f, 1.0f, 1.0f, box);
geoGen.CreateBox(1.0f, 1.0f, 1.0f, boxtwo);
geoGen.CreateGrid(20.0f, 30.0f, 60, 40, grid);
geoGen.CreateSphere(0.5f, 20, 20, sphere);
//geoGen.CreateGeosphere(0.5f, 2, sphere);
geoGen.CreateCylinder(0.5f, 0.3f, 3.0f, 20, 20, cylinder);
// Cache the vertex offsets to each object in the concatenated vertex buffer.
//added
mBoxVertexOffset = 0;
mBoxtwoVertexOffset = box.Vertices.size();
mGridVertexOffset = mBoxtwoVertexOffset + boxtwo.Vertices.size();
mSphereVertexOffset = mGridVertexOffset + grid.Vertices.size();
mCylinderVertexOffset = mSphereVertexOffset + sphere.Vertices.size();
// Cache the index count of each object.
mBoxIndexCount = box.Indices.size();
//added
mBoxtwoIndexCount = boxtwo.Indices.size();
mGridIndexCount = grid.Indices.size();
mSphereIndexCount = sphere.Indices.size();
mCylinderIndexCount = cylinder.Indices.size();
// Cache the starting index for each object in the concatenated index buffer.
mBoxIndexOffset = 0;
//added
mBoxtwoIndexOffset = mBoxIndexCount;
mGridIndexOffset = mBoxtwoIndexOffset + mBoxtwoIndexCount;
mSphereIndexOffset = mGridIndexOffset + mGridIndexCount;
mCylinderIndexOffset = mSphereIndexOffset + mSphereIndexCount;
UINT totalVertexCount =
box.Vertices.size() +
//added
boxtwo.Vertices.size() +
grid.Vertices.size() +
sphere.Vertices.size() +
cylinder.Vertices.size();
UINT totalIndexCount =
mBoxIndexCount +
//added
mBoxtwoIndexCount +
mGridIndexCount +
mSphereIndexCount +
mCylinderIndexCount;