C# 中的简单 3D 图形

发布于 2024-10-13 15:55:01 字数 138 浏览 4 评论 0原文

我目前正在开发一个需要进行一些可视化的应用程序,而我要做的最复杂的事情是显示点状对象。

除此之外的任何事情对于我的目的来说都是完全多余的,因为除了绘制点状物体之外我不会做任何事情。

话虽如此,满足我的需求的最简单的解决方案是什么?

I'm currently working on an application where I need to do some visualization, and the most complicated thing I'll be doing is displaying point-like objects.

Anything beyond that is complete overkill for my purposes, since I won't be doing anything but drawing point-like objects.

That being said, what would be the simplest solution to my needs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

扛起拖把扫天下 2024-10-20 15:55:01

最简单的可能是使用 WPF 3D。这是一个保留模式图形系统,因此如果您没有巨大的需求(即:用于效果的特殊着色器等),则非常容易直接设置和使用。

否则,更复杂的 3D 系统(例如 XNA)可能更合适。这将需要更多的设置工作,但会给您更多的控制权。

The simplest is probably to use WPF 3D. This is a retained mode graphics system, so if you don't have huge needs (ie: special shaders for effects, etc), it's very easy to setup and use directly.

Otherwise, a more elaborate 3D system, such as XNA, may be more appropriate. This will be more work to setup, but give you much more control.

っ〆星空下的拥抱 2024-10-20 15:55:01

我建议您查看 Microsoft XNA for C#

I recommend you take a look on Microsoft XNA for C#

欲拥i 2024-10-20 15:55:01

它们是被渲染为真实的点还是球体? (使用球体的可见尺寸作为参考,您会看到更接近的“点”。)在前一种情况下,我建议您自己简单地乘以适当的变换矩阵以将点投影到您的观察平面,而不是使用成熟的 3D 引擎(因为您没有渲染任何三角形或执行照明/着色)

有关 3D 投影到 2D 平面的一些理论背景,请参阅 这篇 Wiki 文章。如果您使用 XNA,它具有矩阵辅助函数,可以为您生成适当的变换矩阵,即使您不将其用于任何实际渲染。对于点来说,这个问题变得非常微不足道,因为没有法线需要考虑。您只需将组成的视图投影矩阵乘以每个点,裁剪位于视锥体之外的任何点(即在视平面后面、太远或在视口的 2d 范围之外)并在 X、Y 中渲染这些点。通过计算,您可以反馈每个点相对于您的观看平面的“深度”,因此您可以使用它来适当地缩放点或为点着色,否则很难快速理解点的 3D 位置。

Are they to be rendered as true points or as spheres? (where you see the 'points' that are closer using the visible size of the sphere as a reference.) In the former case, I would recommend simply multiplying the appropriate transformation matrices yourself to project the points to your viewing plane, rather than using a full-blown 3D engine (as you're not rendering any triangles or performing lighting/shading)

For some theoretical background on 3D projection to a 2D plane, see this Wiki article. If you use XNA, it has Matrix helper functions that generate the appropriate transformation matrices for you, even if you don't use it for any actual rendering. The problem becomes very trivial for points, as there are no normals to consider. You simply multiply the composed View Projection matrix by each point, clip any points that lie outside the viewing frustrum (i.e. behind the viewing plane, too far away, or outside the 2d range of your viewport) and render the points in X,Y. The calculation does you give feedback as to how 'deep' each point is relative to your viewing plane, so you could use this to scale or color the points appropriately, as otherwise it's very difficult to quickly understand the 3d placement of the points.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文