I'm trying to create a 3D chessboard that the user can look at at various angles. I'm using gluLookAt with converted spherical coordinates to deal with the camera, but for some reason this changes the apparent depth of the objects. I think its related to the fact that I'm generating the board as a sequence of cubes and I'm not understanding something about how gluLookAt and glTranslate play with each other, but as far as I can tell it should work. Here's the display method:
glu.gluLookAt(
r * cos(phi) * sin(theta) - .5, r * sin(phi) - .5, r * cos(phi) * cos(theta) - .5,
board.getSize()[0] / 2.0 - .5, board.getSize()[1] / 2.0 - .5, board.getSize()[2] / 2.0 - .5, //glutSolidCube centeres the cube at the origin so I have to shift back 1/2 the lengh of the cube
sin(phi) * sin(theta), abs(cos(phi)), sin(phi) * cos(theta));
for(int i=0;i<board.getSize()[2];i++){
for(int j=0;j<board.getSize()[1];j++){
for(int k=0;k<board.getSize()[0];k++){
glut.glutSolidCube(1f);
gl.glTranslatef(1f, 0f, 0f);
}
gl.glTranslatef(-1 * board.getSize()[0], 1f, 0f);
}
gl.glTranslatef(0f,-1 * board.getSize()[1], 1f);
}
Note that I'm using theta as the angle in the x-z plane and phi as the angle between the x-z plane and the vector. This is pi/2 shifted from the usual formulation, which is why x=rcos(phi)sin(theta) instead of rsin(phi)sin(theta) and so on.