vertexBuffer.put(i3+0, voxel.vertexPosition.getXf());
vertexBuffer.put(i3+1, voxel.vertexPosition.getYf());
vertexBuffer.put(i3+2, voxel.vertexPosition.getZf());
Vector3 normal = computeVoxelNormal(x,y,z,voxel.vertexPosition);
normalBuffer.put(i3+0, normal.getXf());
normalBuffer.put(i3+1, normal.getYf());
normalBuffer.put(i3+2, normal.getZf());
int i4 = voxel.index * 4;
colorBuffer.put(i4+0, voxel.materials.getXf());
colorBuffer.put(i4+1, voxel.materials.getYf());
colorBuffer.put(i4+2, voxel.materials.getZf());
colorBuffer.put(i4+3, voxel.materials.getWf());
///GRASS
if (voxel.vertexPosition.getY() > 33 && voxel.vertexPosition.getYf() < 210 && normal.getY() > 0.7)
verticesWithGrass.add(voxel.index);
}
}
}
}
for (int q = 0; q < quads.size(); q++) {
Quad quad = quads.get(q);
indexBuffer.put(quad.voxel1.index);
indexBuffer.put(quad.voxel2.index);
indexBuffer.put(quad.voxel3.index);
indexBuffer.put(quad.voxel1.index);
indexBuffer.put(quad.voxel3.index);
indexBuffer.put(quad.voxel4.index);
}
indexBuffer.rewind();
//colorBuffer.flip();
meshData.setVertexBuffer(vertexBuffer);
meshData.setIndexBuffer(indexBuffer);
meshData.setNormalBuffer(normalBuffer);
meshData.setColorBuffer(colorBuffer);
// meshData.setColorBuffer(colorBuffer);
block.numOfTriangles = quads.size()*2;
block.numOfVertices = voxelCounter;
Vector3 center = basePosition;
double halfSize = pool.getLevel().getScale() * VoxelWorld.BLOCK_SIZE / 2.0;
center.addLocal(halfSize, halfSize, halfSize);
mesh.setModelBound(new BoundingBox(center, halfSize, halfSize, halfSize));
block.getVoxelNode().attachChild(mesh);
//////////GRASS///////////////////