|
|||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Object com.supermap.data.Meshes
public class Meshes
网格面集合类。
该类是网格面对象(Mesh对象)的集合。主要用来对三维模型几何对象中的网格面集合对象进行设置,我们可以将定义的多个网格面对象加入到该集合中并显示在三维场景中。
public void TestMeshes(SceneControl m_sceneControl) throws InterruptedException { //新建 GeoModel 对象,设置 Position 为(110, 39, 0); GeoModel geoModel = new GeoModel(); geoModel.setPosition(new Point3D(110, 39, 0)); //返回 Meshes Meshes meshes = geoModel.getMeshes(); //构造 Mesh 对象 mesh Mesh mesh = new Mesh(); double[] vertexes = new double[12]; double[] normals = new double[12]; int[] indexes =new int[8]; double[] textureCoords = new double[8]; Colors colors = new Colors(); colors.set(1, Color.RED); colors.set(2, Color.GREEN); colors.set(3, Color.BLACK); colors.set(4, Color.BLUE); //设置顶点坐标,每三个一组,对应坐标系的X、Y、Z数值 vertexes[0] = 0.0; vertexes[1] = 0.0; vertexes[2] = 0.0; vertexes[3] = 36000.0; vertexes[4] = -48000.0; vertexes[5] = 0.0; vertexes[6] = 100000.0; vertexes[7] = 0.0; vertexes[8] = 0.0; vertexes[9] = 64000.0; vertexes[10] = 0.0; vertexes[11] = 48000.0; //设置顶点索引,用于绘制图形时应用 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.setVertices(vertexes); mesh.setIndexes(indexes); mesh.setNormals(normals); mesh.setColors(colors); mesh.setTextureCoords(textureCoords); Material material = new Material(); material.setTextureFile("C:/green.jpg"); mesh.setMaterial(material); meshes.add(mesh); //新建Scene,关联 m_sceneControl Scene scene = m_sceneControl.getScene(); //MeoModel.ComputeBoundingBos() 一定要调用否则不显示,再调用 setBoundingBox(模型的BoundingBox); geoModel.computeBoundingBox(); geoModel.setBoundingBox(geoModel.getBoundingBox()); //添加GeoModel到Scene的TrackingLayer中; scene.getTrackingLayer().add(geoModel, "Model"); //Meshes.ToArrary()构造 meshs2(先调用 Thread.sleep(500),让场景控件关闭后不占用 meshes 资源) Thread.sleep(500); Mesh[] meshs2 = meshes.toArray(); //将meshs2添加到 Meshes 集合中; meshes.addRange(meshs2); //移除索引为0的 Mesh 对象,移除从索引0处开始的1个 Mesh 对象; meshes.remove(0); meshes.removeRange(0, 1); //clear()清除 Meshes 中全部 Mesh 对象; meshes.clear(); }
方法摘要 | |
---|---|
int |
add(Mesh mesh)
向集合中添加网格面对象,添加成功返回被添加对象的序号。 |
int |
addRange(Mesh[] meshes)
向网格面集合中以数组的形式添加网格面对象,返回成功添加的网格面对象的个数。 |
void |
clear()
清空网格面集合中的所有的网格面对象。 |
Mesh |
get(int index)
返回网格面集合中指定索引的网格面对象。 |
int |
getCount()
返回网格面对象集合中对象的个数。 |
boolean |
insert(int index,
Mesh mesh)
向集合中的指定序号处添加网格面对象,插入成功返回 true。 |
int |
insertRange(int index,
Mesh[] meshes)
向集合中的指定序号处以数组的形式添加网格面对象。 |
boolean |
remove(int index)
在集合中删除指定索引位置的网格面对象。 |
int |
removeRange(int index,
int count)
在集合中从指定序号开始删除指定个数的网格面对象。 |
void |
set(int index,
Mesh mesh)
设置网格面集合中指定索引的网格面对象。 |
Mesh[] |
toArray()
将网格面集合对象转换为网格面对象数组。 |
从类 java.lang.Object 继承的方法 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
方法详细信息 |
---|
public int getCount()
public Mesh get(int index)
index
- 索引值。
public void set(int index, Mesh mesh)
index
- 索引值。mesh
- 网格面集合中指定索引的网格面对象。public int add(Mesh mesh)
mesh
- 网格面对象。
public int addRange(Mesh[] meshes)
meshes
- 网格面数组。
public boolean insert(int index, Mesh mesh)
index
- 指定的索引位置。mesh
- 待插入的网格面对象。
public int insertRange(int index, Mesh[] meshes)
index
- 指定的索引位置。meshes
- 网格面对象数组。
public boolean remove(int index)
index
- 指定索引位置。
public int removeRange(int index, int count)
index
- 指定的索引位置。count
- 需要删除的网格面对象个数。
public void clear()
public Mesh[] toArray()
|
|||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |