网格面类.

命名空间:  SuperMap.Data
程序集:  SuperMap.Data (in SuperMap.Data)
版本: dll

语法

C#
public class Mesh : IDisposable

备注

该类主要用来获取或设置网格面对应的材质、顶点数组、纹理坐标数组、顶点索引数组、颜色集合、向量集合。

示例

以下代码示范了如何初始化Mesh。

CopyC#
public void TestMesh() 
 {
      Mesh mesh = new Mesh();
      Double[] vertexes = new Double[12];
      Double[] normals = new Double[12];
      Int32[] indexes = new Int32[8];
      Double[] textureCoords = new Double[8];
      Color[] colors = new Color[] { Color.Red, Color.SkyBlue, Color.Black, Color.Blue };

      //设置顶点坐标,每三个一组,对应坐标系的X,Y,Z数值
      vertexes[0] = 0.0;            vertexes[1] = 0.0;            vertexes[2] = 0.0;
      vertexes[3] = 36000;      vertexes[4] = -48000;     vertexes[5] = 0.0;
      vertexes[6] = 100000;    vertexes[7] = 0.0;            vertexes[8] = 0.0;
      vertexes[9] = 64000;      vertexes[10] = 0;             vertexes[11] = 48000;

      //设置顶点索引,用于绘制图形时应用
      indexes[0] = 0;            indexes[1] = 1;           indexes[2] = 2;
      indexes[3] = 0;            indexes[4] = 2;           indexes[5] = 3;

      //设置顶点的法向量方向,设置法向量可以突出Mesh的阴影效果,更加逼真。
      normals[0] = 0.0;normals[1] = 0.0; normals[2] = 1.0;
      for (int i = 3; i <7; i++)
      {
          normals[i] = normals[0];normals[i + 1] = normals[1];normals[i + 2] = normals[2];
      }
      normals[9] = 0.0;normals[10] = -1.0;normals[11] = 0.0;


      //设置纹理坐标,用于设置贴图的显示效果
      for (int i = 0; i < 8;i += 2 )
      {
          textureCoords[i] = 0.0 + 0.125 * i;
          textureCoords[i + 1] = textureCoords[i];
      }

      mesh.Vertices = vertexes;
      mesh.Indexes = indexes;
      mesh.Normals = normals;
      mesh.Colors = colors;
      mesh.TextureCoords = textureCoords;
      Material material = new Material();
      //material.Ambient = Color.Red;
      //material.Diffuse = Color.Red;
      //material.Specular = Color.Blue;
      material.TextureFile = "C:/green.jpg";
      mesh.Material = material;
  }

继承层次

System..::.Object
  SuperMap.Data..::.Mesh

请参见