【发布时间】:2011-12-31 15:56:49
【问题描述】:
我对 C# 中的数组有疑问。我是 C# 的新手,我习惯用 java 做程序。 我正在尝试将此代码从 C++ 传输到 C#。 这是 C++ 中的代码
typedef struct point_3d { // Structure for a 3-dimensional point (NEW)
double x, y, z;
} POINT_3D;
typedef struct bpatch { // Structure for a 3rd degree bezier patch (NEW)
POINT_3D anchors[4][4]; // 4x4 grid of anchor points
GLuint dlBPatch; // Display List for Bezier Patch
GLuint texture; // Texture for the patch
} BEZIER_PATCH;
我在 C# 中有 struct Vector3,它是 float x,y,z(我不需要 double ...) 现在我正在尝试制作结构 bpatch,但我在声明数组时遇到了问题
[StructLayout(LayoutKind.Sequential)]
struct BPatch
{
Vector3[][] anchors = new Vector3[4][4]; //there is the problem
uint dblPatch; // I'll probably have to change this two lines but it doesn't matter now
uint texture;
}
我做错了什么??我需要一个4x4的结构,它的类型应该是结构Vector3,它被声明为float x,float y,float z。 谢谢
【问题讨论】:
-
是什么让您认为 C++
POINT_3D转换为 .NETVector3? -
为什么不呢?我根据 NEHE nehe.gamedev.net/tutorial/bezier_patches__fullscreen_fix/18003 的本教程工作,point3D 具有坐标 x、y、z 和我提到的 Vector3 已准备好在图书馆中使用,这使我们在大学时给了我们老师,还有操作 add 和其他......所以我用它。
标签: .net visual-studio c#-4.0