本文主要是介绍龙书D3D11章节习题答案(第五章),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
以下答案仅供参考,有错欢迎留言。
Chapter 5:The Rendering Pipeline
1. Construct the vertex and index list of a pyramid(金字塔), as shown in Figure 5.35(即下图).
Vertex pyramid[5] = {v0, v1, v2, v3, v4, v5};
// 注意要从面的outside看向inside,然后按照顺时针绕序,如下
UINT indexList[6] = { 0, 1, 4,
0, 3, 2,
0, 4, 3,
0, 2, 1,
3, 4, 1,
3, 1, 2};
这里我用dx9绘制了一下来验证结果:
1.为了方便观察金字塔全貌,让绘制出的金字塔绕x轴向上翻转45°,并绕y轴不停旋转。
2.设置CULLMODE为D3DCULL_NONE,观察到所有顶点及其连线。
理由:默认的背面剔除方式是剔除逆时针绕序的三角形,即D3DCULL_CCW (Couter-Clock-Wise)。
而在这种方式下,因为旋转中的金字塔底部对于我们的视角(摄像机镜头)来说,一会是正面(绘制)一会是反面(不绘制)。
2. Consider the two shapes shown in Figure 5.36(即下图). Merge the objects into one vertex and index list. (The idea here is that when you append the 2nd index list to the first, you will need to update the appended indices since they reference vertices in the original vertex list, not the merged vertex list.)
这道题的意思似乎是把绘制a和b所用到的vertex list和index list合起来写。。定义v0,v1,...,v12,v13,慢慢写索引不就行了。。也许是我没悟到题目的意思...
更新:作者的意思其实是将多个vertex list和index list合并vertex list都写在vertex buffer里,index list都写在index buffer里, 对于新的vertex list,vertexList1从0开始计数,vertexList2从0+vertexList1.size()开始计数,vertexList3从0+vertexList1.size()+vertexList2.size()开始计数......以此类推。相应地对于新的index list,由于对应的vertex list现在发生了改变,原索引值也需要加上一个偏移量。IndexList1不变,IndexList2需要为每个索引值加上vertexList1.size()来得到原顶点。这些是新的List的改动。。在绘制的时候,比如DrawIndexed,那么还需要给出每个绘制对象的Index开始位置,那么就需要从0,0+IndexList1.size(),0+IndexList1.size()+IndexList2.size()...累计,具体代码在第六章有,这里就只说个大概。
3. Relative to the world coordinate system, suppose that the camera is positioned at (−20, 35, −50) and looking at the point (10, 0, 30). Compute the view matrix assuming (0, 1, 0) describes the “up” direction in the world.
这篇关于龙书D3D11章节习题答案(第五章)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!