Hi. I am experimenting with different projections, and I am trying to make an isometric view of a house.
I want to do this again by supplying my own matrices, but I am having a little trouble figurring out how I should rotate my objects.
I was thinking about rotating the objects 45 degrees around the z-axis, but this seems to be a bit off.
And then I need something more.
I was hoping to get a little advise in here.
The following are the 2 abjects (the house and profile) that i need to make an isometric view of.
Hope not this is too much.
Many regards
void ctrlpolygon (void) {
int i;
GLfloat ctrlpoints [5][3] = {{0.,0.,0.},{0.,0.,5.},{5.,0.,10.},{10.,0.,5.},{10.,0.,0.} };
glPointSize(5.0);
glColor3f(0.0, 1.0, 1.0);
glBegin(GL_POINTS);
for (i = 0; i < 5; i++)
glVertex3fv(&ctrlpoints[i][0]);
glEnd();
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINE_STRIP);
for (i = 0; i < 5; i++)
glVertex3fv(&ctrlpoints[i][0]);
glEnd();
}
void house (void) {
int i;
/* This code draws the house.
The house consists of 6 polygon as defined below:
Two Ends: Ep and Ep2, Two Walls: Wp and Wp2, and Two Roofs: Rp and Rp2
The code also sets up the normals of the polygons.
*/
GLfloat Ep [5][3] = {{0.,0.,0.},{0.,0.,5.},{5.,0.,10.},{10.,0.,5.},{10.,0.,0.} };
GLfloat Wp[4][3] = {{0.,0.,0.},{0.,-10.0,0.},{0.,-10.,5.},{0.,0.,5.} };
GLfloat Rp [4][3] = {{0.,0.,5.},{0.,-10.,5.},{5.,-10.,10.},{5.,0.,10.} };
GLfloat Ep2 [5][3] = {{10.,-10.,0.},{10.,-10.,5.},{5.,-10.,10.},{0.,-10.,5.},{0.,-10.,0.}};
GLfloat Wp2 [4][3] = {{10.,0.,0.},{10.,0.,5.},{10.,-10.,5.},{10.,-10.,0.}};
GLfloat Rp2 [4][3] = {{10.,0.,5.},{5.,0.,10.},{5.,-10.,10.},{10.,-10.,5.} };
glPushMatrix ();
glColor3f (0.8, 0.0, 0.0);
glBegin(GL_POLYGON);
glNormal3f (0.0,1.0,0.0);
for (i = 0; i < 5; i++)
glVertex3fv(&Ep[i][0]);
glEnd();
glBegin(GL_POLYGON);
glNormal3f (-1.0,0.0,0.0);
for (i = 0; i < 4; i++)
glVertex3fv(&Wp[i][0]);
glEnd();
glBegin(GL_POLYGON);
glNormal3f (-1.0,0.0,1.0);
for (i = 0; i < 4; i++)
glVertex3fv(&Rp[i][0]);
glEnd();
glBegin(GL_POLYGON);
glNormal3f (0.0,-1.0,0.0);
for (i = 0; i < 5; i++)
glVertex3fv(&Ep2[i][0]);
glEnd();
glBegin(GL_POLYGON);
glNormal3f (1.0,0.0,0.0);
for (i = 0; i < 4; i++)
glVertex3fv(&Wp2[i][0]);
glEnd();
glBegin(GL_POLYGON);
glNormal3f (1.0,0.0,1.0);
for (i = 0; i < 4; i++)
glVertex3fv(&Rp2[i][0]);
glEnd();
glPopMatrix();
}