我正在将一个大型XNA项目移植到Unity项目中。我没有写XNA项目,也没有任何背景。移植进行得很顺利,直到我碰到一个用来画几何图形的零件。如下所示:
using (VertexDeclaration vertexdecl =
new VertexDeclaration(GraphicsDevice,
VertexPositionNormalTexture.
VertexElements))
{
GraphicsDevice.VertexDeclaration = vertexdecl;
GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, verticesArray, 0, 2);
}
这个
verticesArray
VertexPositionNormalTexture
结构和初始化如下:
VertexPositionNormalTexture[] verticesArray;
private void InitGeometry()
{
verticesArray = new VertexPositionNormalTexture[6];
verticesArray[0] = new VertexPositionNormalTexture( new Vector3(-20,0,0),
-Vector3.UnitZ,
new Vector2(0,0));
verticesArray[1] = new VertexPositionNormalTexture( new Vector3(20,10,0),
-Vector3.UnitZ,
new Vector2(13,12));
verticesArray[2] = new VertexPositionNormalTexture( new Vector3(-5, 20, 0),
-Vector3.UnitZ,
new Vector2(0, 1));
verticesArray[3] = verticesArray[0];
verticesArray[4] = new VertexPositionNormalTexture( new Vector3(5, 0, 0),
-Vector3.UnitZ,
new Vector2(3, 0));
verticesArray[5] = verticesArray[1];
}
我可以重新创造
GraphicsDevice.DrawUserPrimitives
如上所述。
我发现的最接近的统一函数是
Graphics.DrawMesh
但它只能画画
Mesh
,统一的
函数没有
PrimitiveType.TriangleList
也许我错过了,但是在Unity中有没有类似的函数来画
顶点曝光法线纹理
struct