`

J2ME M3G 编程

    博客分类:
  • Java
阅读更多
//顶点集合
		VertexArray vertexArray = new VertexArray(Util.vertices.length / 3, 3, 2);
		vertexArray.set(0, Util.vertices.length / 3, Util.vertices);
//顶点法线集合
//法线为顶点所在平面的垂直方向,有正负之分
		VertexArray normalArray = new VertexArray(Util.normals.length / 3, 3, 1);
		normalArray.set(0, Util.normals.length / 3, Util.normals);
//顶点颜色集合
		VertexArray colorArray = new VertexArray(Util.colors.length / 3, 3, 1);
		colorArray.set(0, Util.colors.length / 3, Util.colors);

		VertexBuffer cubeVertices = new VertexBuffer();
		cubeVertices.setPositions(vertexArray, 1.0F, null);
		cubeVertices.setNormals(normalArray);
		cubeVertices.setColors(colorArray);
//三角形带
		TriangleStripArray cubeIndices = new TriangleStripArray(0, Util.stripLengths);

		Appearance appearance = new Appearance (); 
		PolygonMode polygonMode = new PolygonMode (); 
		polygonMode.setPerspectiveCorrectionEnable (true); 
		polygonMode.setCulling (PolygonMode.CULL_NONE);
		polygonMode.setShading (PolygonMode.SHADE_SMOOTH); 
		appearance.setPolygonMode (polygonMode);
		
		mesh = new Mesh (cubeVertices, cubeIndices, appearance);
		
		world.addChild(mesh);
		
		cam = new Camera();
//相机距离
		cam.setTranslation(di,0,100);
        	world.addChild(cam);
        	world.setActiveCamera(cam);
//相机角度,及渲染的最近和最远距离
		cam.setPerspective(60F, 
                	(float) width / (float) height,
                	1.0F, 
                	300.0F);
//旋转物体
		mesh.postRotate( Util.degree, 1.0F, 0F, 0F);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics