简体   繁体   English

C#中的简单3D图形

[英]Simple 3D Graphics in C#

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? 话虽这么说,对我的需求最简单的解决方案是什么?

The simplest is probably to use WPF 3D . 最简单的方法可能是使用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. 否则,更复杂的3D系统(例如XNA )可能更合适。 This will be more work to setup, but give you much more control. 这将需要更多的工作来设置,但可以给您更多的控制权。

我建议您看看C#的Microsoft XNA

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) (在此情况下,您可以使用球体的可见大小作为参考来查看更接近的“点”。)在前一种情况下,我建议您自己简单地乘以适当的变换矩阵,即可将这些点投影到您的观察平面上,而不是使用完善的3D引擎(因为您不渲染任何三角形或执行照明/着色)

For some theoretical background on 3D projection to a 2D plane, see this Wiki article . 有关将3D投影到2D平面的一些理论背景,请参阅此Wiki文章 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. 如果您使用XNA,则它具有Matrix帮助器函数,即使您没有将其用于任何实际渲染,该函数也可以为您生成适当的转换矩阵。 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 (ie behind the viewing plane, too far away, or outside the 2d range of your viewport) and render the points in X,Y. 您只需将组成的View Projection矩阵乘以每个点,剪切位于视锥范围之外(即,在视平面后面,太远或在视口的2d范围之外)的所有点,然后将点渲染为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. 该计算是否会反馈每个点相对于您的观察平面的“深度”,因此您可以使用它适当地缩放或着色这些点,否则很难快速理解这些点的3d位置。

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

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