/************ Mala's Objects for the F05 Object Library ************/ /* vase function: Draws a cylindrical vase containing a singular flower vase(...) takes 6 parameters in total, and calls a subfunction named flower. 1 vaseScale [int] scaling/size of the vase - the radii of the top & bottom of the vase (drawn using twCylinder) will be half this number *Please note, once the vaseScale measurement has been given, the flower is drawn proportionally. 2 vaseColor [twTriple] the main color of the vase 3 bottomColor [twTriple] the coloring of the bottom of the vase 4 rimColor [twTriple] color of the rim at the top of the vase 5 flowerColor1 [twTriple] one color used in creation the flower 6 flowerColor2 [twTriple] another color used in creation of the flower To achieve best aesthetic results, do not use the same colors for vaseColor and bottomColor, or flowerColor1 and flowerColor2. If you prefer a vase without the rim accent at the top of the vase, use the same color for rimColor and vaseColor. */ static void flower(int vS, twTriple fc1,twTriple fc2) { twTriple chartreuse = {0.27,0.55,0}; //draw stem GLfloat curveCP[] = {0,0,0, 0,1.1*vS,0, 0.6*vS,1.85*vS,0}; glLineWidth(7); twColor(chartreuse,0,0); glMap1f(GL_MAP1_VERTEX_3, 0,1, 3,3,curveCP); glEnable(GL_MAP1_VERTEX_3); glMapGrid1f(5,0.0,1.0); glEvalMesh1(GL_LINE,0,5); //flower drawn using overlapping octahedrons glTranslatef(0.6*vS,2*vS,0); glScalef(vS*0.35,vS*0.35,vS*0.2); twColor(fc1,0,0); glRotatef(90,1,0,0); glutSolidOctahedron(); twColor(fc2,0,0); glRotatef(-115,0,1,0); glutSolidOctahedron(); glLineWidth(1); //reset linewidth so bounding box and axes show properly } void msarkarVase(int vaseScale, twTriple vaseColor, twTriple bottomColor, twTriple rimColor, twTriple flowerColor1, twTriple flowerColor2) { glPushMatrix(); //body of vase twColor(vaseColor,0,0); glRotatef(-90,1,0,0); glTranslatef(0,vaseScale,0); twCylinder(vaseScale*0.5,vaseScale*0.5,vaseScale*1.5,vaseScale,vaseScale); //bottom of vase twColor(bottomColor,0,0); twDisk(vaseScale*0.5,vaseScale); //water level glPushMatrix(); twColorName(TW_BLUE); glTranslatef(0,0,0.75*vaseScale); twDisk(vaseScale*0.5,vaseScale); glPopMatrix(); //rim around top of vase glPushMatrix(); glTranslatef(0,0,vaseScale*1.5); twColor(rimColor,0,0); twCylinder(vaseScale*0.5,vaseScale*0.5,vaseScale*0.05,vaseScale,1); glPopMatrix(); //call function to draw flower glRotatef(90,1,0,0); flower(vaseScale,flowerColor1,flowerColor2); glPopMatrix(); } /* couch function: Draws a long couch with arms constructed of glutSolidCubes couch(...) takes 3 parameters in total 1 e [int] The scaling of the couch. The width & height will each be 3 times this number,and the depth will be 2.5 times this number 2 colorA [twTriple] main color of the couch 3 colorB [twTriple] piping of the couch (accented edges for definition) */ void msarkarCouch(int e,twTriple colorA,twTriple colorB) { glPushMatrix(); //couch back twColor(colorA,0.25,0); glPushMatrix(); glScalef(6*e,3*e,0.5*e); glutSolidCube(1); twColor(colorB,0,0); glutWireCube(1); glPopMatrix(); //couch base glPushMatrix(); glTranslatef(0,-e,1.25*e); glScalef(5*e,e,2*e); twColor(colorA,0.25,0); glutSolidCube(1); twColor(colorB,0,0); glutWireCube(1); glPopMatrix(); //left arm of base glPushMatrix(); glTranslatef(-2.75*e,-0.5*e,1.25*e); glScalef(0.5*e,2*e,2*e); twColor(colorA,0.25,0); glutSolidCube(1); twColor(colorB,0,0); glutWireCube(1); glPopMatrix(); //right arm of base glPushMatrix(); glTranslatef(2.75*e,-0.5*e,1.25*e); glScalef(0.5*e,2*e,2*e); twColor(colorA,0.25,0); glutSolidCube(1); twColor(colorB,0,0); glutWireCube(1); glPopMatrix(); glPopMatrix(); } /* ceilingLight function: Draws a lamp meant to be hung from the ceiling, complete with lightshade and bulb ceilingLight(...) takes 3 parameters in total 1 lh [int] height of the light pole from which the shade hangs from. 2 mat [twTriple] color of the lighting structure 3 bulbcolor [twTriple] color of the light bulb within the light shade The shade does not adjust according to 'lh' or the pole height, so in that sense the light is not scalable. Notice that the yellow bulb stays a stark bright yellow if you enable lighting in the msarkarCeilingLight demo; if you want to disable this feature, change the value of light0 within the function to 'false.' */ void msarkarCeilingLight(int lh, twTriple mat, twTriple bulbColor) { bool light0 = true; //draw pole from which light hangs from twColor(mat,100,100); glPushMatrix(); glRotatef(90,1,0,0); twCylinder(1,1,lh,10,10); glPopMatrix(); //draw light bulb glPushMatrix(); twColor(bulbColor,0,50); if(light0){ GLfloat mat_emission[] = {1, 1, 0, 0.99}; glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); }else{ GLfloat mat_emission2[] = {0, 0, 0, 0}; glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission2); } glTranslatef(0,-lh,0); glutSolidSphere(2,10,10); glPopMatrix(); //draw light shade glPushMatrix(); twColor(mat,100,100); GLfloat mat_emissionCLEAR[] = {0,0,0,0.0}; glMaterialfv(GL_FRONT, GL_EMISSION,mat_emissionCLEAR); glTranslatef(0,-lh-lh*0.1,0); glRotatef(-90,1,0,0); glLineWidth(5); glutWireCone(7,10,15,15); glPopMatrix(); } /* ottoman function: Draws an ottoman using glutSolidTorus and a flattened sphere to cover the middle ottoman(...) takes 2 parameters in total 1 ottomanScale [int] scaling of the ottoman/diameter of the ottoman 2 ottomanColorA [twTriple] main color of the body of the ottoman 3 ottomanColorB [twTriple] color of middle of ottoman, and accents The ottoman should looks alright in a room setting with lighting. In the demo there is some lighting, but for added clarity I've added piping to the ottoman, and made the middle of the ottoman a different color. The simplest way to get rid of these effects is to use the same twTriple for the second and third parameter. Alternatively, you could delete the lines which draw the wireTorus piping. */ void msarkarOttoman(int ottomanScale, twTriple ottomanColorA, twTriple ottomanColorB) { glPushMatrix(); twColor(ottomanColorA,0,0); glRotatef(90,1,0,0); glutSolidTorus(ottomanScale*0.5,ottomanScale*0.5,ottomanScale*2,ottomanScale*2); twColor(ottomanColorB, 0,0); glutWireTorus(ottomanScale*0.5,ottomanScale*0.5,ottomanScale*2,ottomanScale*2); twColor(ottomanColorB,0.1,0); glTranslatef(0,0,-0.40*ottomanScale); glScalef(1,1,0.10); glutSolidSphere(ottomanScale*0.25,10,10); glPopMatrix(); }