Advertisement
koushik105

graphics

Sep 19th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 48.17 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4.  
  5.  
  6. #include<GL/glut.h>
  7. #include<GL/glu.h>
  8.  
  9. #define BLACK 0, 0, 0
  10.  
  11. //make a global variable -- for tracking the anglular position of camera
  12. double cameraAngle;         //in radian
  13. double cameraAngleDelta;
  14. double chandelierRotation;
  15. double cameraHeight;   
  16. double cameraRadius;
  17.  
  18. double rectAngle;   //in degree
  19.  
  20. bool canDrawGrid;
  21.  
  22. float table_top_height;
  23.  
  24.  
  25. //****************************************************************************************************************************
  26. //****************************************************************************************************************************
  27. //*****************************************************************************************************************************
  28.  
  29. //Table Draw===================================================================
  30.  
  31. void drawFilledCircle(GLfloat x, GLfloat y, GLfloat radius){
  32.     int i;
  33.     int triangleAmount = 200; //# of triangles used to draw circle
  34.    
  35.     //GLfloat radius = 0.8f; //radius
  36.     GLfloat twicePi = 2.0f * 3.1415926;
  37.    
  38.     glBegin(GL_TRIANGLE_FAN);
  39.         glVertex2f(x, y); // center of circle
  40.         for(i = 0; i <= triangleAmount;i++) {
  41.             glVertex2f(
  42.                     x + (radius * cos(i *  twicePi / triangleAmount)),
  43.                 y + (radius * sin(i * twicePi / triangleAmount))
  44.             );
  45.         }
  46.     glEnd();
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53. //*******************Table Draw**************************************
  54.  
  55. //******************Table materials draw******************************
  56. void drawWineContainer(float radius)
  57. {
  58.     glPushMatrix();
  59.     {
  60.         double equ[4];
  61.  
  62.         equ[0] = 0; //0.x
  63.         equ[1] = -1;    //0.y
  64.         equ[2] = 0;//-1.z
  65.         equ[3] = 0;//30
  66.  
  67.         glClipPlane(GL_CLIP_PLANE0,equ);
  68.         glEnable(GL_CLIP_PLANE0);{
  69.             glColor3f(1,1,1);  
  70.  
  71.             glPushMatrix();{
  72.                 glTranslatef(0,0,radius);
  73.                 glScalef(1, 1, 1.5);
  74.                 GLUquadricObj *obj = gluNewQuadric();
  75.                 gluSphere(obj, radius, 50, 50);
  76.         }
  77.             /*
  78.             glPushMatrix();{
  79.                 glTranslatef(50,-50,30);
  80.                 glutWireSphere(20, 20, 20);
  81.             }glPopMatrix();*/
  82.     }glPopMatrix();
  83.     glDisable(GL_CLIP_PLANE0);
  84.     }
  85.     glPopMatrix();
  86. }
  87.  
  88. //Table Drawing====================================================================================================================================================
  89. //=================================================================================================================================================================
  90. void drawTableSurface(float bottomRadius, float upperRadius, float height){
  91.     glColor3f(0.9, 0.9, 0.9);
  92.     GLUquadricObj *obj = gluNewQuadric();
  93.     gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
  94. }
  95.  
  96. void drawSufaceCircles(GLfloat x, GLfloat y, GLfloat radius){
  97.     int i;
  98.     int triangleAmount = 200; //# of triangles used to draw circle
  99.    
  100.     //GLfloat radius = 0.8f; //radius
  101.     GLfloat twicePi = 2.0f * 3.1415926;
  102.    
  103.     glBegin(GL_TRIANGLE_FAN);
  104.         glVertex2f(x, y); // center of circle
  105.         for(i = 0; i <= triangleAmount;i++) {
  106.             glVertex2f(
  107.                     x + (radius * cos(i *  twicePi / triangleAmount)),
  108.                 y + (radius * sin(i * twicePi / triangleAmount))
  109.             );
  110.         }
  111.     glEnd();
  112. }
  113.  
  114. void drawUnderCircle1(float innerRad,float outerRad)
  115. {
  116.     glutSolidTorus(innerRad,outerRad,200,200);
  117. }
  118. void drawUnderCircle2(float innerRad,float outerRad)
  119. {
  120.     glutSolidTorus(innerRad,outerRad,200,200);
  121. }
  122. void drawTableLeg(){
  123.     glTranslatef(35,0,0);
  124.     glTranslatef(0,0,29);
  125.     glRotatef(-20,  0,1,0);
  126.     glRotatef(1801,0,0);
  127.  
  128.     glColor3f(1, 0, 0);
  129.     GLUquadricObj *obj = gluNewQuadric();
  130.     float bottomRadius = 3;
  131.     float upperRadius = 1;
  132.     float height = 31;
  133.     gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
  134.  
  135.  
  136. }
  137. void drawTableLeg1()
  138. {
  139.     glTranslatef(35,0,0);
  140.     glTranslatef(0,0,27);
  141.     glRotatef(22,  0,1,0);
  142.     glColor3f(1, 0, 0);
  143.     GLUquadricObj *obj = gluNewQuadric();
  144.     float bottomRadius = 3;
  145.     float upperRadius = 1;
  146.     float height = 15;
  147.     gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
  148. }
  149.  
  150. void drawTableCenterbase(){
  151.     glColor3f(1, 0, 0);
  152.     GLUquadricObj *obj = gluNewQuadric();
  153.     float bottomRadius = 1;
  154.     float upperRadius = 1;
  155.     float height = 40;
  156.     gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
  157. }
  158.  
  159. void callTableDraw(float translatetop)
  160. {
  161.    
  162.     glPushMatrix();{
  163.         glTranslatef(0,0,translatetop);//translatetop = 40;
  164.         float bottomRadius = 50;
  165.         float upperRadius = 50;
  166.         float height = 3;
  167.         drawTableSurface(bottomRadius, upperRadius, height);
  168.         glColor3f(0.30, 0.30, 0.33);
  169.         drawSufaceCircles(0,0,bottomRadius);
  170.         glColor3f(0.30, 0.30, 0.33);
  171.         glTranslatef(0,0,height);
  172.         drawSufaceCircles(0,0,upperRadius);
  173.     }glPopMatrix();
  174.  
  175.     glPushMatrix();{
  176.         glTranslatef(0,0,translatetop-12.5);
  177.         glColor3f(0.50, 0.16, 0.16);
  178.         float bottomRadius =10.6;float upperRadius = 45;
  179.         drawUnderCircle1(bottomRadius-10, upperRadius-10);
  180.     }glPopMatrix();
  181.  
  182.     glPushMatrix();{
  183.         glTranslatef(0,0,translatetop-10);
  184.         glColor3f(0.93, 0.71, 0.71);
  185.         float bottomRadius =10.6;float upperRadius = 46.5;
  186.         drawUnderCircle2(bottomRadius-10, upperRadius-10);
  187.     }glPopMatrix();
  188.  
  189.     glPushMatrix();{
  190.         glPushMatrix();{
  191.             drawTableLeg();
  192.         }glPopMatrix();
  193.  
  194.         glPushMatrix();{
  195.             drawTableLeg1();
  196.         }glPopMatrix();
  197.  
  198.     }glPopMatrix();
  199.  
  200.     glPushMatrix();{
  201.         glRotatef(90, 0,0,1);
  202.         glPushMatrix();{
  203.             drawTableLeg();
  204.         }glPopMatrix();
  205.  
  206.         glPushMatrix();{
  207.             drawTableLeg1();
  208.         }glPopMatrix();
  209.  
  210.     }glPopMatrix();
  211.  
  212.     glPushMatrix();{
  213.         glRotatef(180, 0,0,1);
  214.         glPushMatrix();{
  215.             drawTableLeg();
  216.         }glPopMatrix();
  217.  
  218.         glPushMatrix();{
  219.             drawTableLeg1();
  220.         }glPopMatrix();
  221.  
  222.     }glPopMatrix();
  223.  
  224.     glPushMatrix();{
  225.         glRotatef(270, 0,0,1);
  226.         glPushMatrix();{
  227.             drawTableLeg();
  228.         }glPopMatrix();
  229.  
  230.         glPushMatrix();{
  231.             drawTableLeg1();
  232.         }glPopMatrix();
  233.  
  234.     }glPopMatrix();
  235.  
  236.     glPushMatrix();{
  237.         drawTableCenterbase();
  238.     }glPopMatrix();
  239. }
  240.  
  241. //=================================================================================================================================================================
  242. //Table Drawing====================================================================================================================================================
  243.  
  244. //================================================================================================================================================================
  245. //Table object Drawing============================================================================================================================================
  246. void drinksGlassDraw()
  247. {
  248.     double equ[4];
  249.  
  250.     equ[0] = 0;
  251.     equ[1] = 0;
  252.     equ[2] = -1;
  253.     equ[3] = 3;
  254.  
  255.     glClipPlane(GL_CLIP_PLANE0,equ);
  256.  
  257.         glEnable(GL_CLIP_PLANE0);{
  258.         glColor3f(0.9,0,0); //blue
  259.  
  260.         glPushMatrix();{
  261.             float rad = 10;
  262.             glTranslatef(0,0,rad);
  263.             GLUquadricObj *obj = gluNewQuadric();          
  264.             gluSphere(obj, rad, 200, 200);
  265.  
  266.         }glPopMatrix();
  267.     }
  268.     glDisable(GL_CLIP_PLANE0); 
  269.  
  270.     glPushMatrix();{
  271.         glColor3f(0.4,0,0);
  272.         float bottomRad= 7;
  273.         float topRad= 4;
  274.         float height= 10.5;
  275.         glTranslatef(0,0,3);
  276.         GLUquadricObj *obj1 = gluNewQuadric();
  277.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  278.     }glPopMatrix();
  279. }
  280.  
  281. void drinksGlassBottomDraw1()
  282. {
  283.     glPushMatrix();{
  284.         glColor3f(0.4,0,0);
  285.         float bottomRad= 1;
  286.         float topRad= .5;
  287.         float height= 15;
  288.         glTranslatef(0,0,1.5);
  289.  
  290.         GLUquadricObj *obj1 = gluNewQuadric();
  291.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  292.     }glPopMatrix();
  293. }
  294.  
  295. void drinksGlassBottomDraw2()
  296. {
  297.     glPushMatrix();{
  298.         glColor3f(0.4,0,0);
  299.         float bottomRad= 6;
  300.         float topRad= 1;
  301.         float height= 1.5;
  302.         //glTranslatef(0,0,3);
  303.  
  304.         GLUquadricObj *obj1 = gluNewQuadric();
  305.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  306.     }glPopMatrix();
  307. }
  308.  
  309. void callTableobjectsGlassesDraw()
  310. {
  311.     //Glass draw
  312.     glPushMatrix();{
  313.         glTranslatef(-40,0,-1);
  314.         glPushMatrix();{
  315.             glTranslatef(0,0,15);
  316.             drinksGlassDraw();
  317.         }glPopMatrix();
  318.  
  319.         glPushMatrix();{
  320.             drinksGlassBottomDraw1();
  321.         }glPopMatrix();
  322.  
  323.         glPushMatrix();{
  324.             drinksGlassBottomDraw2();
  325.         }glPopMatrix();
  326.     }glPopMatrix();
  327.  
  328.     glPushMatrix();{
  329.         glTranslatef(20,30,-1);
  330.         glRotatef(150  ,0,0,1);
  331.         glPushMatrix();{
  332.             glTranslatef(0,0,15);
  333.             drinksGlassDraw();
  334.         }glPopMatrix();
  335.  
  336.         glPushMatrix();{
  337.             drinksGlassBottomDraw1();
  338.         }glPopMatrix();
  339.  
  340.         glPushMatrix();{
  341.             drinksGlassBottomDraw2();
  342.         }glPopMatrix();
  343.     }glPopMatrix();
  344.  
  345.     glPushMatrix();{
  346.         glTranslatef(-20,-30,-1);
  347.         glRotatef(21  ,0,0,1);
  348.         glPushMatrix();{
  349.             glTranslatef(0,0,15);
  350.             drinksGlassDraw();
  351.         }glPopMatrix();
  352.  
  353.         glPushMatrix();{
  354.             drinksGlassBottomDraw1();
  355.         }glPopMatrix();
  356.  
  357.         glPushMatrix();{
  358.             drinksGlassBottomDraw2();
  359.         }glPopMatrix();
  360.     }glPopMatrix();
  361.     //Glass draw complete
  362.    
  363. }
  364.  
  365.  
  366. void drinksContainerBottomdraw()
  367. {
  368.     double equ[4];
  369.     equ[0] = 0;
  370.     equ[1] = 0;
  371.     equ[2] = -1;
  372.     equ[3] = 4.5;
  373.  
  374.     glClipPlane(GL_CLIP_PLANE0,equ);
  375.  
  376.         glEnable(GL_CLIP_PLANE0);{
  377.         glColor3f(0,0.9,0); //blue
  378.  
  379.         glPushMatrix();{
  380.             float rad = 22;
  381.             glTranslatef(0,0,rad);
  382.             GLUquadricObj *obj = gluNewQuadric();          
  383.             gluSphere(obj, rad, 200, 200);
  384.  
  385.         }glPopMatrix();
  386.     }
  387.     glDisable(GL_CLIP_PLANE0);
  388. }
  389.  
  390. void drinksContainerMiddledraw()
  391. {
  392.     glPushMatrix();{
  393.         glColor3f(0,0.4,0);
  394.         float bottomRad= 13.5;
  395.         float topRad= 4;
  396.         float height= 5;
  397.         glTranslatef(0,0,4.5);
  398.  
  399.         GLUquadricObj *obj1 = gluNewQuadric();
  400.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  401.     }glPopMatrix();
  402. }
  403.  
  404. void drinksContainerLeftSideDraw()
  405. {
  406.     glPushMatrix();{
  407.         glColor3f(0,0.4,0);
  408.         float bottomRad= 4;
  409.         float topRad= 3;
  410.         float height= 15;
  411.         glTranslatef(0,0,9.5);
  412.  
  413.         GLUquadricObj *obj1 = gluNewQuadric();
  414.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  415.     }glPopMatrix();
  416. }
  417.  
  418. void drinksContainerTopDraw()
  419. {
  420.     glPushMatrix();{
  421.         glColor3f(0,0.4,0);
  422.         float bottomRad= 3;
  423.         float topRad= 5;
  424.         float height= 5;
  425.         glTranslatef(0,0,24);
  426.  
  427.         GLUquadricObj *obj1 = gluNewQuadric();
  428.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  429.     }glPopMatrix();
  430. }
  431.  
  432. void drinksContainerSidesDraw()
  433. {
  434.     double equ[4];
  435.     equ[0] = 0;
  436.     equ[1] = -1;   
  437.     equ[2] = 0;
  438.     equ[3] = 0;
  439.  
  440.     glClipPlane(GL_CLIP_PLANE0,equ);
  441. //glRotatef(90,  1,0,0);
  442.         glEnable(GL_CLIP_PLANE0);{
  443.         glColor3f(0,0.9,0); //blue
  444.     //  glRotatef(90,  1,0,0);
  445.         glPushMatrix();{
  446.             float innerRad = .25;
  447.             float outerRad = 3.5;
  448.             //glTranslatef(0,0,rad);
  449.            
  450.             glScalef(4,1,1);
  451.             GLUquadricObj *obj = gluNewQuadric();          
  452.             glutSolidTorus(innerRad, outerRad, 200, 200);
  453.  
  454.         }glPopMatrix();
  455.     }
  456.     glDisable(GL_CLIP_PLANE0);
  457. }
  458.  
  459. void callTableobjectContainerDraw()
  460. {
  461.     glPushMatrix();{
  462.         //glScalef(1,1,2);
  463.         //glRotatef(90, 1,0,0);
  464.         drinksContainerBottomdraw();
  465.     }glPopMatrix();
  466.  
  467.     glPushMatrix();{
  468.         drinksContainerMiddledraw();
  469.     }glPopMatrix();
  470.  
  471.     glPushMatrix();{
  472.         //glTranslatef(10,0,10);
  473.         //glScalef(1,2,1);
  474.         //glRotatef(90,  0,1,0);
  475.         drinksContainerLeftSideDraw();
  476.     }glPopMatrix();
  477.  
  478.     glPushMatrix();{
  479.         drinksContainerTopDraw();
  480.     }glPopMatrix();
  481.    
  482.     /*glPushMatrix();{
  483.         glTranslatef(0,0,20);
  484.         glRotatef(90,  0,1,0);
  485.         drinksContainerSidesDraw();
  486.     }glPopMatrix();*/
  487.  
  488. }
  489.  
  490. //=================================================================================================================================================================
  491. //Table object Drawn===============================================================================================================================================
  492.  
  493.  
  494. //Chandelier Drawing============================================================================================================================================
  495. //==============================================================================================================================================================
  496.  
  497. //------------------------------------------------------------------
  498. void chadelierDraw()
  499. {
  500.     double equ[4];
  501.     equ[0] = 0;
  502.     equ[1] = 0;
  503.     equ[2] = -1;
  504.     equ[3] = 13.5;
  505.  
  506.     glClipPlane(GL_CLIP_PLANE0,equ);
  507.  
  508.         glEnable(GL_CLIP_PLANE0);{
  509.         glColor3f(0,0.9,0); //blue
  510.  
  511.         glPushMatrix();{
  512.             float rad = 15;
  513.             glTranslatef(0,0,rad);
  514.             GLUquadricObj *obj = gluNewQuadric();          
  515.             gluSphere(obj, rad, 200, 200);
  516.  
  517.         }glPopMatrix();
  518.     }
  519.     glDisable(GL_CLIP_PLANE0);
  520. }
  521.  
  522. void chadelierMiddlePartDraw()
  523. {
  524.         glColor3f(0,0.9,0);
  525.         float bottomRad= 12.1;
  526.         float topRad= 5.5;
  527.         float height= 12;
  528.         glTranslatef(0,0,9);
  529.  
  530.         GLUquadricObj *obj1 = gluNewQuadric();
  531.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  532. }
  533.  
  534. void chadelierUpperPartDraw()
  535. {
  536.     glTranslatef(0,0,21);
  537.     glColor3f(0,0.4,0);
  538.     float baseRad = 5.5;
  539.     float TopRad = 1;
  540.     float height = 5;
  541.     //glutSolidCone(base, height, 200, 200);
  542.     GLUquadricObj *obj1 = gluNewQuadric();
  543.     gluCylinder(obj1,baseRad, TopRad,height,100,100);
  544. }
  545.  
  546. void chadelierConnectorDraw()
  547. {
  548.     double equ[4];
  549.     equ[0] = -1;   
  550.     equ[1] = 0;
  551.     equ[2] = 0;
  552.     equ[3] = -5;
  553.  
  554.     glClipPlane(GL_CLIP_PLANE0,equ);
  555.  
  556.         glEnable(GL_CLIP_PLANE0);{
  557.         glColor3f(0,0.9,0); //blue
  558.  
  559.         glPushMatrix();{
  560.             float innerRad = .25;
  561.             float outerRad = 12;
  562.             glutSolidTorus(innerRad, outerRad, 200, 200);
  563.  
  564.         }glPopMatrix();
  565.     }
  566.     glDisable(GL_CLIP_PLANE0);
  567. }
  568.  
  569. void callChandelierDraw()
  570. {
  571.     glScalef(0.60, .60, .60);
  572.     glTranslatef(0,45,0);
  573.     glPushMatrix();{
  574.         glTranslatef(0,0,15); //radius = 15
  575.         glRotatef(180, 1,0,0);
  576.         chadelierDraw();
  577.     }glPopMatrix();
  578.  
  579.     glPushMatrix();{
  580.         chadelierMiddlePartDraw();
  581.     }glPopMatrix();
  582.  
  583.     glPushMatrix();{
  584.         chadelierUpperPartDraw();
  585.     }glPopMatrix();
  586.  
  587.     glPushMatrix();{
  588.         glTranslatef(0,-16,20.5);
  589.         glRotatef(90,  0,1,0);
  590.         glScalef(1,1.5,1);
  591.         chadelierConnectorDraw();
  592.     }glPopMatrix();
  593.  
  594. }
  595. //------------------------------------------------------------
  596. //------------------------------------------------------------
  597. void chandelierBaseDraw(){
  598.     //glScalef(0.60, .60, .60);
  599.         float bottomRad= 10;
  600.         float topRad= 1.5;
  601.         float height= 3;
  602.         //glTranslatef(0,0,9);
  603.         glColor3f(1,0.9,1);
  604.         GLUquadricObj *obj1 = gluNewQuadric();
  605.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  606. }
  607.  
  608. void chandelierBaseLowerDraw(){
  609.         float bottomRad= 10;
  610.         float topRad= 1.5;
  611.         float height= 3;
  612.         //glTranslatef(0,0,9);
  613.         glColor3f(1,0.9,1);
  614.         GLUquadricObj *obj1 = gluNewQuadric();
  615.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  616. }
  617.  
  618. void callChandelierBase()
  619. {
  620.     glPushMatrix();{
  621.         chandelierBaseDraw();
  622.     }glPopMatrix();
  623.  
  624.     glPushMatrix();{
  625.         glRotatef(180,  1,0,0);
  626.         chandelierBaseLowerDraw();
  627.     }glPopMatrix();
  628. }
  629. //-------------------------------------------------------------
  630.  
  631. //-------------------------------------------------------------
  632.  
  633. void ChandelierTopBase1Draw(){
  634.         float bottomRad= 18;
  635.         float topRad= 18;
  636.         float height= 3;
  637.         //glTranslatef(0,0,9);
  638.         glColor3f(.3,0.3,.3);
  639.         GLUquadricObj *obj1 = gluNewQuadric();
  640.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  641. }
  642.  
  643. void ChandelierTopBaseSurfaceDraw()
  644. {
  645.     float rad= 18;
  646.     glColor3f(0.44,0.26,0.26);
  647.     drawFilledCircle(0,0,rad);
  648. }
  649.  
  650. void ChandelierConnectorTopBaseDraw(){
  651.     float bottomRad= .25;
  652.     float topRad= .25;
  653.     float height= 39;
  654.     glTranslatef(6.7,0,11);
  655.     glColor3f(1,0,0);
  656.     GLUquadricObj *obj1 = gluNewQuadric();
  657.     gluCylinder(obj1,bottomRad,topRad,height,100,100);
  658. }
  659.  
  660. void callChandelierTopBase1(){
  661.     glPushMatrix();{
  662.         ChandelierTopBase1Draw();
  663.     }glPopMatrix();
  664.  
  665.     glPushMatrix();{
  666.         ChandelierTopBaseSurfaceDraw();
  667.     }glPopMatrix();
  668.  
  669.     glPushMatrix();{
  670.         glTranslatef(0,0,3);
  671.         ChandelierTopBaseSurfaceDraw();
  672.     }glPopMatrix();
  673.  
  674.    
  675.  
  676. }
  677.  
  678. void callChandelierBaseConnectorDraw(){
  679.     glPushMatrix();{
  680.         ChandelierConnectorTopBaseDraw();
  681.     }glPopMatrix();
  682.  
  683.     glPushMatrix();{
  684.         glRotatef(120, 0,0,1);
  685.         ChandelierConnectorTopBaseDraw();
  686.     }glPopMatrix();
  687.  
  688.     glPushMatrix();{
  689.         glRotatef(240, 0,0,1);
  690.         ChandelierConnectorTopBaseDraw();
  691.     }glPopMatrix();
  692. }
  693.  
  694. void callChandelierInTotal(){
  695.     glPushMatrix();{
  696.         glScalef(.70, .70, .70);
  697.         glPushMatrix();{
  698.             callChandelierDraw();
  699.         }glPopMatrix();
  700.  
  701.         glPushMatrix();{
  702.             glRotatef(60,   0,0,1);
  703.             callChandelierDraw();
  704.         }glPopMatrix();
  705.  
  706.         glPushMatrix();{
  707.             glRotatef(120,  0,0,1);
  708.             callChandelierDraw();
  709.         }glPopMatrix();
  710.  
  711.         glPushMatrix();{
  712.             glRotatef(180,  0,0,1);
  713.             callChandelierDraw();
  714.         }glPopMatrix();
  715.  
  716.         glPushMatrix();{
  717.             glRotatef(240,  0,0,1);
  718.             callChandelierDraw();
  719.         }glPopMatrix();
  720.  
  721.         glPushMatrix();{
  722.             glRotatef(300,  0,0,1);
  723.             callChandelierDraw();
  724.         }glPopMatrix();
  725.  
  726.         glPushMatrix();{
  727.             glTranslatef(0,0,15);
  728.             callChandelierBase();
  729.         }glPopMatrix();
  730.     }glPopMatrix();
  731.    
  732.     glPushMatrix();{
  733.         glTranslatef(0,0,50);
  734.         glScalef(.50, .50, .50);
  735.         callChandelierTopBase1();
  736.     }glPopMatrix();
  737.  
  738.     glPushMatrix();{
  739.         callChandelierBaseConnectorDraw();
  740.     }glPopMatrix();
  741. }
  742.  
  743. //Chandelier Drawing===============================================================================================================================================
  744. //=================================================================================================================================================================
  745.  
  746. //Kitchen Closet Draw=========================================
  747. //==================================================================
  748. void kitchenClosetBottomDraw()
  749. {
  750.     float size = 5;
  751.     glColor3f(.74, .56, .56);
  752.     glScalef(10,1,1);
  753.     glutSolidCube(size);
  754. }
  755.  
  756. void kitchenClosetLeftDraw(){
  757.     float size = 5;
  758.     glColor3f(.74, .56, .56);
  759.     glTranslatef(22.5,15,0);
  760.     glScalef(1,5,1);
  761.     glutSolidCube(size);
  762. }
  763.  
  764. void kitchenClosetRightDraw(){
  765.     float size = 5;
  766.     glColor3f(.74, .56, .56);
  767.     glTranslatef(-22.5,15,0);
  768.     glScalef(1,5,1);
  769.     glutSolidCube(size);
  770. }
  771.  
  772. void kitchenClosetTopDraw(){
  773.     float size = 5;
  774.     glColor3f(.74, .56, .56);
  775.     glTranslatef(0,30,0);
  776.     glScalef(10,1,1);
  777.     glutSolidCube(size);
  778. }
  779.  
  780. void kitchenClosetInsideDraw()
  781. {
  782.     float size = 5;
  783.     glColor3f(.77, .77, .77);
  784.     glTranslatef(0,14,0);
  785.     glScalef(7.95,5.5,1);
  786.     glutSolidCube(size);
  787. }
  788.  
  789. void kitchenClosetBottomHandleDraw(){
  790.     double equ[4];
  791.     equ[0] = 0;
  792.     equ[1] = -1;   
  793.     equ[2] = 0;
  794.     equ[3] = 0;
  795.  
  796.     glClipPlane(GL_CLIP_PLANE0,equ);
  797.  
  798.         glEnable(GL_CLIP_PLANE0);{
  799.         glColor3f(0,1,0);   //blue
  800.  
  801.         glPushMatrix();{
  802.             float innerRad = .25;
  803.             float outerRad = 3.5;
  804.             glTranslatef(0,0,0);
  805.             glScalef(3,1,1);
  806.             GLUquadricObj *obj = gluNewQuadric();          
  807.             glutSolidTorus(innerRad, outerRad, 200, 200);
  808.  
  809.         }glPopMatrix();
  810.     }
  811.     glDisable(GL_CLIP_PLANE0);
  812. }
  813.  
  814. void callKitchenClosetDraw()
  815. {
  816.     glPushMatrix();{
  817.         kitchenClosetBottomDraw();
  818.     }glPopMatrix();
  819.  
  820.     glPushMatrix();{
  821.         glRotatef(-90, 1,0,0);
  822.         kitchenClosetBottomHandleDraw();
  823.     }glPopMatrix();
  824.  
  825.     glPushMatrix();{
  826.         kitchenClosetLeftDraw();
  827.     }glPopMatrix();
  828.  
  829.     glPushMatrix();{
  830.         kitchenClosetRightDraw();
  831.     }glPopMatrix();
  832.  
  833.     glPushMatrix();{
  834.         kitchenClosetTopDraw();
  835.     }glPopMatrix();
  836.  
  837.     glPushMatrix();{
  838.         kitchenClosetInsideDraw();
  839.     }glPopMatrix();
  840. }
  841.  
  842.  
  843. void callKitchenCloset1Draw(){
  844.     glTranslatef(50, 0, 0);
  845.     callKitchenClosetDraw();
  846. }
  847.  
  848. void callKitchenCloset2Draw()
  849. {
  850.     glTranslatef(0, 36, 0);
  851.     callKitchenClosetDraw();   
  852. }
  853.  
  854. void callKitchenCloset3Draw()
  855. {
  856.     glTranslatef(50, 36, 0);
  857.     callKitchenClosetDraw();   
  858. }
  859. //=================================================================
  860. //Kitchen Closet Draw=========================================
  861.  
  862.  
  863. //================================================================
  864. //Kitchen Drawer Draw=============================================
  865.  
  866. void kitchenDrawerDraw(){
  867.     double equ[4];
  868.     equ[0] = 0;
  869.     equ[1] = -1;   
  870.     equ[2] = 0;
  871.     equ[3] = 26;
  872.  
  873.     glClipPlane(GL_CLIP_PLANE0,equ);
  874.  
  875.         glEnable(GL_CLIP_PLANE0);{
  876.         glColor3f(0.55,0.27,0.07);  //blue
  877.  
  878.         glPushMatrix();{
  879.             float size = 50;
  880.             glutSolidCube(size);
  881.  
  882.         }glPopMatrix();
  883.     }
  884.     glDisable(GL_CLIP_PLANE0);
  885. }
  886.  
  887. void kitchenInsideDrawerDraw(){
  888.     glPushMatrix();{
  889.             float size = 38;
  890.             glutSolidCube(size);
  891.  
  892.         }glPopMatrix();
  893.        
  894.         glPushMatrix();{
  895.                 glTranslatef(-19, -26+52, 4);
  896.                 glScalef(0.80,1,0.60);
  897.                 glColor3f(.54,.20,.14);
  898.                 glBegin(GL_QUADS);{
  899.                 glVertex3f(0,0,-38);
  900.                 glVertex3f(50,0,-38);
  901.                 glVertex3f(50,0,28);
  902.                 glVertex3f(0,0,28);
  903.         }glEnd();
  904.  
  905.         }glPopMatrix();
  906.  
  907.         glPushMatrix();{
  908.             glRotatef(180, 0,0,1);
  909.             glScalef(1.4, 1, 1);
  910.             glTranslatef(0,-22-1,22.5);
  911.             double equ[4];
  912.             equ[0] = 0;
  913.             equ[1] = -1;   
  914.             equ[2] = 0;
  915.             equ[3] = 0;
  916.  
  917.             glClipPlane(GL_CLIP_PLANE0,equ);
  918.  
  919.                 glEnable(GL_CLIP_PLANE0);{
  920.                 glColor3f(1,0,0.5); //blue
  921. //draing handle here also
  922.                
  923.                 glPushMatrix();{
  924.                     glutSolidTorus(.5, 6, 200, 200);
  925.  
  926.             }glPopMatrix();
  927.         }
  928.         glDisable(GL_CLIP_PLANE0);
  929.  
  930.         }glPopMatrix();
  931.        
  932.  
  933. }
  934.  
  935. void kitchenInsideDrawerBorderDraw(){
  936.         float bottomRad= .5;
  937.         float topRad= .5;
  938.         float height= 40;
  939.         glTranslatef(17,21,-18);
  940.         glColor3f(1,0,0);
  941.         GLUquadricObj *obj1 = gluNewQuadric();
  942.         gluCylinder(obj1,bottomRad,topRad,height,100,100);
  943. }
  944.  
  945. void callKitchenDrawerDraw(float x)
  946. {
  947.     glPushMatrix();{
  948.         glTranslatef(x,0,0);
  949.         kitchenDrawerDraw();
  950.     }glPopMatrix();
  951.  
  952.     glPushMatrix();{
  953.         glTranslatef(x,0,0);
  954.         kitchenInsideDrawerDraw();
  955.     }glPopMatrix();
  956.  
  957.     /*glPushMatrix();{
  958.         kitchenInsideDrawerBorderDraw();
  959.     }glPopMatrix();*/
  960. }
  961.  
  962. void callKitchenDrawer1Draw(float x)
  963. {
  964.     callKitchenDrawerDraw(x);
  965.  
  966.     /*glPushMatrix();{
  967.         kitchenInsideDrawerBorderDraw();
  968.     }glPopMatrix();*/
  969. }
  970.  
  971. void callKitchenDrawer2Draw(float x)
  972. {
  973.     callKitchenDrawerDraw(x);
  974.  
  975.     /*glPushMatrix();{
  976.         kitchenInsideDrawerBorderDraw();
  977.     }glPopMatrix();*/
  978. }
  979.  
  980. void callKitchenDrawer3Draw(float x)
  981. {
  982.     callKitchenDrawerDraw(x);
  983.  
  984.     /*glPushMatrix();{
  985.         kitchenInsideDrawerBorderDraw();
  986.     }glPopMatrix();*/
  987. }
  988.  
  989. void callKitchenDrawer4Draw(float x)
  990. {
  991.     callKitchenDrawerDraw(x);
  992.  
  993.     /*glPushMatrix();{
  994.         kitchenInsideDrawerBorderDraw();
  995.     }glPopMatrix();*/
  996. }
  997.  
  998. void callKitchenDrawer5Draw(float x)
  999. {
  1000.     callKitchenDrawerDraw(x);
  1001.  
  1002.     /*glPushMatrix();{
  1003.         kitchenInsideDrawerBorderDraw();
  1004.     }glPopMatrix();*/
  1005. }
  1006.  
  1007. void SteelContainerBottomDraw(){
  1008.     glScalef(12,1,1);
  1009.     glColor3f(.55, .37, .07);  
  1010.     float size = 5;
  1011.     glutSolidCube(size);
  1012. }
  1013.  
  1014. void SteelContainerSteelLayerDraw(){
  1015.     glTranslatef(0,0,3.5);
  1016.     glScalef(12,1,.5);
  1017.     glColor3f(.88, .87, .86);  
  1018.     float size = 5;
  1019.     glutSolidCube(size);
  1020. }
  1021.  
  1022. void SteelContainerLeftDraw()
  1023. {
  1024.     glTranslatef(27.5,0,19);
  1025.     glColor3f(.88, .87, .86);
  1026.     glScalef(1,1,6);
  1027.     float size = 5;
  1028.     glutSolidCube(size);
  1029. }
  1030.  
  1031. void SteelContainerRightDraw(){
  1032.     glTranslatef(-27.5,0,19);
  1033.     glColor3f(.88, .87, .86);
  1034.     glScalef(1,1,6);
  1035.     float size = 5;
  1036.     glutSolidCube(size);
  1037. }
  1038.  
  1039. void SteelContainerTopDraw(){
  1040.     glTranslatef(0,0,37);
  1041.     glColor3f(.88, .87, .86);
  1042.     glScalef(12,1,1.5);
  1043.     float size = 5;
  1044.     glutSolidCube(size);
  1045. }
  1046.  
  1047. void SteelBlackContainerDraw(){
  1048.     glTranslatef(0,0,19);
  1049.     glColor3f(.55, .53, .47);
  1050.     glScalef(10,1,5.8);
  1051.     float size = 5;
  1052.     glutSolidCube(size);
  1053. }
  1054.  
  1055. void callSteelContainerDraw(){
  1056.     glPushMatrix();{
  1057.         SteelContainerBottomDraw();
  1058.     }glPopMatrix();
  1059.    
  1060.     glPushMatrix();{
  1061.         SteelContainerSteelLayerDraw();
  1062.     }glPopMatrix();
  1063.  
  1064.     glPushMatrix();{
  1065.         SteelContainerLeftDraw();
  1066.     }glPopMatrix();
  1067.  
  1068.     glPushMatrix();{
  1069.         SteelContainerRightDraw();
  1070.     }glPopMatrix();
  1071.  
  1072.     glPushMatrix();{
  1073.         SteelContainerTopDraw();
  1074.     }glPopMatrix();
  1075.    
  1076.     glPushMatrix();{
  1077.         SteelBlackContainerDraw();
  1078.     }glPopMatrix();
  1079.  
  1080. /*void callKitchenDrawer3Draw(float x)
  1081. {
  1082.     callKitchenDrawerDraw(x);
  1083.  
  1084.     /*glPushMatrix();{
  1085.         kitchenInsideDrawerBorderDraw();
  1086.     }glPopMatrix();*/
  1087. //}
  1088.  
  1089. }
  1090.  
  1091. void coveKitchen1draw()
  1092. {
  1093.     glTranslatef(15,-0.5,27.5);
  1094.     glScalef(72,10,1);
  1095.     glColor3f(0.9,0.8,0.9);
  1096.     float size = 5;
  1097.     glutSolidCube(size);
  1098. }
  1099.  
  1100. void draweKitchenSink(){
  1101.     glTranslatef(47,-0.5,29.5);
  1102.     glScalef(50,21.5,1);
  1103.     glColor3f(0.80,0.79,0.79);
  1104.     float size = 2;
  1105.     glutSolidCube(size);
  1106. }
  1107.  
  1108. void draweKitchenSinkWaterHolder()
  1109. {
  1110.     glTranslatef(67,2.5,29.5);
  1111.     glScalef(10,10.5,1);
  1112.     glColor3f(0.18,0.18,0.18);
  1113.     float size = 3;
  1114.     glutSolidCube(size);
  1115. }
  1116.  
  1117. void draweKitchenSinkWaterHolder2(){
  1118.     glTranslatef(33.5,4.5,29.5);
  1119.     glScalef(10,8.5,1);
  1120.     glColor3f(0.18,0.18,0.18);
  1121.     float size = 3;
  1122.     glutSolidCube(size);
  1123. }
  1124.  
  1125. void draweKitchenSinkWaterTap(){
  1126.     glTranslatef(-10,-5,-1);
  1127.     glScalef(1, 1, 1);
  1128.     double equ[4];
  1129.     equ[0] = 0;
  1130.     equ[1] = -1;   
  1131.     equ[2] = 0;
  1132.     equ[3] = -1;
  1133.  
  1134.     glClipPlane(GL_CLIP_PLANE0,equ);
  1135.  
  1136.         glEnable(GL_CLIP_PLANE0);{
  1137.         glColor3f(0.18,0.18,0.18);  //blue
  1138.         glTranslatef(45,-5,40);
  1139.         glScalef(.7,.7,.7);
  1140.         glRotatef(90,  0,1,0);
  1141.         glPushMatrix();{
  1142.             float innerRad = 1.5;
  1143.             float outerRad = 15;
  1144.             glutSolidTorus(innerRad, outerRad, 200,200);
  1145.  
  1146.         }glPopMatrix();
  1147.     }
  1148.     glDisable(GL_CLIP_PLANE0);
  1149. }
  1150.  
  1151. void draweKitchenSinkWaterTapC1(){
  1152.     glTranslatef(28,-16,35);
  1153.     glScalef(2,1.5,3);
  1154.     glutSolidCube(2);
  1155. }
  1156.  
  1157. void draweKitchenSinkWaterTapC2(){
  1158.     glTranslatef(44,-16,35);
  1159.     glScalef(2,1.5,3);
  1160.     glutSolidCube(2);
  1161. }
  1162.  
  1163. void callCoverKitchenDraw(){
  1164.     glPushMatrix();{
  1165.         coveKitchen1draw();
  1166.     }glPopMatrix();
  1167.  
  1168.     glPushMatrix();{
  1169.         draweKitchenSink();
  1170.     }glPopMatrix();
  1171.  
  1172.     glPushMatrix();{
  1173.         draweKitchenSinkWaterHolder();
  1174.     }glPopMatrix();
  1175.    
  1176.     glPushMatrix();{
  1177.         draweKitchenSinkWaterHolder2();
  1178.     }glPopMatrix();
  1179.    
  1180.     glPushMatrix();{
  1181.         draweKitchenSinkWaterTap();
  1182.     }glPopMatrix();
  1183.  
  1184.     glPushMatrix();{
  1185.         draweKitchenSinkWaterTapC1();
  1186.     }glPopMatrix();
  1187.  
  1188.     glPushMatrix();{
  1189.         draweKitchenSinkWaterTapC2();
  1190.     }glPopMatrix();
  1191.  
  1192. }
  1193.  
  1194. //================================================================
  1195. //Kitchen Drawer Draw=============================================
  1196.  
  1197.  
  1198. //kitchen object Drawing================================================
  1199. //======================================================================
  1200.  
  1201.  
  1202. //======================================================================
  1203. //kitchen object Drawing===============================================
  1204. void OrangeDraw(float radius){
  1205.     glColor3f(1,.40, 0);
  1206.     GLUquadricObj *obj1 = gluNewQuadric();
  1207.     gluSphere(obj1, radius, 200, 200);
  1208. }
  1209.  
  1210. void OrangeDraw1(float radius){
  1211.     glTranslatef(radius*2,0,0);
  1212.     glColor3f(1,.40, 0);
  1213.     GLUquadricObj *obj1 = gluNewQuadric();
  1214.     gluSphere(obj1, radius, 200, 200);
  1215. }
  1216.  
  1217. void OrangeDraw2(float radius){
  1218.     glTranslatef(0,0,radius*2);
  1219.     glColor3f(1,.40, 0);
  1220.     GLUquadricObj *obj1 = gluNewQuadric();
  1221.     gluSphere(obj1, radius, 200, 200);
  1222. }
  1223.  
  1224. void OrangeDraw3(float radius){
  1225.     glTranslatef(radius*2,0,radius*2);
  1226.     glColor3f(1,.40, 0);
  1227.     GLUquadricObj *obj1 = gluNewQuadric();
  1228.     gluSphere(obj1, radius, 200, 200);
  1229. }
  1230.  
  1231. void OrangeDraw4(float radius){
  1232.     glTranslatef(0,0,radius*4);
  1233.     glColor3f(1,.40, 0);
  1234.     GLUquadricObj *obj1 = gluNewQuadric();
  1235.     gluSphere(obj1, radius, 200, 200);
  1236. }
  1237.  
  1238. void OrangeDraw5(float radius){
  1239.     glTranslatef(radius*2,0,radius*4);
  1240.     glColor3f(1,.40, 0);
  1241.     GLUquadricObj *obj1 = gluNewQuadric();
  1242.     gluSphere(obj1, radius, 200, 200);
  1243. }
  1244.  
  1245. void OrangeDraw6(float radius){
  1246.     glTranslatef(0,0,radius*6);
  1247.     glColor3f(1,.40, 0);
  1248.     GLUquadricObj *obj1 = gluNewQuadric();
  1249.     gluSphere(obj1, radius, 200, 200);
  1250. }
  1251.  
  1252. void OrangeDraw7(float radius){
  1253.     glTranslatef(radius*2,0,radius*6);
  1254.     glColor3f(1,.40, 0);
  1255.     GLUquadricObj *obj1 = gluNewQuadric();
  1256.     gluSphere(obj1, radius, 200, 200);
  1257. }
  1258.  
  1259. void TotalOrangeDraw(float radius){
  1260.     glPushMatrix();{
  1261.         OrangeDraw(radius);
  1262.     }glPopMatrix();
  1263.  
  1264.     glPushMatrix();{
  1265.         OrangeDraw1(radius);
  1266.     }glPopMatrix();
  1267.  
  1268.     glPushMatrix();{
  1269.         OrangeDraw2(radius);
  1270.     }glPopMatrix();
  1271.  
  1272.     glPushMatrix();{
  1273.         OrangeDraw3(radius);
  1274.     }glPopMatrix();
  1275.  
  1276.     glPushMatrix();{
  1277.         OrangeDraw4(radius);
  1278.     }glPopMatrix();
  1279.  
  1280.     glPushMatrix();{
  1281.         OrangeDraw5(radius);
  1282.     }glPopMatrix();
  1283.  
  1284.     glPushMatrix();{
  1285.         OrangeDraw6(radius);
  1286.     }glPopMatrix();
  1287.  
  1288.     glPushMatrix();{
  1289.         OrangeDraw7(radius);
  1290.     }glPopMatrix();
  1291. }
  1292.  
  1293.  
  1294. void SausePanDraw(){
  1295.     glColor3f(0.1, .4,0.6);
  1296.     GLUquadricObj *obj1 = gluNewQuadric();
  1297.     gluCylinder(obj1, 15, 15, 25, 200, 200);
  1298.  
  1299.     glPushMatrix();{
  1300.         glColor3f(1, 0,0);
  1301.         glTranslatef(0,0,15);
  1302.         glScalef(17,3,1);
  1303.         glutSolidCube(2);
  1304.     }glPopMatrix();
  1305.  
  1306. }
  1307.  
  1308. void SausePanUpperSurfaceDraw(){
  1309.     glColor3f(1, 0,0);
  1310.     drawFilledCircle(0,0,15);
  1311. }
  1312.  
  1313. void SausePanLowerSurfaceDraw(){
  1314.     glColor3f(1, 0,0);
  1315.     glTranslatef(0,0,25);
  1316.     drawFilledCircle(0,0,16);
  1317. }
  1318.  
  1319. void SausePanLowerNutsDraw(){
  1320.     glColor3f(0,1,0);
  1321.     glTranslatef(0,0,25);
  1322.     GLUquadricObj *obj1 = gluNewQuadric();
  1323.     gluCylinder(obj1, 3, 3, 3, 200, 200);  
  1324. }
  1325.  
  1326. void SausePanUpperNutsDraw(){
  1327.     glColor3f(0,1,0);
  1328.     glTranslatef(0,0,28.5);
  1329.     drawFilledCircle(0,0,6);
  1330. }
  1331.  
  1332. void TotalSausePanDraw(){
  1333.     glPushMatrix();{
  1334.         SausePanDraw();
  1335.     }glPopMatrix();
  1336.  
  1337.     glPushMatrix();{
  1338.         SausePanUpperSurfaceDraw();
  1339.     }glPopMatrix();
  1340.  
  1341.     glPushMatrix();{
  1342.         SausePanLowerSurfaceDraw();
  1343.     }glPopMatrix();
  1344.  
  1345.     glPushMatrix();{
  1346.         SausePanLowerNutsDraw();
  1347.     }glPopMatrix();
  1348.  
  1349.     glPushMatrix();{
  1350.         SausePanUpperNutsDraw();
  1351.     }glPopMatrix();
  1352. }
  1353.  
  1354. void TotalOrangePotDraw(){
  1355.     glColor3f(1,.76, .76);
  1356.     glTranslatef(0,0,-6);
  1357.     GLUquadricObj *obj1 = gluNewQuadric();
  1358.     gluCylinder(obj1, 20, 20, 30, 200, 200);
  1359.     glTranslatef(0,0,-6);
  1360.     drawFilledCircle(0,0,20);
  1361. }
  1362.  
  1363. void TisshueDraw()
  1364. {
  1365.     glRotatef(-90, 0,1,0);
  1366.     glScalef(1,1,4);
  1367.     glColor3f(1,1, 1);
  1368.     glutSolidTorus(4,8,200,200);
  1369. }
  1370.  
  1371. void TisshuehangerDraw(){
  1372.     glTranslatef(35,12,25);
  1373.     glRotatef(-90,  0,1,0);
  1374.     glColor3f(1,0,0);
  1375.     GLUquadricObj *obj1 = gluNewQuadric();
  1376.     gluCylinder(obj1, 1, 1, 70, 200, 200);
  1377. }
  1378.  
  1379. void DownTisshueDraw(){
  1380.     glColor3f(1, 1, 1);
  1381.     glTranslatef(-30,-6,-26);
  1382.     glScalef(1.5, .5, 1);
  1383.     glRotatef(90,  1,0,0);
  1384.         glBegin(GL_QUADS);{
  1385.             glVertex3f(10,10,10);
  1386.             glVertex3f(30,10,10);
  1387.             glVertex3f(30,30,10);
  1388.             glVertex3f(10,30,10);
  1389.         }glEnd();
  1390. }
  1391.  
  1392. void UpTisshueDraw(){
  1393.     glColor3f(.55, .54, .54);
  1394.     glTranslatef(0, 13, 6);
  1395.     glRotatef(90,   0,1,0);
  1396.     glScalef(18,1,19);
  1397.     glutSolidCube(2);
  1398. }
  1399.  
  1400. void HolderTisshueDraw(){
  1401.     glColor3f(.55, .54, .54);
  1402.     glTranslatef(0, 4, -12);
  1403.     glRotatef(12,   1,0,0);
  1404.     glScalef(20,10,1);
  1405.     glutSolidCube(2);
  1406. }
  1407.  
  1408. void TotalTisshueDraw(){
  1409.     glPushMatrix();{
  1410.         TisshueDraw();
  1411.     }glPopMatrix();
  1412.  
  1413.     glPushMatrix();{
  1414.         TisshuehangerDraw();
  1415.     }glPopMatrix();
  1416.  
  1417.     glPushMatrix();{
  1418.         UpTisshueDraw();
  1419.     }glPopMatrix();
  1420.  
  1421.     glPushMatrix();{
  1422.         DownTisshueDraw();
  1423.     }glPopMatrix();
  1424.  
  1425.     glPushMatrix();{
  1426.         HolderTisshueDraw();
  1427.     }glPopMatrix();
  1428.  
  1429. }
  1430.  
  1431. void FruitOnThePlate(){
  1432.     /*GLUquadricObj *obj1 = gluNewQuadric();
  1433.     gluCylinder(obj1, 3, 6, 1.5, 200, 200);*/
  1434.     double equ[4];
  1435.     equ[0] = 0; //0.x
  1436.     equ[1] = 0; //0.y
  1437.     equ[2] = -1;//-1.z
  1438.     equ[3] = -3;//30
  1439.     glClipPlane(GL_CLIP_PLANE0,equ);
  1440.  
  1441.     glEnable(GL_CLIP_PLANE0);{
  1442.         glColor3f(0,1,0);  
  1443.  
  1444.         glPushMatrix();{
  1445.            
  1446.             glScalef(1.5,1.3,1);
  1447.            
  1448.             GLUquadricObj *obj1 = gluNewQuadric();
  1449.            
  1450.             gluSphere(obj1, 6, 200, 200);
  1451.         }glPopMatrix();
  1452.  
  1453.     }
  1454.     glDisable(GL_CLIP_PLANE0);
  1455.  
  1456.     glTranslatef(0,0,-4);
  1457.     glColor3f(0,1,0);
  1458.     GLUquadricObj *obj2 = gluNewQuadric();
  1459.     gluCylinder(obj2, 6, 14, 3, 200, 200);
  1460. }
  1461.  
  1462. void Orange(){
  1463.     glPushMatrix();{
  1464.         glTranslatef(4,0,0);
  1465.         glColor3f(1, 0.40, 0);
  1466.         GLUquadricObj *obj1 = gluNewQuadric();
  1467.         gluSphere(obj1, 3, 200, 200);
  1468.     }glPopMatrix();
  1469.  
  1470.     glPushMatrix();{
  1471.         glTranslatef(-3,2,0);
  1472.         glColor3f(1, 0.40, 0);
  1473.         GLUquadricObj *obj1 = gluNewQuadric();
  1474.         gluSphere(obj1, 3, 200, 200);
  1475.     }glPopMatrix();
  1476.  
  1477.     glPushMatrix();{
  1478.         glTranslatef(-3,-3,0);
  1479.         glColor3f(1, 0.40, 0);
  1480.         GLUquadricObj *obj1 = gluNewQuadric();
  1481.         gluSphere(obj1, 3, 200, 200);
  1482.     }glPopMatrix();
  1483. }
  1484.  
  1485. void callKitchenObjectDraw(){
  1486.     float radius = 5;
  1487.     /*glPushMatrix();{
  1488.         TotalOrangeDraw(radius);
  1489.     }glPopMatrix();*/
  1490.  
  1491.     glPushMatrix();{
  1492.     glTranslatef(-60,0,-23);
  1493.         glPushMatrix();{
  1494.             glScalef(.40, .40, .40);
  1495.             glTranslatef(40,0,0);
  1496.             TotalSausePanDraw();
  1497.         }glPopMatrix();
  1498.     }glPopMatrix();
  1499.  
  1500.     /*glPushMatrix();{
  1501.         TotalOrangePotDraw();
  1502.     }glPopMatrix();*/
  1503.  
  1504.     glPushMatrix();{
  1505.         glTranslatef(150,0,-18);
  1506.         glScalef(0.80, .80, .80);
  1507.         glPushMatrix();{
  1508.             FruitOnThePlate();
  1509.         }glPopMatrix();
  1510.  
  1511.         glPushMatrix();{
  1512.             Orange();
  1513.         }glPopMatrix();
  1514.     }glPopMatrix();
  1515.  
  1516.     glPushMatrix();{
  1517.         glTranslatef(120,-7,-10);
  1518.         glScalef(0.80, .80, .50);
  1519.         glPushMatrix();{
  1520.             glTranslatef(-60,0,0);
  1521.             glRotatef(180, 0,0,1);
  1522.             glScalef(0.40, .40, .40);
  1523.             TotalTisshueDraw();
  1524.         }glPopMatrix();
  1525.     }glPopMatrix();
  1526.    
  1527. }
  1528.  
  1529.  
  1530.  
  1531. //===============================================================
  1532. //Chair draw====================================================
  1533.  
  1534. void chairTopPartDraw(){
  1535.    
  1536.     double equ[4];
  1537.  
  1538.     equ[0] = 0; //0.x
  1539.     equ[1] = -1;    //0.y
  1540.     equ[2] = 0;//-1.z
  1541.     equ[3] = -4;//30
  1542.  
  1543.     glClipPlane(GL_CLIP_PLANE0,equ);
  1544.  
  1545.     //now we enable the clip plane
  1546.  
  1547.     glEnable(GL_CLIP_PLANE0);{
  1548.         glColor3f(0,0.3,0.8);   //blue
  1549.  
  1550.         glPushMatrix();{
  1551.             glTranslatef(0, 0, 20);
  1552.             glScalef(2,1,1);
  1553.             GLUquadricObj *obj1 = gluNewQuadric();
  1554.             gluCylinder(obj1, 10, 8, 40, 200, 200);
  1555.         }glPopMatrix();
  1556.  
  1557.     }
  1558.     glDisable(GL_CLIP_PLANE0);
  1559. }
  1560.  
  1561. void chairTopCurveDraw(){
  1562.     glTranslatef(0, -6, 15);
  1563.     glRotatef(180,  0,0,1);
  1564.     glRotatef(90,   1,0,0);
  1565.     chairTopPartDraw();
  1566. }
  1567.  
  1568. void chairCurveDraw(){
  1569.     glTranslatef(-17,25,7);
  1570.     glRotatef(45, 1,0,0);
  1571.     glRotatef(90, 0,0,1);
  1572.     double equ[4];
  1573.  
  1574.     equ[0] = -1;    //0.x
  1575.     equ[1] = 0; //0.y
  1576.     equ[2] = 0;//-1.z
  1577.     equ[3] = -4;//30
  1578.  
  1579.    
  1580.  
  1581.     glClipPlane(GL_CLIP_PLANE0,equ);
  1582.  
  1583.     //now we enable the clip plane
  1584.  
  1585.     glEnable(GL_CLIP_PLANE0);{
  1586.         glColor3f(0,0.6,0.9);   //blue
  1587.  
  1588.         glPushMatrix();{
  1589.             glTranslatef(-0, 0, 20);
  1590.             glScalef(.7,.9,1.5);
  1591.             glRotatef(90,  1,0,0);
  1592.             GLUquadricObj *obj1 = gluNewQuadric();
  1593.             gluCylinder(obj1, 9, 10, 40, 200, 200);
  1594.         }glPopMatrix();
  1595.  
  1596.     }
  1597.     glDisable(GL_CLIP_PLANE0);
  1598. }
  1599.  
  1600. void callChairDraw()
  1601. {
  1602.     glPushMatrix();{
  1603.         chairTopPartDraw();
  1604.     }glPopMatrix();
  1605.  
  1606.     glPushMatrix();{
  1607.         chairTopCurveDraw();
  1608.     }glPopMatrix();
  1609.  
  1610.     glPushMatrix();{
  1611.         chairCurveDraw();
  1612.     }glPopMatrix();
  1613.  
  1614.  
  1615. }
  1616. //===============================================================
  1617. //Chair draw====================================================
  1618.  
  1619.  
  1620. //===============================================================
  1621. //Screen Draw===============================================================
  1622.  
  1623. void ScrreenDraw(){
  1624.     glTranslatef(14*0,0,0);
  1625.     glRotatef(45,   0,0,1);
  1626.     glBegin(GL_QUADS);{
  1627.             glVertex3f(0,0,0);
  1628.             glVertex3f(10,0,0);
  1629.             glVertex3f(10,0,90);
  1630.             glVertex3f(0,0,90);
  1631.         }glEnd();
  1632. }
  1633.  
  1634. void Scrreen1Draw(){
  1635.     glTranslatef(14,0,0);
  1636.     glRotatef(135,   0,0,1);
  1637.     glBegin(GL_QUADS);{
  1638.             glVertex3f(0,0,0);
  1639.             glVertex3f(10,0,0);
  1640.             glVertex3f(10,0,90);
  1641.             glVertex3f(0,0,90);
  1642.         }glEnd();
  1643. }
  1644.  
  1645. void Scrreen2Draw(){
  1646.     glTranslatef(14,0,0);
  1647.     glRotatef(45,   0,0,1);
  1648.     glBegin(GL_QUADS);{
  1649.             glVertex3f(0,0,0);
  1650.             glVertex3f(10,0,0);
  1651.             glVertex3f(10,0,90);
  1652.             glVertex3f(0,0,90);
  1653.         }glEnd();
  1654. }
  1655.  
  1656. void Scrreen3Draw(){
  1657.     glTranslatef(28,0,0);
  1658.     glRotatef(135,   0,0,1);
  1659.     glBegin(GL_QUADS);{
  1660.             glVertex3f(0,0,0);
  1661.             glVertex3f(10,0,0);
  1662.             glVertex3f(10,0,90);
  1663.             glVertex3f(0,0,90);
  1664.         }glEnd();
  1665. }
  1666.  
  1667. void callScreenDraw(){
  1668.     glPushMatrix();{
  1669.         ScrreenDraw();
  1670.     }glPopMatrix();
  1671.  
  1672.     glPushMatrix();{
  1673.         Scrreen1Draw();
  1674.     }glPopMatrix();
  1675.  
  1676.     glPushMatrix();{
  1677.         Scrreen2Draw();
  1678.     }glPopMatrix();
  1679.  
  1680.     glPushMatrix();{
  1681.         Scrreen3Draw();
  1682.     }glPopMatrix();
  1683.  
  1684.     glPushMatrix();{
  1685.         glTranslatef(28,0,0);
  1686.         glPushMatrix();{
  1687.             ScrreenDraw();
  1688.         }glPopMatrix();
  1689.  
  1690.         glPushMatrix();{
  1691.             Scrreen1Draw();
  1692.         }glPopMatrix();
  1693.  
  1694.         glPushMatrix();{
  1695.             Scrreen2Draw();
  1696.         }glPopMatrix();
  1697.  
  1698.         glPushMatrix();{
  1699.             Scrreen3Draw();
  1700.         }glPopMatrix();
  1701.  
  1702.     }glPopMatrix();
  1703.  
  1704.     glPushMatrix();{
  1705.         glTranslatef(56,0,0);
  1706.         glPushMatrix();{
  1707.             ScrreenDraw();
  1708.         }glPopMatrix();
  1709.  
  1710.         glPushMatrix();{
  1711.             Scrreen1Draw();
  1712.         }glPopMatrix();
  1713.  
  1714.         glPushMatrix();{
  1715.             Scrreen2Draw();
  1716.         }glPopMatrix();
  1717.  
  1718.         glPushMatrix();{
  1719.             Scrreen3Draw();
  1720.         }glPopMatrix();
  1721.  
  1722.     }glPopMatrix();
  1723.  
  1724.     glPushMatrix();{
  1725.         glTranslatef(-28,0,0);
  1726.         glPushMatrix();{
  1727.             ScrreenDraw();
  1728.         }glPopMatrix();
  1729.  
  1730.         glPushMatrix();{
  1731.             Scrreen1Draw();
  1732.         }glPopMatrix();
  1733.  
  1734.         glPushMatrix();{
  1735.             Scrreen2Draw();
  1736.         }glPopMatrix();
  1737.  
  1738.         glPushMatrix();{
  1739.             Scrreen3Draw();
  1740.         }glPopMatrix();
  1741.  
  1742.     }glPopMatrix();
  1743.  
  1744. }
  1745.  
  1746. //===============================================================
  1747. //Screen Draw===============================================================
  1748.  
  1749. //****************************************************************************************************************************
  1750. //****************************************************************************************************************************
  1751. //****************************************************************************************************************************
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758. void display(){
  1759.  
  1760.     //clear the display
  1761.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  1762.     glClearColor(BLACK, 0); //color black
  1763.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  1764.  
  1765.     /********************
  1766.     / set-up camera here
  1767.     ********************/
  1768.     //load the correct matrix -- MODEL-VIEW matrix
  1769.     glMatrixMode(GL_MODELVIEW);
  1770.  
  1771.     //initialize the matrix
  1772.     glLoadIdentity();
  1773.  
  1774.     //now give three info
  1775.     //1. where is the camera (viewer)?
  1776.     //2. where is the camera is looking?
  1777.     //3. Which direction is the camera's UP direction?
  1778.  
  1779.     //instead of CONSTANT information, we will define a circular path.
  1780. //  gluLookAt(-30,-30,50,   0,0,0,  0,0,1);
  1781.  
  1782.     gluLookAt(cameraRadius*cos(cameraAngle), cameraRadius*sin(cameraAngle), cameraHeight,       0,0,0,      0,0,1);
  1783.     //********************EDit For Last Task
  1784.     //gluLookAt(        0,0,cameraRadius,   cameraRadius*cos(cameraAngle), cameraRadius*sin(cameraAngle), cameraHeight, 0,0,1);
  1785.     //NOTE: the camera still CONSTANTLY looks at the center
  1786.     // cameraAngle is in RADIAN, since you are using inside COS and SIN
  1787.    
  1788.    
  1789.     //again select MODEL-VIEW
  1790.     glMatrixMode(GL_MODELVIEW);
  1791.  
  1792.  
  1793.     /****************************
  1794.     / Add your objects from here
  1795.     ****************************/
  1796.     //add objects
  1797.     //rotate this rectangle around the Z axis
  1798.  
  1799. //************************************************CALL************************************************************************
  1800. //**********************************************ALLL THE***************************************************************************
  1801. //***********************************************DRAWING************************************************************************
  1802.  
  1803. //TABLE, TABLE OBJECTS & cHANDELIER*******************************************************************************************************************************
  1804.  
  1805.     glPushMatrix();{
  1806.         glTranslatef(40, -40, 0);
  1807.         glScalef(0.8, 0.8, 0.8);
  1808.         //TABLE DRAW CALLING+++++++++++++++++++++++++++++++++++++++++
  1809.         glPushMatrix();{
  1810.             float translateTop = 40;
  1811.             glScalef(0.6, 0.6, 0.6);
  1812.             callTableDraw(translateTop);
  1813.         }glPopMatrix();
  1814.         //TABLE DRAW CALLING+++++++++++++++++++++++++++++++++++++++++
  1815.  
  1816.        
  1817.         //Table Objects Draw+++++++++++++++++++++++++++++++++++++++++
  1818.         glPushMatrix();{
  1819.             glTranslatef(0,0,27);
  1820.             glScalef(0.6, 0.6, 0.6);
  1821.             callTableobjectsGlassesDraw();
  1822.         }glPopMatrix();
  1823.  
  1824.         glPushMatrix();{
  1825.             glTranslatef(0,0,27);
  1826.             glScalef(0.6, 0.6, 0.6);
  1827.             callTableobjectContainerDraw();
  1828.         }glPopMatrix();
  1829.         //Table Objects Draw+++++++++++++++++++++++++++++++++++++++++
  1830.  
  1831.         //Chandeier Draw+++++++++++++++++++++++++++++++++++++++++
  1832.    
  1833.         glPushMatrix();{
  1834.             glTranslatef(0,0,70);
  1835.             glScalef(.6, .6, .6);
  1836.             glRotatef(chandelierRotation, 0,0,1);
  1837.             callChandelierInTotal();
  1838.         }glPopMatrix();
  1839.  
  1840.     }glPopMatrix();
  1841. //*****************************************************************************************************************************************************************
  1842. //KITCHEN CLOSET DRAWING*******************************************************************************************************************************************
  1843.     glPushMatrix();{
  1844.         glTranslatef(-80,90,65);// prothom co - ordinate diye sinker dan dike
  1845.         glScalef(0.50, 2.30, .20);
  1846.         glPushMatrix();{
  1847.             glRotatef(90,  1,0,0);
  1848.             glPushMatrix();{
  1849.                 glTranslatef(50,30,0);
  1850.                 glRotatef(180, 0,0,1);
  1851.                 callKitchenClosetDraw();
  1852.             }glPopMatrix();
  1853.  
  1854.             glPushMatrix();{
  1855.                 glTranslatef(50,30,0);
  1856.                 glRotatef(180, 0,0,1);
  1857.                 callKitchenCloset1Draw();
  1858.             }glPopMatrix();
  1859.  
  1860.             glPushMatrix();{
  1861.                 callKitchenCloset2Draw();
  1862.             }glPopMatrix();
  1863.  
  1864.             glPushMatrix();{
  1865.                 callKitchenCloset3Draw();
  1866.             }glPopMatrix();
  1867.  
  1868.         }glPopMatrix();
  1869.  
  1870.     }glPopMatrix();
  1871. //*****************************************************************************************************************************************************************
  1872.  
  1873.  
  1874. //  Ktchen Drawer, Sink Draw***************************************************************************************************************************************
  1875.     glPushMatrix();{
  1876.         glTranslatef(-10,90,20);
  1877.         glRotatef(180, 0, 0, 1);
  1878.         glScalef(0.8, 0.8, 0.8);
  1879.         glPushMatrix();{
  1880.             glScalef(.55, .55, .90);
  1881.             glPushMatrix();{
  1882.                 float palcementofX = 170;
  1883.                 callKitchenDrawerDraw(palcementofX);
  1884.             }glPopMatrix();
  1885.  
  1886.             glPushMatrix();{
  1887.                 float palcementofX = 120;
  1888.                 callKitchenDrawer1Draw(palcementofX);
  1889.             }glPopMatrix();
  1890.            
  1891.             glPushMatrix();{
  1892.                 float palcementofX = 70;
  1893.                 callKitchenDrawer2Draw(palcementofX);
  1894.             }glPopMatrix();
  1895.            
  1896.             glPushMatrix();{
  1897.                 float palcementofX = 20;
  1898.                 callKitchenDrawer3Draw(palcementofX);
  1899.             }glPopMatrix();
  1900.  
  1901.             glPushMatrix();{
  1902.                 glTranslatef(-36.5,0,-22);
  1903.                 glScalef(1,10,1.15);
  1904.                 callSteelContainerDraw();
  1905.             }glPopMatrix();
  1906.  
  1907.             glPushMatrix();{
  1908.                 float palcementofX = -91;
  1909.                 callKitchenDrawer4Draw(palcementofX);
  1910.             }glPopMatrix();
  1911.  
  1912.             glPushMatrix();{
  1913.                 float palcementofX = -141;
  1914.                 callKitchenDrawer5Draw(palcementofX);
  1915.             }glPopMatrix();
  1916.  
  1917.             glPushMatrix();{
  1918.                 callCoverKitchenDraw();
  1919.             }glPopMatrix();
  1920.  
  1921.             glPushMatrix();{
  1922.                 glTranslatef(0,0,50);
  1923.                 callKitchenObjectDraw();
  1924.             }glPopMatrix();
  1925.  
  1926.         }glPopMatrix();
  1927.     }glPopMatrix();
  1928. //*****************************************************************************************************************************************************************
  1929.  
  1930.  
  1931. /*
  1932. //++++++++Chair Draw++++++++++++
  1933.     glPushMatrix();{
  1934.         callChairDraw();
  1935.     }glPopMatrix();
  1936. //++++++++++++++++++++++++++++++
  1937. */
  1938. //++++Screeen Draw++++++++++++++
  1939. /*  glPushMatrix();{
  1940.         callScreenDraw();
  1941.     }glPopMatrix();*/
  1942. //++++++++++++++++++++++++++++++
  1943.    
  1944.  
  1945. //****************************************************************************************************************************
  1946. //****************************************************************************************************************************
  1947. //****************************************************************************************************************************
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981. //************************************************************************************************************************
  1982. /*  glPushMatrix();{    //STORE the state
  1983.         glRotatef(rectAngle,    0,0,1); // in DEGREE
  1984.         //a simple rectangles
  1985.         glColor3f(0.3, 0.4, 0.8);
  1986.         glBegin(GL_QUADS);{
  1987.             glVertex3f(0,0,30);
  1988.             glVertex3f(10,0,30);
  1989.             glVertex3f(10,20,30);
  1990.             glVertex3f(0,20,30);
  1991.         }glEnd();
  1992.  
  1993.         ///lets draw another one in the XY plane --- i.e. Z = 0
  1994.         glColor3f(0.15, 0.2, 0.4);
  1995.         glBegin(GL_QUADS);{
  1996.             glVertex3f(0,0,0);
  1997.             glVertex3f(10,0,0);
  1998.             glVertex3f(10,20,0);
  1999.             glVertex3f(0,20,0);
  2000.         }glEnd();
  2001.     }glPopMatrix();     //the effect of rotation is not there now.
  2002. */
  2003. /*  //FORGET THE FIELD
  2004.     //an square field
  2005.     glColor3f(0.4, 1, 0.4);
  2006.     glBegin(GL_QUADS);{
  2007.         glVertex3f(-100,-100,0);
  2008.         glVertex3f(100,-100,0);
  2009.         glVertex3f(100,100,0);
  2010.         glVertex3f(-100,100,0);
  2011.     }glEnd();
  2012. */
  2013.  
  2014.     //some gridlines along the field
  2015.     int i;
  2016.  
  2017.     //WILL draw grid IF the "canDrawGrid" is true:
  2018.  
  2019.     if(canDrawGrid == true){
  2020.         glColor3f(0.3, 0.3, 0.3);   //grey
  2021.         glBegin(GL_LINES);{
  2022.             for(i=-10;i<=10;i++){
  2023.  
  2024.                 if(i==0)
  2025.                     continue;   //SKIP the MAIN axes
  2026.  
  2027.                 //lines parallel to Y-axis
  2028.                 glVertex3f(i*10, -100, 0);
  2029.                 glVertex3f(i*10,  100, 0);
  2030.  
  2031.                 //lines parallel to X-axis
  2032.                 glVertex3f(-100, i*10, 0);
  2033.                 glVertex3f( 100, i*10, 0);
  2034.             }
  2035.         }glEnd();
  2036.     }
  2037.  
  2038.     // draw the two AXES
  2039.     glColor3f(1, 1, 1); //100% white
  2040.     glBegin(GL_LINES);{
  2041.         //Y axis
  2042.         glVertex3f(0, -150, 0); // intentionally extended to -150 to 150, no big deal
  2043.         glVertex3f(0,  150, 0);
  2044.  
  2045.         //X axis
  2046.         glVertex3f(-150, 0, 0);
  2047.         glVertex3f( 150, 0, 0);
  2048.     }glEnd();
  2049.  
  2050.  
  2051.     //FOUR spheres
  2052.  
  2053.     //draw first two : as half spheres: bottom half.
  2054.     /// the cutting plane equation: z = 30
  2055.     /// we will keep the points with
  2056.     //      z <= 30
  2057.     //OR    0.x + 0.y + 1.z - 30 <= 0
  2058.     //OR    0.x + 0.y - 1.z + 30 >= 0   //// standard format:: ax + by + cz + d >= 0
  2059.    
  2060. /*  double equ[4];
  2061.  
  2062.     equ[0] = 0; //0.x
  2063.     equ[1] = 0; //0.y
  2064.     equ[2] = -1;//-1.z
  2065.     equ[3] = 30;//30
  2066.  
  2067.     glClipPlane(GL_CLIP_PLANE0,equ);
  2068.  
  2069.     //now we enable the clip plane
  2070.  
  2071.     glEnable(GL_CLIP_PLANE0);{
  2072.         glColor3f(0,0.3,0.8);   //blue
  2073.  
  2074.         glPushMatrix();{
  2075.             glTranslatef(50,50,30);
  2076.             glutWireSphere(20, 20, 20); //radius, slices(XY), stacks(Z) -- like earth
  2077.         }glPopMatrix();
  2078.  
  2079.         glPushMatrix();{
  2080.             glTranslatef(50,-50,30);
  2081.             glutWireSphere(20, 20, 20);
  2082.         }glPopMatrix();
  2083.     }
  2084.  
  2085.  
  2086.     glColor3f(0.8,0.3,0);
  2087.     glPushMatrix();{
  2088.         glTranslatef(-50,-50,30);
  2089.         glScalef(2, 2, 0.5);
  2090.         glutWireSphere(10, 20, 20);
  2091.     }glPopMatrix();
  2092.  
  2093.     glColor3f(0.7,0.8,0);
  2094.     glPushMatrix();{
  2095.         glScalef(2, 2, 0.5);
  2096.         glTranslatef(-50,-50,30);
  2097.         glutWireSphere(10, 20, 20);
  2098.     }glPopMatrix();
  2099.     glDisable(GL_CLIP_PLANE0);
  2100.     */
  2101.  
  2102.     //////// ------ NOTE ---- ORDER matters. compare last two spheres!
  2103.  
  2104.     //ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE)
  2105.  
  2106.  
  2107.     glutSwapBuffers();
  2108. }
  2109.  
  2110. void animate(){
  2111.     //codes for any changes in Camera
  2112.  
  2113.     cameraAngle += cameraAngleDelta;    // camera will rotate at 0.002 radians per frame.   // keep the camera steady NOW!!
  2114.    
  2115.     //codes for any changes in Models
  2116.    
  2117.     rectAngle -= 0.01;
  2118.  
  2119.     chandelierRotation += 1;
  2120.  
  2121.     //MISSING SOMETHING? -- YES: add the following
  2122.     glutPostRedisplay();    //this will call the display AGAIN
  2123. }
  2124.  
  2125. void keyboardListener(unsigned char key, int x,int y){
  2126.     switch(key){
  2127.  
  2128.         case '1':   //reverse the rotation of camera
  2129.             cameraAngleDelta = -cameraAngleDelta;
  2130.             break;
  2131.  
  2132.         case '2':   //increase rotation of camera by 10%
  2133.             cameraAngleDelta *= 1.1;
  2134.             break;
  2135.  
  2136.         case '3':   //decrease rotation
  2137.             cameraAngleDelta /= 1.1;
  2138.             break;
  2139.  
  2140.         case '8':   //toggle grids
  2141.             canDrawGrid = 1 - canDrawGrid;
  2142.             break;
  2143.  
  2144.         case 27:    //ESCAPE KEY -- simply exit
  2145.             exit(0);
  2146.             break;
  2147.  
  2148.         default:
  2149.             break;
  2150.     }
  2151. }
  2152.  
  2153. void specialKeyListener(int key, int x,int y){
  2154.     switch(key){
  2155.         case GLUT_KEY_DOWN:     //down arrow key
  2156.             cameraRadius += 10;
  2157.             break;
  2158.         case GLUT_KEY_UP:       // up arrow key
  2159.             if(cameraRadius > 10)
  2160.                 cameraRadius -= 10;
  2161.             break;
  2162.  
  2163.         case GLUT_KEY_RIGHT:
  2164.             break;
  2165.         case GLUT_KEY_LEFT:
  2166.             break;
  2167.  
  2168.         case GLUT_KEY_PAGE_UP:
  2169.             cameraHeight += 10;
  2170.             break;
  2171.         case GLUT_KEY_PAGE_DOWN:
  2172.             cameraHeight -= 10;
  2173.             break;
  2174.  
  2175.         case GLUT_KEY_INSERT:
  2176.             break;
  2177.  
  2178.         case GLUT_KEY_HOME:
  2179.             break;
  2180.         case GLUT_KEY_END:
  2181.             break;
  2182.  
  2183.         default:
  2184.             break;
  2185.     }
  2186. }
  2187.  
  2188. void mouseListener(int button, int state, int x, int y){    //x, y is the x-y of the screen (2D)
  2189.     switch(button){
  2190.         case GLUT_LEFT_BUTTON:
  2191.             if(state == GLUT_DOWN){     // 2 times?? in ONE click? -- solution is checking DOWN or UP
  2192.                 cameraAngleDelta = -cameraAngleDelta;  
  2193.             }
  2194.             break;
  2195.  
  2196.         case GLUT_RIGHT_BUTTON:
  2197.             //........
  2198.             break;
  2199.  
  2200.         case GLUT_MIDDLE_BUTTON:
  2201.             //........
  2202.             break;
  2203.  
  2204.         default:
  2205.             break;
  2206.     }
  2207. }
  2208.  
  2209.  
  2210. void init(){
  2211.     //codes for initialization
  2212.     cameraAngle = 0;    //// init the cameraAngle
  2213.     cameraAngleDelta = 0.007;
  2214.     chandelierRotation=0;
  2215.     rectAngle = 0;
  2216.     canDrawGrid = true;
  2217.     cameraHeight = 80;
  2218.     cameraRadius = 110;
  2219.  
  2220.     //clear the screen
  2221.     glClearColor(BLACK, 0);
  2222.  
  2223.     /************************
  2224.     / set-up projection here
  2225.     ************************/
  2226.     //load the PROJECTION matrix
  2227.     glMatrixMode(GL_PROJECTION);
  2228.    
  2229.     //initialize the matrix
  2230.     glLoadIdentity();
  2231.  
  2232.     //give PERSPECTIVE parameters
  2233.     gluPerspective(7010.1,    10000.0);
  2234.     //field of view in the Y (vertically)
  2235.     //aspect ratio that determines the field of view in the X direction (horizontally)
  2236.     //near distance
  2237.     //far distance
  2238. }
  2239.  
  2240. int main(int argc, char **argv){
  2241.     glutInit(&argc,argv);
  2242.     glutInitWindowSize(500, 500);
  2243.     glutInitWindowPosition(0, 0);
  2244.     glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);   //Depth, Double buffer, RGB color
  2245.  
  2246.     glutCreateWindow("My OpenGL Program");
  2247.  
  2248.     init();
  2249.  
  2250.     glEnable(GL_DEPTH_TEST);    //enable Depth Testing
  2251.  
  2252.     glutDisplayFunc(display);   //display callback function
  2253.     glutIdleFunc(animate);      //what you want to do in the idle time (when no drawing is occuring)
  2254.  
  2255.     //ADD keyboard listeners:
  2256.     glutKeyboardFunc(keyboardListener);
  2257.     glutSpecialFunc(specialKeyListener);
  2258.  
  2259.     //ADD mouse listeners:
  2260.     glutMouseFunc(mouseListener);
  2261.  
  2262.     glutMainLoop();     //The main loop of OpenGL
  2263.  
  2264.     return 0;
  2265. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement