I would like to do something like this: a rotating cube on a form. I don't want to use any external library or dll, just pure .NET 3.5 (without directx). And a cube build with lines only. Could you please tell me how to do this?
我想做这样的事情:表格上的旋转立方体。我不想使用任何外部库或DLL,只是纯.NET 3.5(没有directx)。并且仅使用线条构建立方体。你能告诉我怎么做吗?
I don't want to use external libraries because I don't need > 100 MB library to do this thing right? I want only to animate a rotating cube made with lines.
我不想使用外部库,因为我不需要> 100 MB的库来做这件事吗?我只想动画一个用线条制作的旋转立方体。
6 个解决方案
#1
5
This is how you go about making a Cube in GDI+
这就是你如何在GDI +中制作立方体
C# 3D Drawing with GDI+ Euler Rotation
使用GDI + Euler旋转的C#3D绘图
http://www.vcskicks.com/3d-graphics-improved.html
C# 3D-Drawing Cube with Shading
具有着色的C#3D绘图立方体
#2
4
Study assignment? This can be done with some simple 3D maths. You just need to understand the basics of matrix algebra, 3D transformations, and 3D->2D view transformation. The DirectX tutorial covers this, but you can google for it and you'll get plenty of other tutorials.
学习作业?这可以通过一些简单的3D数学来完成。您只需要了解矩阵代数,3D变换和3D-> 2D视图变换的基础知识。 DirectX教程涵盖了这一点,但您可以谷歌搜索它,您将获得大量其他教程。
Added: Just to clarify - I'm not suggesting to use DirectX or anything. You can do this with standard System.Drawing tools. You just need to understand the math, and that's explained in the DirectX tutorials.
补充:只是为了澄清 - 我不建议使用DirectX或任何东西。您可以使用标准的System.Drawing工具执行此操作。您只需要了解数学,并在DirectX教程中进行了解释。
#3
0
You might try using WPF and the 3D Tools source code released by the WPF team.
您可以尝试使用WPF和WPF团队发布的3D Tools源代码。
#4
0
Assuming you are using WPF for your GUI:
假设您使用WPF作为GUI:
- Make an animated PNG of the cube using a graphics program.
- Use the APNG WPF Control to insert the image into your GUI.
使用图形程序制作立方体的动画PNG。
使用APNG WPF Control将图像插入GUI。
This will yield a small assembly size and transparent background if needed.
如果需要,这将产生小的装配尺寸和透明背景。
#5
0
You need a way to represent 3d points. There is no ready struct for that in .NET unless you use directx or WPF.
你需要一种表示3d点的方法。除非使用directx或WPF,否则.NET中没有现成的结构。
Then with a standard euler rotation matrix applied to the points you get the transformed points. If you only do rotations you can get away with 3x3 matrix, but if you want translation you better use 4x4 matrices and homogenous points.
然后使用标准的euler旋转矩阵应用于点,您将获得变换点。如果你只进行旋转,你可以使用3x3矩阵,但如果你想要翻译,你最好使用4x4矩阵和同质点。
After this you need a way to project those 3d points to the 2d canvas. Depending whether you are using perspective or orthographic projection the projection matrix will look a bit different.
在此之后,您需要一种方法将这些3d点投影到2D画布。根据您是使用透视投影还是正交投影,投影矩阵看起来会有所不同。
#6
-1
Look into WPF in general, it will help you do this with a few measly lines of code. You can also host a WPF window in Forms.
一般来说,查看WPF,它将帮助您使用一些可疑的代码行来完成此操作。您还可以在Forms中托管WPF窗口。
#1
5
This is how you go about making a Cube in GDI+
这就是你如何在GDI +中制作立方体
C# 3D Drawing with GDI+ Euler Rotation
使用GDI + Euler旋转的C#3D绘图
http://www.vcskicks.com/3d-graphics-improved.html
C# 3D-Drawing Cube with Shading
具有着色的C#3D绘图立方体
#2
4
Study assignment? This can be done with some simple 3D maths. You just need to understand the basics of matrix algebra, 3D transformations, and 3D->2D view transformation. The DirectX tutorial covers this, but you can google for it and you'll get plenty of other tutorials.
学习作业?这可以通过一些简单的3D数学来完成。您只需要了解矩阵代数,3D变换和3D-> 2D视图变换的基础知识。 DirectX教程涵盖了这一点,但您可以谷歌搜索它,您将获得大量其他教程。
Added: Just to clarify - I'm not suggesting to use DirectX or anything. You can do this with standard System.Drawing tools. You just need to understand the math, and that's explained in the DirectX tutorials.
补充:只是为了澄清 - 我不建议使用DirectX或任何东西。您可以使用标准的System.Drawing工具执行此操作。您只需要了解数学,并在DirectX教程中进行了解释。
#3
0
You might try using WPF and the 3D Tools source code released by the WPF team.
您可以尝试使用WPF和WPF团队发布的3D Tools源代码。
#4
0
Assuming you are using WPF for your GUI:
假设您使用WPF作为GUI:
- Make an animated PNG of the cube using a graphics program.
- Use the APNG WPF Control to insert the image into your GUI.
使用图形程序制作立方体的动画PNG。
使用APNG WPF Control将图像插入GUI。
This will yield a small assembly size and transparent background if needed.
如果需要,这将产生小的装配尺寸和透明背景。
#5
0
You need a way to represent 3d points. There is no ready struct for that in .NET unless you use directx or WPF.
你需要一种表示3d点的方法。除非使用directx或WPF,否则.NET中没有现成的结构。
Then with a standard euler rotation matrix applied to the points you get the transformed points. If you only do rotations you can get away with 3x3 matrix, but if you want translation you better use 4x4 matrices and homogenous points.
然后使用标准的euler旋转矩阵应用于点,您将获得变换点。如果你只进行旋转,你可以使用3x3矩阵,但如果你想要翻译,你最好使用4x4矩阵和同质点。
After this you need a way to project those 3d points to the 2d canvas. Depending whether you are using perspective or orthographic projection the projection matrix will look a bit different.
在此之后,您需要一种方法将这些3d点投影到2D画布。根据您是使用透视投影还是正交投影,投影矩阵看起来会有所不同。
#6
-1
Look into WPF in general, it will help you do this with a few measly lines of code. You can also host a WPF window in Forms.
一般来说,查看WPF,它将帮助您使用一些可疑的代码行来完成此操作。您还可以在Forms中托管WPF窗口。