DrawIndexedPrimitive和D3DXIntersect。搭配使用的问题。
2012-01-19 14:29
190 查看
shader版龙书第20章,射线与三角形相交,作者为了显示相交,会对点击到的三角形进行单独Solid渲染一次,而整体用Wireframe渲染。
对于D3DXIntersect函数用来检测射线和网格的相交情况。
它有个参数,FaceIndex:
[out] Pointer to an index value of the face closest to the ray origin
(指向最靠近射线起源的面(三角形)索引值。)
作者从网格得到顶点缓冲,索引缓冲,准备渲染。样式为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, pMesh->GetNumVertices(), FaceIndex*3, 1);
该方法有个争议参数,NumVertices;
NumVertices[in] Number of vertices used during this call. The first vertex is located at index: BaseVertexIndex + MinIndex.
(在调用期间要使用的顶点数。第一个顶点是基于:BaseVertexIndex+MinIndex)
我在仿写作者的DEMO时,写的为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3, FaceIndex*3, 1);
因为要只会显示一个三角形,所以,我将NumVertices设为3;
结果,是渲染不出。
如果将争议参数NumVertiecs设置为整个网格的顶点数-》pMesh->GetNumVertices();
结果,可以渲染。
可见,该参数不是SDK中描述的那样。
。。。。。
按照参数描述我的理解又为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3, pMesh->GetNumVertices(), 1);
结果,渲染和点击是不统一的。这不对。
为什么FaceIndex要乘上3呢?
对于D3DXIntersect函数用来检测射线和网格的相交情况。
它有个参数,FaceIndex:
[out] Pointer to an index value of the face closest to the ray origin
(指向最靠近射线起源的面(三角形)索引值。)
作者从网格得到顶点缓冲,索引缓冲,准备渲染。样式为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, pMesh->GetNumVertices(), FaceIndex*3, 1);
该方法有个争议参数,NumVertices;
NumVertices[in] Number of vertices used during this call. The first vertex is located at index: BaseVertexIndex + MinIndex.
(在调用期间要使用的顶点数。第一个顶点是基于:BaseVertexIndex+MinIndex)
我在仿写作者的DEMO时,写的为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3, FaceIndex*3, 1);
因为要只会显示一个三角形,所以,我将NumVertices设为3;
结果,是渲染不出。
如果将争议参数NumVertiecs设置为整个网格的顶点数-》pMesh->GetNumVertices();
结果,可以渲染。
可见,该参数不是SDK中描述的那样。
。。。。。
按照参数描述我的理解又为:
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3, pMesh->GetNumVertices(), 1);
结果,渲染和点击是不统一的。这不对。
为什么FaceIndex要乘上3呢?
相关文章推荐
- echarts2.0 时间轴搭配力导向图使用+时间轴数据覆盖问题的解决
- Flex开发ArcGIS问题集锦八:怎样使用DrawTool绘制工具
- DrawIndexedPrimitive()函数
- 硬件兼容性的陷阱,DrawIndexedPrimitiveUP的用法
- 值得注意的函数: DrawIndexedPrimitive
- 使用canvas.drawRoundRect()时,解决四个圆角的线比较粗的问题
- 安卓开发——问题:使用canvas.drawRoundRect()需要api21
- D3D描绘四边形的四种方法之DrawPrimitive、DrawIndexedPrimitive、DrawPrimitiveUP、DrawIndexedPrimitiveUP
- 硬件兼容性的陷阱,DrawIndexedPrimitiveUP的用法
- cocos2dx2.1版本中使用CCTextureAtlas drawQuads绘制问题
- webpy搭配wsgi使用session的问题
- 硬件兼容性的陷阱,DrawIndexedPrimitiveUP的用法
- DrawIndexedPrimitive()函数
- 关于解决caffe中draw_net无法使用的问题
- 硬件兼容性的陷阱,DrawIndexedPrimitiveUP的用法
- Android ActivityGroup和TabActivity搭配使用及遇到的一些问题
- 使用UnityVS1.8.2搭配VS2013进行Unity3D代码调试(下载+安装+使用+问题解决)
- 硬件兼容性的陷阱,DrawIndexedPrimitiveUP的用法
- 关于label标签搭配textarea使用的样式问题
- 解决Django和EasyUI搭配使用时出现的CSRF问题