Point3d[] vertexs={ p1,p3,p2, // 面1 p1,p2,p4, // 面2 p1,p4,p3, // 面3 p2,p3,p4}; // 面4
TriangleArray geometry=new IndexedTriangleArray( 4,IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3,12); // vertexCount = 4 // vertexFormat = 座標、色 // indexCount = 3 × 4
Point3d p0=new Point3d( 0.0 ,-2.0*Math.sqrt(2.0)*1.0/3.0, 2.0); Point3d p1=new Point3d( Math.sqrt(3.0),-2.0*Math.sqrt(2.0)*1.0/3.0,-1.0); Point3d p2=new Point3d(-Math.sqrt(3.0),-2.0*Math.sqrt(2.0)*1.0/3.0,-1.0); Point3d p3=new Point3d( 0.0 , 2.0*Math.sqrt(2.0)*2.0/3.0, 0.0); Color3f c0=new Color3f(0.1f,1.0f,0.3f); Color3f c1=new Color3f(0.1f,1.0f,0.3f); Color3f c2=new Color3f(0.1f,1.0f,0.3f); Color3f c3=new Color3f(0.1f,1.0f,0.3f); Point3d[] vertexs={p0,p1,p2,p3}; Color3f[] colors={c0,c1,c2,c3}; int[] indices={ 0,2,1, // 面1 0,1,3, // 面2 0,3,2, // 面3 1,2,3}; // 面4 geometry.setCoordinates(0,vertexs); // 頂点座標の設定 geometry.setCoordinateIndices(0,indices); geometry.setColors(0,colors); // 頂点の色の設定 geometry.setColorIndices(0,indices);
戻る