Hi trying to sub divide the terrain shape from the terrain demo into a 2 dim array of shape3d's each of size 256 * 256.
wrote a piece of code (see below) but the texturing is not mapping properly and there is large gaps between each shape3d geometry.
the init method is the only major thing i changed can anyone suggest a reason why there could be gaps between the shape3d's?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| public void rebuild(View view) {
view.getTransform().get(pTemp); terrain.update(pTemp,117); for(int row=0; row<geo.length; ++row){ for(int col=0; col<geo[0].length; ++col){ geo[row][col].drawStart(); totalIndex = totalVerts = 0; terrain.render(this); geo[row][col].drawEnd(); geo[row][col].setIndex(index);
geo[row][col].setValidIndexCount(totalIndex); geo[row][col].setValidVertexCount(totalVerts); } }
} public void start() { } public void initVert(int i, float x, float y, float z) { if (totalVerts>=MAX_VERTICES) return; int row = (int)((x) / 256); int col = (int)((z) / 256); if(row == 4)row = 3; if(col == 4)col = 3; geo[row][col].newVertex(); geo[row][col].setCoordinate(x,y,z);
float texCoordx = x / (terrain.getWidth() / textureScale); float texCoordz = z / (terrain.getWidth() / textureScale); TexCoord2f texCoords = new TexCoord2f(texCoordx, texCoordz); geo[row][col].setTextureCoordinate(0,totalVerts,texCoords);
float c = y/1500; geo[row][col].setColor(0.48f+c, 0.48f+c, 0.39f+c);
vertexMap[i] = totalVerts++; } public void tri(int a, int b, int c) { if (totalIndex+3>=MAX_INDICES) return; index[totalIndex++] = vertexMap[a]; index[totalIndex++] = vertexMap[b]; index[totalIndex++] = vertexMap[c]; } |