实现java3d的即时刷新技术

时间:2012-06-30 05:37:14
【文件属性】:

文件名称:实现java3d的即时刷新技术

文件大小:13KB

文件格式:JAVA

更新时间:2012-06-30 05:37:14

刷新

实现java3d的即时刷新技术 private Geometry createGeometry() { int nx = 21 * 2 - 1; int ny = 21 * 2 - 1; Point3f coords[] = new Point3f[nx * ny]; float z; int count = 0; for (float y = -10f; y <= 10f; y += 0.5f) { for (float x = -10f; x <= 10f; x += 0.5f) { if (x == 0f && y == 0f) { // 閫欓粸, 鑸囩溇涓嶅悓, 瑕佺壒鍒ヨ檿鐞? z = 1f; // (for n --> 0), lim (sin(n) / n) --> 1 } else { double r = Math.sqrt(x * x + y * y); z = (float) (Math.sin(r) / r); } coords[count++] = new Point3f(x / 10f, y / 10f, z); } } int[] indices = new int[(nx - 1) * (ny - 1) * 4]; count = 0; for (int y = 0, endY = ny - 1; y < endY; y++) { for (int x = 0, endX = nx - 1; x < endX; x++) { int v = nx * y + x; indices[count++] = v; indices[count++] = v + 1; v += nx; indices[count++] = v + 1; indices[count++] = v; } } IndexedQuadArray iqa = new IndexedQuadArray(coords.length, IndexedQuadArray.COORDINATES, indices.length); iqa.setCoordinates(0, coords); iqa.setCoordinateIndices(0, indices); return iqa; }


网友评论