Hello.
I would like to render a cube with a dimetric view :
- the edge of the cube should render as a 2:1 line of pixels (see [1])
- two of the three angles between the axes are equal (116.565°, 116.565°, 126.87°) (see [1])
My question are :
- what are the corresponding camera rotations to form a dimetric perspective ?
- why does my code not work when i make a rotation of (90 - 26.565)° and 45° (i must do 55 then 45, see [2]) ?
Thanks for your help.
Regards.
[1] a link on sometric perspectives http://en.wikipedia.org/wiki/Isometric_projection#Blurring_of_the_definition
[2] my code
// g++ -Wall -o foo foo.cc -lGL -lglut
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
float angle = 55;
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
// Begin of the section where i don't know what to do
glRotatef(angle, 1.0, 0.0, 0.0);
glRotatef(45, 0.0, 0.0, 1.0);
// End
glScalef(1.0, 1.0, 0.5);
glutWireCube(1);
glPopMatrix();
glFlush ();
}
void reshape(int w, int h)
{
h = w;
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho(-2, 2, -2, 2, -2, 2);
}
void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case 'a':
angle += 0.1;
printf("%g
", angle);
break;
case 'z':
angle -= 0.1;
printf("%g
", angle);
break;
case 27:
exit(0);
break;
default:
break;
}
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
glClearColor (0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 0.0);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}