开发者

Simple 3D Graphics in C#

I'm currently working on开发者_JS百科 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. 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜