首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >DirectX9如何找到交点?

DirectX9如何找到交点?
EN

Stack Overflow用户
提问于 2013-04-03 17:27:53
回答 2查看 259关注 0票数 0

我用函数'D3DXIntersectTri‘找到了交点的距离。现在,使用距离值,我如何找到该点值?

IDE: Delphi - JEDI

语言:帕斯卡语

DirectX 9

编辑:实际上我有两个圆柱体,只想在三维中渲染相交的部分。请参见图像:

EN

回答 2

Stack Overflow用户

发布于 2013-04-03 23:05:38

MSDN article中所述,您可以使用重心坐标计算点:

代码语言:javascript
运行
复制
p = p1 + pU * (p2 - p1) + pV(p3 - p1)
票数 1
EN

Stack Overflow用户

发布于 2013-04-08 16:57:35

模板缓冲区的任务是渲染到屏幕的某些部分。除非你想从交叉点创建一个新的顶点缓冲区(这可以通过裁剪部分来创建,这并不容易),否则使用模具缓冲区会更有效。

模板缓冲区是保存整数值的缓冲区。您必须使用深度缓冲区创建它,并指定正确的格式(例如D24S8)。然后,您可以指定何时丢弃像素。想法是这样的:

代码语言:javascript
运行
复制
Clear stencil buffer to 0
Enable solid rendering
Enable stencil buffer
Set blend states to not draw anything (Souce: 0, Destination: 1)
Disable depth testing, enable backface culling
Set the following stencil states:
    CompareFunc to Always
    StencilRef to 1
    StencilWriteMask to 255
    StencilFail to Replace
    StencilPass to Replace
    //this will set value 1 to every pixel that will be drawn
Draw the first cylinder
Now set the following stencil states:
    CompareFunc to Equal
    StencilFail to Keep //this keeps the value where the stencil test fails
    StencilPass to Increment //this increments the value to 2 where stencil test passes
Draw the second cylinder
//Now there is a 2 in the stencil buffer where the cylinders intersect
Reset blend states
Reenable depth testing
Set StencilRef to 2 //render only pixels where stencil value == 2
Draw both cylinders

在最后一次渲染过程之前,可能需要将compare函数更改为GreaterEqual。如果像素重叠,则可能存在大于两个的值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15783579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档