简体   繁体   English

DirectX 11-项目符号调试图

[英]DirectX 11 - Bullet Debug Draw

I am using Bullet Physics in my own DirectX 11 Game Engine and i want to use the debug draw class provided by bullet. 我在自己的DirectX 11游戏引擎中使用Bullet Physics,并且我想使用bullet提供的调试绘图类。 Basicly you are creating a class, that receives all the lines that should be drawn by bullet. 基本上,您正在创建一个类,该类接收应由bullet绘制的所有线条。 Is there an easy and fast way to just draw a 3D Line in DirectX 11 (preferably without using buffers and shaders and all that stuff)? 是否有一种简单快捷的方法来在DirectX 11中绘制3D线(最好不使用缓冲区和着色器以及所有其他东西)?

Unfortunately, there is no easy way. 不幸的是,没有简单的方法。 You need to create a vertex buffer with the line points. 您需要使用线点创建顶点缓冲区。 If you want to draw multiple lines, put all your vertices in one buffer to optimize for performance. 如果要绘制多条线,请将所有顶点放在一个缓冲区中以优化性能。

Because the FFP has been removed in DirectX 10, you need a simple shader. 由于FFP已在DirectX 10中删除,因此您需要一个简单的着色器。 The vertex shader probably just transforms the vertices with view and projection transform and the pixel shader returns a constant color (depending on your needs). 顶点着色器可能只是通过视图和投影变换来变换顶点,而像素着色器将返回恒定的颜色(取决于您的需求)。

You would then draw the vertex buffer with an appropriate topology (line list). 然后,您将使用适当的拓扑(线列表)绘制顶点缓冲区。

The reason why there are no easy methods (like Jesus Ramos' answer or OpenGL's glBegin(GL_LINES) ) is that they cannot be implemented efficiently. 之所以没有简单的方法(例如Jesus Ramos的答案或OpenGL的glBegin(GL_LINES) ),是因为它们无法有效实施。 It is always necessary to transfer more data to the GPU than needed. 总是有必要将比所需更多的数据传输到GPU。 That's why it's up to the programmer to write efficient code using buffers. 这就是程序员决定使用缓冲区编写高效代码的原因。

Use LP3DXLINE and call D3DXCreateLine to draw a simple line. 使用LP3DXLINE并调用D3DXCreateLine绘制一条简单的线。 Calling Draw with an array of length 2 (start, end) for your line and it should work. 为您的线调用长度为2(开始,结束)的数组的Draw ,它应该可以工作。

EDIT: This is apparently only DX9. 编辑:这显然只是DX9。 Leaving answer here just in case it helps someone else. 在这里留下答案,以防万一对别人有帮助。

在发光的线框中使用三角形并使两个顶点在相同位置的任何机会:x1y1z1,x2y2z2,x2y2z2我在DBPro中做到了,并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM