Hey there,
I am bit stuck about how I draw a simple grid like a chess field best way.
My approach so far is the following, but somehow the indices are wrongly connected.
int height = 500;
int width = 500;
int distance = 10;
for (int y = 0; y < height; y = y + distance){
for (int x = 0; x<width; x = x + distance){
mesh.addVertex(ofPoint(x,y,0)); // make a new vertex
}
}
int heightIndex = height / distance-1;
int widthIndex = width / distance-1;
for (int y = 0; y<heightIndex; y++){
for (int x=0; x<widthIndex; x++){
mesh.addIndex(x+y*widthIndex);
mesh.addIndex((x+1)+y*widthIndex);
mesh.addIndex(x+(y+1)*widthIndex);
mesh.addIndex((x+1)+y*widthIndex);
mesh.addIndex((x+1)+(y+1)*widthIndex);
mesh.addIndex(x+(y+1)*widthIndex);
}
}
Is there a better way for that? any ideas what exactly is going wrong. I can not wrap my head around that.