batch.getVertexBuffer().rewind();
float firstX = -1.0f;
float firstY = -1.0f;
for (int i = 0; i < batch.getVertexCount(); i++) {
Vector2f mapCoord = new Vector2f();
mapCoord.x = (batch.getVertexBuffer().get() + offsetX) / (getStepScale().x);
batch.getVertexBuffer().get(); // ignore vert y coord.
mapCoord.y = (batch.getVertexBuffer().get() + offsetY) / (getStepScale().z);
if( firstX == -1.0f ) {
firstX = mapCoord.x;
}
if( firstY == -1.0f ) {
firstY = mapCoord.y;
}
float up = 1.0f;//((float)TILE_SIZE+1.0f) / (float)TILE_SIZE;
float tileIndexX = (mapCoord.x % TILE_SIZE) / TILE_SIZE;
float tileIndexY = (mapCoord.y % TILE_SIZE) / TILE_SIZE;
float oX = tileIndexX * up;
float oY = tileIndexY * up;
if( tileIndexX == 0.0f ) {
if( mapCoord.x != firstX ) {
oX = 1.0f;
} else {
oX = 0.00f;
}
}
if( tileIndexY == 0.0f ) {
if( mapCoord.y != firstY ) {
oY = 1.0f;
} else {
oY = 0.00f;
}
}
Vector2f texCoord = materialMap.textureForMap(mapCoord);
float fX = texCoord.x + (0.5f * oX);
float fY = texCoord.y + (0.5f * oY);
texs.put(fX);