Okay i am following TheBennyBox from Youtube I skipped most of the videos as I already had my own engine ready and I could convert most of the things he was saying into my engine but anyway lets get to the point I am trying to make the map and there are spaces inbetween each tile in like a diagonal way image below would explain better but I want it to not have those spaces
Also I cannot figure out how I would texture it all I could do was that little square
Not sure if this will help but I am using Open Gl 3+ from the YouTube tutorial from ThinMatrix
Map Code
public class Map {
public static final int WIDTH = 1;
public static final int HEIGHT = 1;
public static final int LENGTH = 1;
private TexturedModel mapModel;
private VertexArray rawModel;
private Bitmap mapImage;
public Map() {
mapImage = new Bitmap("res/levelTest.png");
ArrayList<Float> verticesArray = new ArrayList<>();
ArrayList<Integer> indicesArray = new ArrayList<>();
for(int x = 0;x < mapImage.getWidth();x++){
for(int z = 0; z < mapImage.getHeight();z++){
// if((mapImage.getPixel(x,z) & 0xFFFFFF) == 0){
// continue;
// }
indicesArray.add(verticesArray.size() + 0);
indicesArray.add(verticesArray.size() + 1);
indicesArray.add(verticesArray.size() + 2);
indicesArray.add(verticesArray.size() + 2);
indicesArray.add(verticesArray.size() + 3);
indicesArray.add(verticesArray.size() + 0);
addVertex(verticesArray, x*WIDTH, 0, z*LENGTH);
addVertex(verticesArray, x*WIDTH, 0, (z+1)*LENGTH);
addVertex(verticesArray, (x+1)*WIDTH, 0, (z+1)*LENGTH);
addVertex(verticesArray, (x+1)*WIDTH, 0, z*LENGTH);
}
}
float[] vertices = new float[verticesArray.size()];
int[] indices = new int[indicesArray.size()];
for(int i = 0;i < verticesArray.size();i++){
vertices[i] = verticesArray.get(i);
}
for(int i = 0;i < indicesArray.size();i++){
indices[i] = indicesArray.get(i);
}
float[] normals = {
0,1,0
};
float[] textureCoords = {
0,0,
0,1,
1,1,
1,0
};
rawModel = new VertexArray(vertices, indices, textureCoords, normals);
Texture grassTexture = Utils.loadTexture("grass");
mapModel = new TexturedModel(new Model(rawModel), grassTexture);
}
private void addVertex(ArrayList<Float> vertices,float x,float y,float z){
vertices.add(x);
vertices.add(y);
vertices.add(z);
}
public TexturedModel getModel(){
return mapModel;
}
}