// Zaza Kabayadondo // CS 307 // Assignment 4 // 17 October 2006 // Using Material and Lighting to produce a creative scene // My scene will be the start of my final project. // For the project I want to // create a jazz club, with an audience sitting at candlelit tables and // sipping wine while watching a jazz band play. The jazz band will be onstage, // a pianist, sax and bass players,and a diva singing. // My scene now will be a table with the saxophone on it. #include #include #include #include #include //#include // for the couch- later // The dimensions of the bounding box const int height = 50; // height- distance along y axis const int length = 50; // length- distance along x axis const int depth = 50; // depth- distance along z axis GLMmodel* CoveredTable = NULL; GLMmodel* Sax = NULL; void initCoveredTable() { GLfloat BoundingBox1[6] ={-10,10, // x-axis 0,20, // y-axis -10,10};// z-axis); CoveredTable = glmReadOBJ(twPathname("table.obj",true)); // not sure about the above line if(!CoveredTable) exit(0); glmUnitize(CoveredTable); glmBoundingBox(CoveredTable,BoundingBox1); glmFacetNormals(CoveredTable); glmVertexNormals(CoveredTable, 90.0); } void initSax() { GLfloat BoundingBox2[6] ={-10,10, 20,50, -10,10}; Sax = glmReadOBJ(twPathname("sax.obj",true)); // not sure about the above line if(!Sax) exit(0); glmUnitize(Sax); glmFacetNormals(Sax); glmBoundingBox(Sax,BoundingBox2); glmVertexNormals(Sax,90.0); } //************************************************************* void drawTableandSax() { // draws the entire table and sax in the coordinate system of the dot(origin) // first make the origin- a dot twColorName(TW_MAGENTA); glutSolidOctahedron(); glPushMatrix(); // To clown system glScalef(5,5,5); glmDraw(CoveredTable,GLM_SMOOTH | GLM_MATERIAL); glTranslatef(0,10,0); // I need to see the objects together before I can adjust this // height changed is based on the center of the bounding box for the // table glmDraw(Sax, GLM_SMOOTH | GLM_MATERIAL); glPopMatrix(); // Back to original system } // ******************************************************************** // ******************************************************************** void display(void) { twDisplayInit(); twCamera(); drawTableandSax(); glFlush(); glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); twInitWindowSize(500,500); glutCreateWindow(argv[0]); glutDisplayFunc(display); twBoundingBox(-length/2,length/2, // x-axis 0,height, // y-axis -depth/2,depth/2);// z-axis twMainInit(); glutMainLoop(); return 0; }