顶部表示的 3d 图标与 c++ 中的直接 x 9
我正在做一个模拟器视觉效果,其中有很多代表模拟元素的 2D 图标,还有一个 3D(.x 用 Blender 制作)图标,它代表另一个更重要的元素。
我需要在其他 2d 图标 (.tga) 之上制作这个图标,但我找不到制作此图标的方法。 Direct x 是否可以在其余 2d 图标上绘制 3d 图标? 此时,2D 图标始终显示在 3D 之上。
请有人帮我解决这个问题。我正在用 C++ 编程 预先非常感谢。
I'm doing a simulator visual where I have a lot of 2D icons representing elements of the simulation and I have a 3D (.x made with Blender) icon which represents another and more important element.
I need to make this one on top of the other 2d icons (.tga) but I cannot find the way to make this. Is it possible for Direct x to draw a 3d icon over the rest of the 2d icons?.
At this moment, the 2D icons apear on top of the 3D, always.
Could please someone help me with this. I'm programming in C++
Thanks very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
渲染 2D 图标时禁用 Z 写入。当您在启用 Z 写入的情况下渲染 3D 图标时,它将渲染 2D 图标。
您目前的问题是,当您渲染 2D 图标时,您使用的是 z 值,该值是 z 缓冲区的前面(很可能为 0)。您可能还会发现可以将 z 值设置为 1(同样,这可能完全取决于您如何设置 2D 渲染)以强制 2d 图标在 z 缓冲区的后面渲染。
Z 缓冲区中的任何条目都等同于它位于 Z 顺序的后面。
Disable Z-writes when you render the 2D icons. When you then render the 3D icons with Z-writes enabled it will render OVER the 2D icons.
Your problem at present is that when you render the 2D icons you are doing so with a z value which is the front of the z-buffer (most probably 0). You may also find you can set the z-value to 1 (again this is probably, it entirely depends on how you've set up your 2D rendering) to force the 2d icons to render at the back of the z buffer.
No entry in the Z-buffer is equivalent to it being at the back of the Z-order.
假设您启用了深度缓冲,您需要确保图标的 Z 值距离相机比模型更远。如果您使用的是 ID3DXSprite,则应该能够在调用 Draw 函数时指定 Z 位置,或者使用 ID3DXSprite::SetTransform() 函数。
请注意,ID3DXSprite 可能会使用与模型不同的投影矩阵来绘制精灵,具体取决于传递给 ID3DXSprite::Begin() 的标志。您可能需要使用 D3DXSPRITE_OBJECTSPACE 标志。
Assuming you have depth buffering enabled, you need to ensure that the Z value of your icons is further from your camera than your model. If you are using ID3DXSprite, you should be able to specify the Z position when you call the Draw function, or by using the ID3DXSprite::SetTransform() function.
Note that ID3DXSprite may draw your sprites with a different projection matrix than your model, depending on the flags you pass to ID3DXSprite::Begin(). You might want to use the D3DXSPRITE_OBJECTSPACE flag.