//Jackie Weber /* My object for the Object Library table(...) takes four parameters 1) float tablePostLeftX 2) float tablePostRightX 3) float tablePostTopZ 4) float tablePostBottomZ 5) int tex - number of texture ID to be used for table legs 1-4 are the positions of the table legs. This is assuming a normal coordinate system with a normal (down the z axis) camera view. The size of the top of the table is: tablePostRightX-tablePostLeftX tablePostTopZ-tablePostBottomZ y=4* top of table is white/ /* x and z specify the origin along their respective axes Origin: x,0,z Orientation: normal axes Size: Color: tex */ twTriple lightGray={.9,.9,.9}; static void tablePosts2(float x,float z, GLuint texid){ glEnable(GL_TEXTURE_2D); twColor(lightGray,0.5,30);//lightGray because the texture was darker than I wanted glBindTexture(GL_TEXTURE_2D, texid); float frontLowerRightX=x-.5; float frontLowerLeftX=x+.5; glBegin(GL_QUADS); glNormal3f(0,0,1); glTexCoord2f(0,0); glVertex3f(x-.5,3.0, z+.5); glTexCoord2f(0,1); glVertex3f (x-.5,0.0, z+.5); glTexCoord2f(1,1); glVertex3f (x+.5,0.0,z+.5); glTexCoord2f(1,0); glVertex3f (x+.5,3.0,z+.5); glNormal3f(1,0,0); glTexCoord2f(0,0); glVertex3f(x+.5,3,z+.5); glTexCoord2f(0,1); glVertex3f(x+.5,0,z+.5); glTexCoord2f(1,1); glVertex3f(x+.5,0,z-.5); glTexCoord2f(1,0); glVertex3f(x+.5,3,z-.5); glNormal3f(0,0,-1); glTexCoord2f(0,0); glVertex3f(x-.5,3.0, z-.5); glTexCoord2f(0,1); glVertex3f (x-.5,0.0, z-.5); glTexCoord2f(1,1); glVertex3f (x+.5,0.0,z-.5); glTexCoord2f(1,0); glVertex3f (x+.5,3.0,z-.5); glNormal3f(-1,0,0); glTexCoord2f(0,0); glVertex3f(x-.5,3,z+.5); glTexCoord2f(0,1); glVertex3f(x-.5,0,z+.5); glTexCoord2f(1,1); glVertex3f(x-.5,0,z-.5); glTexCoord2f(1,0); glVertex3f(x-.5,3,z-.5); glEnd(); } /* x1 is the right edge of the table; x2 is the left side, z1 is top and z2 is bottom Origin: halfway between x1 and x2, y=3.5, and halfway between z1 and z2 Orientation: normal axes Size: in the x direction, x1-x2+1,z1-z2-1 Color: White */ static void tableTop2(float x1,float x2,float z1,float z2){ glDisable(GL_TEXTURE_2D); twColorName(TW_WHITE); glTranslatef((x1+x2)/2.0,3.5,(z1+z2)/2.0); glPushMatrix(); glScalef(x1-x2+1,1,z1-z2-1); glutSolidCube(1); glPopMatrix(); } /* Note: this function has no push and pop. This makes it easier to place things on top of the table. Origin: halfway between tablePostLeftX and tablePostRightX, halfway between tablePostTopZ and tablePostBottomZ (tablePostBottomA being a lower number on the z axis, so it's farther from the viewer with the typical original view), y=0 Orientation: normal coordinate system Size: tablePostRightX-tablePostLeftX, tablePostTopZ-tablePostBottomZ, y=4 (tablepostheight (3) + tableTopHeight(1)) Colors: tablePosts are brown, tableTop is white */ void jweber2Table2(float tablePostLeftX,float tablePostRightX,float tablePostTopZ,float tablePostBottomZ,GLuint texid){ glDisable(GL_TEXTURE_2D); tablePosts2(tablePostLeftX,tablePostTopZ,texid);//tableposts for table tablePosts2(tablePostRightX,tablePostTopZ,texid); tablePosts2(tablePostLeftX,tablePostBottomZ,texid); tablePosts2(tablePostRightX,tablePostBottomZ,texid); tableTop2(tablePostRightX-1,tablePostLeftX+1,tablePostTopZ,tablePostBottomZ);//top of table - tableposts changed in the X direction so directly over tableposts and not between them in the x direction }