9

Possible Duplicate:
true isometric projection with opengl

I want to render using the same isometric rendering which Blender3d uses, how can i do this ? Is it possible with just a call to glMultMatrix() ? I tried googling but couldnt find any working matrixes that would result in that kind of rendering mode. i tried this http://en.wikipedia.org/wiki/Isometric_projection but it just rendered really weird.

This is the matrix i use now that renders with normal perspective:

    GLdouble f = cotan(fovy/2.0);
    GLdouble aspect = (GLdouble)width/(GLdouble)height;

    IsoMatrix.x[0] = f/aspect;
    IsoMatrix.y[0] = 0;
    IsoMatrix.z[0] = 0;
    IsoMatrix.w[0] = 0;

    IsoMatrix.x[1] = 0;
    IsoMatrix.y[1] = f;
    IsoMatrix.z[1] = 0;
    IsoMatrix.w[1] = 0;

    IsoMatrix.x[2] = 0;
    IsoMatrix.y[2] = 0;
    IsoMatrix.z[2] = (zfar+znear)/(znear-zfar);
    IsoMatrix.w[2] = (2.0*zfar*znear)/(znear-zfar);

    IsoMatrix.x[3] = 0;
    IsoMatrix.y[3] = 0;
    IsoMatrix.z[3] = -1;
    IsoMatrix.w[3] = 0;

    glMultMatrixd((GLdouble *)&IsoMatrix);

How do i change it so it will result to: http://rvzenteno.files.wordpress.com/2008/10/rvz_018.jpg ?

Community
  • 1
  • 1
Rookie
  • 3,753
  • 5
  • 33
  • 33

1 Answers1

12

It is easier to use glOrtho then rotate the axes:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -10.0f, 10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
Alex Peck
  • 4,603
  • 1
  • 33
  • 37
  • what exactly those two glRotatef()'s are for ? – Rookie Jun 28 '11 at 17:25
  • Without them, you have an orthographic projection looking directly along the z axis. – Alex Peck Jun 28 '11 at 17:46
  • With them, you have an isometric view - rotated 35.264° about the x axis, and 45° about Y. I updated the angles according to your link to wikipedia. 35.264° = arctan(sin 45°) – Alex Peck Jun 28 '11 at 17:53
  • oh i see, i have my own rotation system already for my camera, so i guess i dont need these. although, i will keep in mind those angles there, to set it into perfect symmetry later. – Rookie Jun 28 '11 at 18:01
  • Thanks for those rotations; they were just what I needed! :) – Asherah May 04 '14 at 11:29