Skip to main content
GameDev.net gamedev.net
🔒 Locked

Cavalier Projection

Started by ma_hty Nov 24, 2008 at 9:04 PM 0 replies 2k views
Original Post
ma_hty
ma_hty
When I help my professor do the marking of a quiz, I came across a question about implementing Cavalier Projection using OpenGL. While the suggested answer from my professor and those I found on internet are both not very useful, I wrote one myself. Just in case someone might want to find one, here is the Cavalier Projection function I wrote.

void glOblique( GLdouble alpha, GLdouble phi, GLdouble aspect, GLdouble zNear, GLdouble zFar )
{
  double x, z, a, b, c, m[16];
  x = 1/aspect;
  a = cos(phi*PI/180)/tan(alpha*PI/180);
  b = sin(phi*PI/180)/tan(alpha*PI/180);
  z = -2/(zFar-zNear);
  c = -(zFar+zNear)/(zFar-zNear);
  m[0]=x; m[4]=0; m[ 8]=-a; m[12]=a;
  m[1]=0; m[5]=1; m[ 9]=-b; m[13]=b;
  m[2]=0; m[6]=0; m[10]= z; m[14]=c;
  m[3]=0; m[7]=0; m[11]= 0; m[15]=1;
  glMultMatrixd(m);
}


Alpha and phi are measured in degree and they are defined as http://local.wasp.uwa.edu.au/~pbourke/geometry/classification/.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.