注册 登录
编程论坛 C图形专区

在第一个int处有问题,且提示“应为get或set访问器”求大神解

代码狗 发布于 2015-01-15 22:56, 849 次点击
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
}
          }
}
4 回复
#2
代码狗2015-01-17 10:05
应该在createsphere后加(),查了很多资料了解到的
#3
砖家的谎言2015-01-17 15:45
顶下帖子,虽然这个问题我不会。
#4
唯风相随2015-04-13 10:17
public   static TriMesh CreateSphere后加(),它需要一个返回值。
#5
自傲2015-06-17 12:21
不会,也添点人气
1