在第一个int处有问题,且提示“应为get或set访问器”求大神解
namespace WindowsFormsApplication1{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static TriMesh CreateSphere
{
int n=50;
TriMesh Shape =new TriMesh();
for (int j=-n/2;j<n/2;j++)
{
double distance =Math.Sin (j*Math.PI/n);
double r_circle=Math.cos (j*Math.PI/n);
for (int i=0;i<n;i++)
{
Shape.Vertices.Add(new VertexTraits(r_circle*Math.Cos(2*i*Math.PI/n),
r_circle*Math.Sin (2*i*Math.PI/n),distance));
}
}
for (int i=0;i<n-1;i++)
{
for (int j=0;j<n;j++)
{
TriMesh.Vertex topRight=Shape.Vertices[i*n+j];
TriMesh.Vertex topLeft=Shape.Vertices[i*n+(j+1)%n];
TriMesh.Vertex bottomRight=Shape.Vertices[(i+1)*n+j];
TriMesh.Vertex bottomLeft=Shape.Vertices[(i+1)*n+(j+1)%n];
Shape.Faces.AddTriangles(topRight,bottomLeft,bottomRight);
Shape.Faces.AddTriangles(topRight,topLeft,bottomLeft);
}
}
TriMesh.Vertex tv=Shape.Vertices.Add(new VertexTraits(0,0,1));
TriMesh.Vertex bv=Shape.Vertices.Add(new VertexTraits(0,0,0));
int last=Shape.Vertices.Count-1;
for (int i=0;i<n;i++)
{
Shape.Faces.AddTriangles(tv,Shape.Vertices[(i+1)%n],Shape.Vertices[i]);
Shape.Faces.AddTriangles(bv,Shape.Vertices[last-(i+1)%n],Shape.Vertices[last-i]);
}
reture Shape
}
}
}