龙书D3D11章节习题答案(第五章)

这篇博客详细探讨了Direct3D 11中的视图变换和透视投影,包括第一人称摄像机的实现、金字塔的顶点和索引构造、视图矩阵的计算以及透视投影矩阵的推导。还讨论了不同场景下多边形失真的问题,并解答了一系列相关习题,深入理解3D图形编程的关键概念。
摘要由CSDN通过智能技术生成


以下答案仅供参考,有错欢迎留言。


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.

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值