C# .NET 的 3D 图形库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14987727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 13:40:48  来源:igfitidea点击:

3D graphics library for .NET

c#graphics3ddirectx

提问by Janman

I would like to learn to make simple 3D applications for Windows 7 / desktop. By that, I mean spheres, triangles or pixels moving around in 3D space. It does not have to be very complicated as of yet. For this, I would like to use C# language with .NET (Java/C++ is my second priority).

我想学习为 Windows 7 / 桌面制作简单的 3D 应用程序。我的意思是在 3D 空间中移动的球体、三角形或像素。到目前为止,它不必非常复杂。为此,我想在 .NET 中使用 C# 语言(Java/C++ 是我的第二优先事项)。

I know this has been asked many times around the internet, but I feel like many of the questions are outdated, many APIs deprecated and tutorials too old.

我知道这已经在互联网上被问过很多次了,但我觉得很多问题已经过时了,很多 API 被弃用了,教程也太旧了。

I was thinking about learning XNA, but then I learned that Microsoft does not plan to develop and support it anymore.SharpDX also seemed like a good way to go, but that seems to be aimed for Windows Store and Phone apps.

我想学习 XNA,但后来我了解到Microsoft 不再计划开发和支持它。SharpDX 似乎也是一个不错的选择,但这似乎是针对 Windows Store 和 Phone 应用程序的。

While looking on the internet, Managed DirectX seemed exactly what I was looking for (the syntax, the complexity), but again, that is way too deprecatedfor me to use.

在 Internet 上查看时,Managed DirectX 似乎正是我正在寻找的(语法、复杂性),但同样,这对我来说太不推荐使用了。

Can you please guide me what I should learn to create simple yet solid 3D applications?

你能指导我应该学习什么来创建简单而可靠的 3D 应用程序吗?

采纳答案by Daniel A.A. Pelsmaeker

Take a look at SlimDX. It's an open-source, free, managed library for DirectX (DirectX 11). Each release coincides with a DirectX release, so most of the time it's pretty up-to-date. I've used it and it was quite easy to get started. Here (scroll down)is a comparison with other possibilities you mentioned.

看看SlimDX。它是 DirectX (DirectX 11) 的开源、免费、托管库。每个版本都与 DirectX 版本同时发生,所以大多数时候它都是最新的。我用过它,而且很容易上手。这里(向下滚动)是与您提到的其他可能性的比较。

回答by zandi

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.

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

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.

否则,更精细的 3D 系统,例如 XNA,可能更合适。这将需要更多的设置工作,但可以为您提供更多控制权。

  1. Tutorial 1: Displaying a 3D Model on the Screen
  2. WPF
  3. XNA
  1. 教程 1:在屏幕上显示 3D 模型
  2. WPF
  3. 新华社

回答by ja72

In the OpenGL world I have been using OpenTK. I had to build on top of the existing code with C#to get to display flat geometrical objects without shading and realistic effects.

在 OpenGL 世界中,我一直在使用OpenTK。我必须在现有代码的基础上构建C#,才能在没有阴影和逼真效果的情况下显示平面几何对象。

Here is an example:

下面是一个例子:

render

使成为

Generated from the code:

从代码生成:

void InitModels()
{
    Scene.CoordinateSystem cs1 = new Scene.CoordinateSystem(world.Ground)
    {
        DrawSize = 1,
        Visible = false
    };
    Scene.CoordinateSystem cs2 = new Scene.CoordinateSystem(world.Ground, 0.6 * vec3.J)
    {
        DrawSize = 0.5,
        Orientation = rot3.RotateXDegrees(-15)
    };
    Scene.Cube cube = new Scene.Cube(cs1)
    {
        CubeSize = 0.5
    };
    cs2.AddPoint(new point3(vec3.O,1), Color.Firebrick, 15);
    var line = cs2.AddLine(new line3(-vec3.I, vec3.I), 20, Color.SlateGray, 2);
    line.SetPattern(0xFF0F, GeometryTest.Scene.Stripple.Scale2);

    cube.BindTexture(5, GeometryTest.Properties.Resources.julia, true);
    cube.AddText(3, "OpenTK 1.0", Color.DarkMagenta, 0.5f, 0.5f, 1.0f);

}