Mesh MakeMeshPot(Point3Ds ps) { Mesh mesh = new Mesh(); Double[] vertexes = new Double[12]; Double[] normals = new Double[12]; Int32[] indexes = new Int32[6]; Double[] textureCoords = new Double[8]; //设置顶点坐标,每三个一组,对应坐标系的X,Y,Z数值 // -0.661115958904828,-0.239472665266096,1646.15246582031 double offsetX = 0; double offsetY = 0; double offsetZ = 0; vertexes[0] = ps.leftbottom().X + (ps.rightbottom().X - ps.leftbottom().X) / 10 + offsetX; vertexes[1] = ps.leftbottom().Y + (ps.rightbottom().Y - ps.leftbottom().Y) / 10 + offsetY; vertexes[2] = ps.leftbottom().Z + (ps.leftup().Z - ps.leftbottom().Z) / 10 * 8 + offsetZ; vertexes[3] = ps.leftup().X + (ps.rightup().X - ps.leftup().X) / 10 + offsetX; vertexes[4] = ps.leftup().Y + (ps.rightup().Y - ps.leftup().Y) / 10 + offsetY; vertexes[5] = ps.leftup().Z - (ps.leftup().Z - ps.leftbottom().Z) / 10 + offsetZ; vertexes[6] = ps.rightup().X - (ps.rightup().X - ps.leftup().X) / 10 + offsetX; vertexes[7] = ps.rightup().Y - (ps.rightup().Y - ps.leftup().Y) / 10 + offsetY; vertexes[8] = ps.rightup().Z - (ps.rightup().Z - ps.rightbottom().Z) / 10 + offsetZ; vertexes[9] = ps.rightbottom().X - (ps.rightbottom().X - ps.leftbottom().X) / 10 + offsetX; vertexes[10] = ps.rightbottom().Y - (ps.rightbottom().Y - ps.leftbottom().Y) / 10 + offsetY; vertexes[11] = ps.rightbottom().Z + (ps.rightup().Z - ps.rightbottom().Z) / 10 * 8 + offsetZ; //设置顶点索引,用于绘制图形时应用 indexes[0] = 0; indexes[1] = 1; indexes[2] = 2; indexes[3] = 0; indexes[4] = 2; indexes[5] = 3; //设置顶点的法向量方向,设置法向量可以突出Mesh的阴影效果,更加逼真。 for (int i = 0; i < 12; i += 3) { normals[i] = 0; normals[i + 1] = 1; normals[i + 2] = 0; } mesh.Vertices = vertexes; mesh.Indexes = indexes; return(mesh); }
Mesh MakeMeshPot(Point3Ds ps) { Mesh mesh = new Mesh(); Double[] vertexes = new Double[12]; Double[] normals = new Double[12]; Int32[] indexes = new Int32[6]; Double[] textureCoords = new Double[8]; //设置顶点坐标,每三个一组,对应坐标系的X,Y,Z数值 // -0.661115958904828,-0.239472665266096,1646.15246582031 double offsetX = 0; double offsetY = 0; double offsetZ = 0; vertexes[0] = ps.leftbottom().X + (ps.rightbottom().X - ps.leftbottom().X) / 10 + offsetX; vertexes[1] = ps.leftbottom().Y + (ps.rightbottom().Y - ps.leftbottom().Y) / 10 + offsetY; vertexes[2] = ps.leftbottom().Z + (ps.leftup().Z - ps.leftbottom().Z) / 10 * 8 + offsetZ; vertexes[3] = ps.leftup().X + (ps.rightup().X - ps.leftup().X) / 10 + offsetX; vertexes[4] = ps.leftup().Y + (ps.rightup().Y - ps.leftup().Y) / 10 + offsetY; vertexes[5] = ps.leftup().Z - (ps.leftup().Z - ps.leftbottom().Z) / 10 + offsetZ; vertexes[6] = ps.rightup().X - (ps.rightup().X - ps.leftup().X) / 10 + offsetX; vertexes[7] = ps.rightup().Y - (ps.rightup().Y - ps.leftup().Y) / 10 + offsetY; vertexes[8] = ps.rightup().Z - (ps.rightup().Z - ps.rightbottom().Z) / 10 + offsetZ; vertexes[9] = ps.rightbottom().X - (ps.rightbottom().X - ps.leftbottom().X) / 10 + offsetX; vertexes[10] = ps.rightbottom().Y - (ps.rightbottom().Y - ps.leftbottom().Y) / 10 + offsetY; vertexes[11] = ps.rightbottom().Z + (ps.rightup().Z - ps.rightbottom().Z) / 10 * 8 + offsetZ; //设置顶点索引,用于绘制图形时应用 indexes[0] = 0; indexes[1] = 1; indexes[2] = 2; indexes[3] = 0; indexes[4] = 2; indexes[5] = 3; //设置顶点的法向量方向,设置法向量可以突出Mesh的阴影效果,更加逼真。 for (int i = 0; i < 12; i += 3) { normals[i] = 0; normals[i + 1] = 1; normals[i + 2] = 0; } mesh.Vertices = vertexes; mesh.Indexes = indexes; return mesh; }