Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<GL/glut.h>
- #include<GL/glu.h>
- #define BLACK 0, 0, 0
- //make a global variable -- for tracking the anglular position of camera
- double cameraAngle; //in radian
- double cameraAngleDelta;
- double chandelierRotation;
- double cameraHeight;
- double cameraRadius;
- double rectAngle; //in degree
- bool canDrawGrid;
- float table_top_height;
- //****************************************************************************************************************************
- //****************************************************************************************************************************
- //*****************************************************************************************************************************
- //Table Draw===================================================================
- void drawFilledCircle(GLfloat x, GLfloat y, GLfloat radius){
- int i;
- int triangleAmount = 200; //# of triangles used to draw circle
- //GLfloat radius = 0.8f; //radius
- GLfloat twicePi = 2.0f * 3.1415926;
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(x, y); // center of circle
- for(i = 0; i <= triangleAmount;i++) {
- glVertex2f(
- x + (radius * cos(i * twicePi / triangleAmount)),
- y + (radius * sin(i * twicePi / triangleAmount))
- );
- }
- glEnd();
- }
- //*******************Table Draw**************************************
- //******************Table materials draw******************************
- void drawWineContainer(float radius)
- {
- glPushMatrix();
- {
- double equ[4];
- equ[0] = 0; //0.x
- equ[1] = -1; //0.y
- equ[2] = 0;//-1.z
- equ[3] = 0;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(1,1,1);
- glPushMatrix();{
- glTranslatef(0,0,radius);
- glScalef(1, 1, 1.5);
- GLUquadricObj *obj = gluNewQuadric();
- gluSphere(obj, radius, 50, 50);
- }
- /*
- glPushMatrix();{
- glTranslatef(50,-50,30);
- glutWireSphere(20, 20, 20);
- }glPopMatrix();*/
- }glPopMatrix();
- glDisable(GL_CLIP_PLANE0);
- }
- glPopMatrix();
- }
- //Table Drawing====================================================================================================================================================
- //=================================================================================================================================================================
- void drawTableSurface(float bottomRadius, float upperRadius, float height){
- glColor3f(0.9, 0.9, 0.9);
- GLUquadricObj *obj = gluNewQuadric();
- gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
- }
- void drawSufaceCircles(GLfloat x, GLfloat y, GLfloat radius){
- int i;
- int triangleAmount = 200; //# of triangles used to draw circle
- //GLfloat radius = 0.8f; //radius
- GLfloat twicePi = 2.0f * 3.1415926;
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(x, y); // center of circle
- for(i = 0; i <= triangleAmount;i++) {
- glVertex2f(
- x + (radius * cos(i * twicePi / triangleAmount)),
- y + (radius * sin(i * twicePi / triangleAmount))
- );
- }
- glEnd();
- }
- void drawUnderCircle1(float innerRad,float outerRad)
- {
- glutSolidTorus(innerRad,outerRad,200,200);
- }
- void drawUnderCircle2(float innerRad,float outerRad)
- {
- glutSolidTorus(innerRad,outerRad,200,200);
- }
- void drawTableLeg(){
- glTranslatef(35,0,0);
- glTranslatef(0,0,29);
- glRotatef(-20, 0,1,0);
- glRotatef(180, 1,0,0);
- glColor3f(1, 0, 0);
- GLUquadricObj *obj = gluNewQuadric();
- float bottomRadius = 3;
- float upperRadius = 1;
- float height = 31;
- gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
- }
- void drawTableLeg1()
- {
- glTranslatef(35,0,0);
- glTranslatef(0,0,27);
- glRotatef(22, 0,1,0);
- glColor3f(1, 0, 0);
- GLUquadricObj *obj = gluNewQuadric();
- float bottomRadius = 3;
- float upperRadius = 1;
- float height = 15;
- gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
- }
- void drawTableCenterbase(){
- glColor3f(1, 0, 0);
- GLUquadricObj *obj = gluNewQuadric();
- float bottomRadius = 1;
- float upperRadius = 1;
- float height = 40;
- gluCylinder(obj, bottomRadius, upperRadius, height, 50, 50);
- }
- void callTableDraw(float translatetop)
- {
- glPushMatrix();{
- glTranslatef(0,0,translatetop);//translatetop = 40;
- float bottomRadius = 50;
- float upperRadius = 50;
- float height = 3;
- drawTableSurface(bottomRadius, upperRadius, height);
- glColor3f(0.30, 0.30, 0.33);
- drawSufaceCircles(0,0,bottomRadius);
- glColor3f(0.30, 0.30, 0.33);
- glTranslatef(0,0,height);
- drawSufaceCircles(0,0,upperRadius);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,translatetop-12.5);
- glColor3f(0.50, 0.16, 0.16);
- float bottomRadius =10.6;float upperRadius = 45;
- drawUnderCircle1(bottomRadius-10, upperRadius-10);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,translatetop-10);
- glColor3f(0.93, 0.71, 0.71);
- float bottomRadius =10.6;float upperRadius = 46.5;
- drawUnderCircle2(bottomRadius-10, upperRadius-10);
- }glPopMatrix();
- glPushMatrix();{
- glPushMatrix();{
- drawTableLeg();
- }glPopMatrix();
- glPushMatrix();{
- drawTableLeg1();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(90, 0,0,1);
- glPushMatrix();{
- drawTableLeg();
- }glPopMatrix();
- glPushMatrix();{
- drawTableLeg1();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(180, 0,0,1);
- glPushMatrix();{
- drawTableLeg();
- }glPopMatrix();
- glPushMatrix();{
- drawTableLeg1();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(270, 0,0,1);
- glPushMatrix();{
- drawTableLeg();
- }glPopMatrix();
- glPushMatrix();{
- drawTableLeg1();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- drawTableCenterbase();
- }glPopMatrix();
- }
- //=================================================================================================================================================================
- //Table Drawing====================================================================================================================================================
- //================================================================================================================================================================
- //Table object Drawing============================================================================================================================================
- void drinksGlassDraw()
- {
- double equ[4];
- equ[0] = 0;
- equ[1] = 0;
- equ[2] = -1;
- equ[3] = 3;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0.9,0,0); //blue
- glPushMatrix();{
- float rad = 10;
- glTranslatef(0,0,rad);
- GLUquadricObj *obj = gluNewQuadric();
- gluSphere(obj, rad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- glPushMatrix();{
- glColor3f(0.4,0,0);
- float bottomRad= 7;
- float topRad= 4;
- float height= 10.5;
- glTranslatef(0,0,3);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void drinksGlassBottomDraw1()
- {
- glPushMatrix();{
- glColor3f(0.4,0,0);
- float bottomRad= 1;
- float topRad= .5;
- float height= 15;
- glTranslatef(0,0,1.5);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void drinksGlassBottomDraw2()
- {
- glPushMatrix();{
- glColor3f(0.4,0,0);
- float bottomRad= 6;
- float topRad= 1;
- float height= 1.5;
- //glTranslatef(0,0,3);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void callTableobjectsGlassesDraw()
- {
- //Glass draw
- glPushMatrix();{
- glTranslatef(-40,0,-1);
- glPushMatrix();{
- glTranslatef(0,0,15);
- drinksGlassDraw();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw1();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw2();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(20,30,-1);
- glRotatef(150 ,0,0,1);
- glPushMatrix();{
- glTranslatef(0,0,15);
- drinksGlassDraw();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw1();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw2();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-20,-30,-1);
- glRotatef(21 ,0,0,1);
- glPushMatrix();{
- glTranslatef(0,0,15);
- drinksGlassDraw();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw1();
- }glPopMatrix();
- glPushMatrix();{
- drinksGlassBottomDraw2();
- }glPopMatrix();
- }glPopMatrix();
- //Glass draw complete
- }
- void drinksContainerBottomdraw()
- {
- double equ[4];
- equ[0] = 0;
- equ[1] = 0;
- equ[2] = -1;
- equ[3] = 4.5;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.9,0); //blue
- glPushMatrix();{
- float rad = 22;
- glTranslatef(0,0,rad);
- GLUquadricObj *obj = gluNewQuadric();
- gluSphere(obj, rad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void drinksContainerMiddledraw()
- {
- glPushMatrix();{
- glColor3f(0,0.4,0);
- float bottomRad= 13.5;
- float topRad= 4;
- float height= 5;
- glTranslatef(0,0,4.5);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void drinksContainerLeftSideDraw()
- {
- glPushMatrix();{
- glColor3f(0,0.4,0);
- float bottomRad= 4;
- float topRad= 3;
- float height= 15;
- glTranslatef(0,0,9.5);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void drinksContainerTopDraw()
- {
- glPushMatrix();{
- glColor3f(0,0.4,0);
- float bottomRad= 3;
- float topRad= 5;
- float height= 5;
- glTranslatef(0,0,24);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }glPopMatrix();
- }
- void drinksContainerSidesDraw()
- {
- double equ[4];
- equ[0] = 0;
- equ[1] = -1;
- equ[2] = 0;
- equ[3] = 0;
- glClipPlane(GL_CLIP_PLANE0,equ);
- //glRotatef(90, 1,0,0);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.9,0); //blue
- // glRotatef(90, 1,0,0);
- glPushMatrix();{
- float innerRad = .25;
- float outerRad = 3.5;
- //glTranslatef(0,0,rad);
- glScalef(4,1,1);
- GLUquadricObj *obj = gluNewQuadric();
- glutSolidTorus(innerRad, outerRad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void callTableobjectContainerDraw()
- {
- glPushMatrix();{
- //glScalef(1,1,2);
- //glRotatef(90, 1,0,0);
- drinksContainerBottomdraw();
- }glPopMatrix();
- glPushMatrix();{
- drinksContainerMiddledraw();
- }glPopMatrix();
- glPushMatrix();{
- //glTranslatef(10,0,10);
- //glScalef(1,2,1);
- //glRotatef(90, 0,1,0);
- drinksContainerLeftSideDraw();
- }glPopMatrix();
- glPushMatrix();{
- drinksContainerTopDraw();
- }glPopMatrix();
- /*glPushMatrix();{
- glTranslatef(0,0,20);
- glRotatef(90, 0,1,0);
- drinksContainerSidesDraw();
- }glPopMatrix();*/
- }
- //=================================================================================================================================================================
- //Table object Drawn===============================================================================================================================================
- //Chandelier Drawing============================================================================================================================================
- //==============================================================================================================================================================
- //------------------------------------------------------------------
- void chadelierDraw()
- {
- double equ[4];
- equ[0] = 0;
- equ[1] = 0;
- equ[2] = -1;
- equ[3] = 13.5;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.9,0); //blue
- glPushMatrix();{
- float rad = 15;
- glTranslatef(0,0,rad);
- GLUquadricObj *obj = gluNewQuadric();
- gluSphere(obj, rad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void chadelierMiddlePartDraw()
- {
- glColor3f(0,0.9,0);
- float bottomRad= 12.1;
- float topRad= 5.5;
- float height= 12;
- glTranslatef(0,0,9);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void chadelierUpperPartDraw()
- {
- glTranslatef(0,0,21);
- glColor3f(0,0.4,0);
- float baseRad = 5.5;
- float TopRad = 1;
- float height = 5;
- //glutSolidCone(base, height, 200, 200);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,baseRad, TopRad,height,100,100);
- }
- void chadelierConnectorDraw()
- {
- double equ[4];
- equ[0] = -1;
- equ[1] = 0;
- equ[2] = 0;
- equ[3] = -5;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.9,0); //blue
- glPushMatrix();{
- float innerRad = .25;
- float outerRad = 12;
- glutSolidTorus(innerRad, outerRad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void callChandelierDraw()
- {
- glScalef(0.60, .60, .60);
- glTranslatef(0,45,0);
- glPushMatrix();{
- glTranslatef(0,0,15); //radius = 15
- glRotatef(180, 1,0,0);
- chadelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- chadelierMiddlePartDraw();
- }glPopMatrix();
- glPushMatrix();{
- chadelierUpperPartDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,-16,20.5);
- glRotatef(90, 0,1,0);
- glScalef(1,1.5,1);
- chadelierConnectorDraw();
- }glPopMatrix();
- }
- //------------------------------------------------------------
- //------------------------------------------------------------
- void chandelierBaseDraw(){
- //glScalef(0.60, .60, .60);
- float bottomRad= 10;
- float topRad= 1.5;
- float height= 3;
- //glTranslatef(0,0,9);
- glColor3f(1,0.9,1);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void chandelierBaseLowerDraw(){
- float bottomRad= 10;
- float topRad= 1.5;
- float height= 3;
- //glTranslatef(0,0,9);
- glColor3f(1,0.9,1);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void callChandelierBase()
- {
- glPushMatrix();{
- chandelierBaseDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(180, 1,0,0);
- chandelierBaseLowerDraw();
- }glPopMatrix();
- }
- //-------------------------------------------------------------
- //-------------------------------------------------------------
- void ChandelierTopBase1Draw(){
- float bottomRad= 18;
- float topRad= 18;
- float height= 3;
- //glTranslatef(0,0,9);
- glColor3f(.3,0.3,.3);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void ChandelierTopBaseSurfaceDraw()
- {
- float rad= 18;
- glColor3f(0.44,0.26,0.26);
- drawFilledCircle(0,0,rad);
- }
- void ChandelierConnectorTopBaseDraw(){
- float bottomRad= .25;
- float topRad= .25;
- float height= 39;
- glTranslatef(6.7,0,11);
- glColor3f(1,0,0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void callChandelierTopBase1(){
- glPushMatrix();{
- ChandelierTopBase1Draw();
- }glPopMatrix();
- glPushMatrix();{
- ChandelierTopBaseSurfaceDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,3);
- ChandelierTopBaseSurfaceDraw();
- }glPopMatrix();
- }
- void callChandelierBaseConnectorDraw(){
- glPushMatrix();{
- ChandelierConnectorTopBaseDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(120, 0,0,1);
- ChandelierConnectorTopBaseDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(240, 0,0,1);
- ChandelierConnectorTopBaseDraw();
- }glPopMatrix();
- }
- void callChandelierInTotal(){
- glPushMatrix();{
- glScalef(.70, .70, .70);
- glPushMatrix();{
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(60, 0,0,1);
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(120, 0,0,1);
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(180, 0,0,1);
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(240, 0,0,1);
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(300, 0,0,1);
- callChandelierDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,15);
- callChandelierBase();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,50);
- glScalef(.50, .50, .50);
- callChandelierTopBase1();
- }glPopMatrix();
- glPushMatrix();{
- callChandelierBaseConnectorDraw();
- }glPopMatrix();
- }
- //Chandelier Drawing===============================================================================================================================================
- //=================================================================================================================================================================
- //Kitchen Closet Draw=========================================
- //==================================================================
- void kitchenClosetBottomDraw()
- {
- float size = 5;
- glColor3f(.74, .56, .56);
- glScalef(10,1,1);
- glutSolidCube(size);
- }
- void kitchenClosetLeftDraw(){
- float size = 5;
- glColor3f(.74, .56, .56);
- glTranslatef(22.5,15,0);
- glScalef(1,5,1);
- glutSolidCube(size);
- }
- void kitchenClosetRightDraw(){
- float size = 5;
- glColor3f(.74, .56, .56);
- glTranslatef(-22.5,15,0);
- glScalef(1,5,1);
- glutSolidCube(size);
- }
- void kitchenClosetTopDraw(){
- float size = 5;
- glColor3f(.74, .56, .56);
- glTranslatef(0,30,0);
- glScalef(10,1,1);
- glutSolidCube(size);
- }
- void kitchenClosetInsideDraw()
- {
- float size = 5;
- glColor3f(.77, .77, .77);
- glTranslatef(0,14,0);
- glScalef(7.95,5.5,1);
- glutSolidCube(size);
- }
- void kitchenClosetBottomHandleDraw(){
- double equ[4];
- equ[0] = 0;
- equ[1] = -1;
- equ[2] = 0;
- equ[3] = 0;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,1,0); //blue
- glPushMatrix();{
- float innerRad = .25;
- float outerRad = 3.5;
- glTranslatef(0,0,0);
- glScalef(3,1,1);
- GLUquadricObj *obj = gluNewQuadric();
- glutSolidTorus(innerRad, outerRad, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void callKitchenClosetDraw()
- {
- glPushMatrix();{
- kitchenClosetBottomDraw();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(-90, 1,0,0);
- kitchenClosetBottomHandleDraw();
- }glPopMatrix();
- glPushMatrix();{
- kitchenClosetLeftDraw();
- }glPopMatrix();
- glPushMatrix();{
- kitchenClosetRightDraw();
- }glPopMatrix();
- glPushMatrix();{
- kitchenClosetTopDraw();
- }glPopMatrix();
- glPushMatrix();{
- kitchenClosetInsideDraw();
- }glPopMatrix();
- }
- void callKitchenCloset1Draw(){
- glTranslatef(50, 0, 0);
- callKitchenClosetDraw();
- }
- void callKitchenCloset2Draw()
- {
- glTranslatef(0, 36, 0);
- callKitchenClosetDraw();
- }
- void callKitchenCloset3Draw()
- {
- glTranslatef(50, 36, 0);
- callKitchenClosetDraw();
- }
- //=================================================================
- //Kitchen Closet Draw=========================================
- //================================================================
- //Kitchen Drawer Draw=============================================
- void kitchenDrawerDraw(){
- double equ[4];
- equ[0] = 0;
- equ[1] = -1;
- equ[2] = 0;
- equ[3] = 26;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0.55,0.27,0.07); //blue
- glPushMatrix();{
- float size = 50;
- glutSolidCube(size);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void kitchenInsideDrawerDraw(){
- glPushMatrix();{
- float size = 38;
- glutSolidCube(size);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-19, -26+52, 4);
- glScalef(0.80,1,0.60);
- glColor3f(.54,.20,.14);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,-38);
- glVertex3f(50,0,-38);
- glVertex3f(50,0,28);
- glVertex3f(0,0,28);
- }glEnd();
- }glPopMatrix();
- glPushMatrix();{
- glRotatef(180, 0,0,1);
- glScalef(1.4, 1, 1);
- glTranslatef(0,-22-1,22.5);
- double equ[4];
- equ[0] = 0;
- equ[1] = -1;
- equ[2] = 0;
- equ[3] = 0;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(1,0,0.5); //blue
- //draing handle here also
- glPushMatrix();{
- glutSolidTorus(.5, 6, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }glPopMatrix();
- }
- void kitchenInsideDrawerBorderDraw(){
- float bottomRad= .5;
- float topRad= .5;
- float height= 40;
- glTranslatef(17,21,-18);
- glColor3f(1,0,0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1,bottomRad,topRad,height,100,100);
- }
- void callKitchenDrawerDraw(float x)
- {
- glPushMatrix();{
- glTranslatef(x,0,0);
- kitchenDrawerDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(x,0,0);
- kitchenInsideDrawerDraw();
- }glPopMatrix();
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void callKitchenDrawer1Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void callKitchenDrawer2Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void callKitchenDrawer3Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void callKitchenDrawer4Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void callKitchenDrawer5Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- }
- void SteelContainerBottomDraw(){
- glScalef(12,1,1);
- glColor3f(.55, .37, .07);
- float size = 5;
- glutSolidCube(size);
- }
- void SteelContainerSteelLayerDraw(){
- glTranslatef(0,0,3.5);
- glScalef(12,1,.5);
- glColor3f(.88, .87, .86);
- float size = 5;
- glutSolidCube(size);
- }
- void SteelContainerLeftDraw()
- {
- glTranslatef(27.5,0,19);
- glColor3f(.88, .87, .86);
- glScalef(1,1,6);
- float size = 5;
- glutSolidCube(size);
- }
- void SteelContainerRightDraw(){
- glTranslatef(-27.5,0,19);
- glColor3f(.88, .87, .86);
- glScalef(1,1,6);
- float size = 5;
- glutSolidCube(size);
- }
- void SteelContainerTopDraw(){
- glTranslatef(0,0,37);
- glColor3f(.88, .87, .86);
- glScalef(12,1,1.5);
- float size = 5;
- glutSolidCube(size);
- }
- void SteelBlackContainerDraw(){
- glTranslatef(0,0,19);
- glColor3f(.55, .53, .47);
- glScalef(10,1,5.8);
- float size = 5;
- glutSolidCube(size);
- }
- void callSteelContainerDraw(){
- glPushMatrix();{
- SteelContainerBottomDraw();
- }glPopMatrix();
- glPushMatrix();{
- SteelContainerSteelLayerDraw();
- }glPopMatrix();
- glPushMatrix();{
- SteelContainerLeftDraw();
- }glPopMatrix();
- glPushMatrix();{
- SteelContainerRightDraw();
- }glPopMatrix();
- glPushMatrix();{
- SteelContainerTopDraw();
- }glPopMatrix();
- glPushMatrix();{
- SteelBlackContainerDraw();
- }glPopMatrix();
- /*void callKitchenDrawer3Draw(float x)
- {
- callKitchenDrawerDraw(x);
- /*glPushMatrix();{
- kitchenInsideDrawerBorderDraw();
- }glPopMatrix();*/
- //}
- }
- void coveKitchen1draw()
- {
- glTranslatef(15,-0.5,27.5);
- glScalef(72,10,1);
- glColor3f(0.9,0.8,0.9);
- float size = 5;
- glutSolidCube(size);
- }
- void draweKitchenSink(){
- glTranslatef(47,-0.5,29.5);
- glScalef(50,21.5,1);
- glColor3f(0.80,0.79,0.79);
- float size = 2;
- glutSolidCube(size);
- }
- void draweKitchenSinkWaterHolder()
- {
- glTranslatef(67,2.5,29.5);
- glScalef(10,10.5,1);
- glColor3f(0.18,0.18,0.18);
- float size = 3;
- glutSolidCube(size);
- }
- void draweKitchenSinkWaterHolder2(){
- glTranslatef(33.5,4.5,29.5);
- glScalef(10,8.5,1);
- glColor3f(0.18,0.18,0.18);
- float size = 3;
- glutSolidCube(size);
- }
- void draweKitchenSinkWaterTap(){
- glTranslatef(-10,-5,-1);
- glScalef(1, 1, 1);
- double equ[4];
- equ[0] = 0;
- equ[1] = -1;
- equ[2] = 0;
- equ[3] = -1;
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0.18,0.18,0.18); //blue
- glTranslatef(45,-5,40);
- glScalef(.7,.7,.7);
- glRotatef(90, 0,1,0);
- glPushMatrix();{
- float innerRad = 1.5;
- float outerRad = 15;
- glutSolidTorus(innerRad, outerRad, 200,200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void draweKitchenSinkWaterTapC1(){
- glTranslatef(28,-16,35);
- glScalef(2,1.5,3);
- glutSolidCube(2);
- }
- void draweKitchenSinkWaterTapC2(){
- glTranslatef(44,-16,35);
- glScalef(2,1.5,3);
- glutSolidCube(2);
- }
- void callCoverKitchenDraw(){
- glPushMatrix();{
- coveKitchen1draw();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSink();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSinkWaterHolder();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSinkWaterHolder2();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSinkWaterTap();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSinkWaterTapC1();
- }glPopMatrix();
- glPushMatrix();{
- draweKitchenSinkWaterTapC2();
- }glPopMatrix();
- }
- //================================================================
- //Kitchen Drawer Draw=============================================
- //kitchen object Drawing================================================
- //======================================================================
- //======================================================================
- //kitchen object Drawing===============================================
- void OrangeDraw(float radius){
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw1(float radius){
- glTranslatef(radius*2,0,0);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw2(float radius){
- glTranslatef(0,0,radius*2);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw3(float radius){
- glTranslatef(radius*2,0,radius*2);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw4(float radius){
- glTranslatef(0,0,radius*4);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw5(float radius){
- glTranslatef(radius*2,0,radius*4);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw6(float radius){
- glTranslatef(0,0,radius*6);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void OrangeDraw7(float radius){
- glTranslatef(radius*2,0,radius*6);
- glColor3f(1,.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, radius, 200, 200);
- }
- void TotalOrangeDraw(float radius){
- glPushMatrix();{
- OrangeDraw(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw1(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw2(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw3(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw4(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw5(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw6(radius);
- }glPopMatrix();
- glPushMatrix();{
- OrangeDraw7(radius);
- }glPopMatrix();
- }
- void SausePanDraw(){
- glColor3f(0.1, .4,0.6);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 15, 15, 25, 200, 200);
- glPushMatrix();{
- glColor3f(1, 0,0);
- glTranslatef(0,0,15);
- glScalef(17,3,1);
- glutSolidCube(2);
- }glPopMatrix();
- }
- void SausePanUpperSurfaceDraw(){
- glColor3f(1, 0,0);
- drawFilledCircle(0,0,15);
- }
- void SausePanLowerSurfaceDraw(){
- glColor3f(1, 0,0);
- glTranslatef(0,0,25);
- drawFilledCircle(0,0,16);
- }
- void SausePanLowerNutsDraw(){
- glColor3f(0,1,0);
- glTranslatef(0,0,25);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 3, 3, 3, 200, 200);
- }
- void SausePanUpperNutsDraw(){
- glColor3f(0,1,0);
- glTranslatef(0,0,28.5);
- drawFilledCircle(0,0,6);
- }
- void TotalSausePanDraw(){
- glPushMatrix();{
- SausePanDraw();
- }glPopMatrix();
- glPushMatrix();{
- SausePanUpperSurfaceDraw();
- }glPopMatrix();
- glPushMatrix();{
- SausePanLowerSurfaceDraw();
- }glPopMatrix();
- glPushMatrix();{
- SausePanLowerNutsDraw();
- }glPopMatrix();
- glPushMatrix();{
- SausePanUpperNutsDraw();
- }glPopMatrix();
- }
- void TotalOrangePotDraw(){
- glColor3f(1,.76, .76);
- glTranslatef(0,0,-6);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 20, 20, 30, 200, 200);
- glTranslatef(0,0,-6);
- drawFilledCircle(0,0,20);
- }
- void TisshueDraw()
- {
- glRotatef(-90, 0,1,0);
- glScalef(1,1,4);
- glColor3f(1,1, 1);
- glutSolidTorus(4,8,200,200);
- }
- void TisshuehangerDraw(){
- glTranslatef(35,12,25);
- glRotatef(-90, 0,1,0);
- glColor3f(1,0,0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 1, 1, 70, 200, 200);
- }
- void DownTisshueDraw(){
- glColor3f(1, 1, 1);
- glTranslatef(-30,-6,-26);
- glScalef(1.5, .5, 1);
- glRotatef(90, 1,0,0);
- glBegin(GL_QUADS);{
- glVertex3f(10,10,10);
- glVertex3f(30,10,10);
- glVertex3f(30,30,10);
- glVertex3f(10,30,10);
- }glEnd();
- }
- void UpTisshueDraw(){
- glColor3f(.55, .54, .54);
- glTranslatef(0, 13, 6);
- glRotatef(90, 0,1,0);
- glScalef(18,1,19);
- glutSolidCube(2);
- }
- void HolderTisshueDraw(){
- glColor3f(.55, .54, .54);
- glTranslatef(0, 4, -12);
- glRotatef(12, 1,0,0);
- glScalef(20,10,1);
- glutSolidCube(2);
- }
- void TotalTisshueDraw(){
- glPushMatrix();{
- TisshueDraw();
- }glPopMatrix();
- glPushMatrix();{
- TisshuehangerDraw();
- }glPopMatrix();
- glPushMatrix();{
- UpTisshueDraw();
- }glPopMatrix();
- glPushMatrix();{
- DownTisshueDraw();
- }glPopMatrix();
- glPushMatrix();{
- HolderTisshueDraw();
- }glPopMatrix();
- }
- void FruitOnThePlate(){
- /*GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 3, 6, 1.5, 200, 200);*/
- double equ[4];
- equ[0] = 0; //0.x
- equ[1] = 0; //0.y
- equ[2] = -1;//-1.z
- equ[3] = -3;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,1,0);
- glPushMatrix();{
- glScalef(1.5,1.3,1);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, 6, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- glTranslatef(0,0,-4);
- glColor3f(0,1,0);
- GLUquadricObj *obj2 = gluNewQuadric();
- gluCylinder(obj2, 6, 14, 3, 200, 200);
- }
- void Orange(){
- glPushMatrix();{
- glTranslatef(4,0,0);
- glColor3f(1, 0.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, 3, 200, 200);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-3,2,0);
- glColor3f(1, 0.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, 3, 200, 200);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-3,-3,0);
- glColor3f(1, 0.40, 0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluSphere(obj1, 3, 200, 200);
- }glPopMatrix();
- }
- void callKitchenObjectDraw(){
- float radius = 5;
- /*glPushMatrix();{
- TotalOrangeDraw(radius);
- }glPopMatrix();*/
- glPushMatrix();{
- glTranslatef(-60,0,-23);
- glPushMatrix();{
- glScalef(.40, .40, .40);
- glTranslatef(40,0,0);
- TotalSausePanDraw();
- }glPopMatrix();
- }glPopMatrix();
- /*glPushMatrix();{
- TotalOrangePotDraw();
- }glPopMatrix();*/
- glPushMatrix();{
- glTranslatef(150,0,-18);
- glScalef(0.80, .80, .80);
- glPushMatrix();{
- FruitOnThePlate();
- }glPopMatrix();
- glPushMatrix();{
- Orange();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(120,-7,-10);
- glScalef(0.80, .80, .50);
- glPushMatrix();{
- glTranslatef(-60,0,0);
- glRotatef(180, 0,0,1);
- glScalef(0.40, .40, .40);
- TotalTisshueDraw();
- }glPopMatrix();
- }glPopMatrix();
- }
- //===============================================================
- //Chair draw====================================================
- void chairTopPartDraw(){
- double equ[4];
- equ[0] = 0; //0.x
- equ[1] = -1; //0.y
- equ[2] = 0;//-1.z
- equ[3] = -4;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- //now we enable the clip plane
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.3,0.8); //blue
- glPushMatrix();{
- glTranslatef(0, 0, 20);
- glScalef(2,1,1);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 10, 8, 40, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void chairTopCurveDraw(){
- glTranslatef(0, -6, 15);
- glRotatef(180, 0,0,1);
- glRotatef(90, 1,0,0);
- chairTopPartDraw();
- }
- void chairCurveDraw(){
- glTranslatef(-17,25,7);
- glRotatef(45, 1,0,0);
- glRotatef(90, 0,0,1);
- double equ[4];
- equ[0] = -1; //0.x
- equ[1] = 0; //0.y
- equ[2] = 0;//-1.z
- equ[3] = -4;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- //now we enable the clip plane
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.6,0.9); //blue
- glPushMatrix();{
- glTranslatef(-0, 0, 20);
- glScalef(.7,.9,1.5);
- glRotatef(90, 1,0,0);
- GLUquadricObj *obj1 = gluNewQuadric();
- gluCylinder(obj1, 9, 10, 40, 200, 200);
- }glPopMatrix();
- }
- glDisable(GL_CLIP_PLANE0);
- }
- void callChairDraw()
- {
- glPushMatrix();{
- chairTopPartDraw();
- }glPopMatrix();
- glPushMatrix();{
- chairTopCurveDraw();
- }glPopMatrix();
- glPushMatrix();{
- chairCurveDraw();
- }glPopMatrix();
- }
- //===============================================================
- //Chair draw====================================================
- //===============================================================
- //Screen Draw===============================================================
- void ScrreenDraw(){
- glTranslatef(14*0,0,0);
- glRotatef(45, 0,0,1);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(10,0,0);
- glVertex3f(10,0,90);
- glVertex3f(0,0,90);
- }glEnd();
- }
- void Scrreen1Draw(){
- glTranslatef(14,0,0);
- glRotatef(135, 0,0,1);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(10,0,0);
- glVertex3f(10,0,90);
- glVertex3f(0,0,90);
- }glEnd();
- }
- void Scrreen2Draw(){
- glTranslatef(14,0,0);
- glRotatef(45, 0,0,1);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(10,0,0);
- glVertex3f(10,0,90);
- glVertex3f(0,0,90);
- }glEnd();
- }
- void Scrreen3Draw(){
- glTranslatef(28,0,0);
- glRotatef(135, 0,0,1);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(10,0,0);
- glVertex3f(10,0,90);
- glVertex3f(0,0,90);
- }glEnd();
- }
- void callScreenDraw(){
- glPushMatrix();{
- ScrreenDraw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen1Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen2Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen3Draw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(28,0,0);
- glPushMatrix();{
- ScrreenDraw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen1Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen2Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen3Draw();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(56,0,0);
- glPushMatrix();{
- ScrreenDraw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen1Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen2Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen3Draw();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-28,0,0);
- glPushMatrix();{
- ScrreenDraw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen1Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen2Draw();
- }glPopMatrix();
- glPushMatrix();{
- Scrreen3Draw();
- }glPopMatrix();
- }glPopMatrix();
- }
- //===============================================================
- //Screen Draw===============================================================
- //****************************************************************************************************************************
- //****************************************************************************************************************************
- //****************************************************************************************************************************
- void display(){
- //clear the display
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(BLACK, 0); //color black
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- /********************
- / set-up camera here
- ********************/
- //load the correct matrix -- MODEL-VIEW matrix
- glMatrixMode(GL_MODELVIEW);
- //initialize the matrix
- glLoadIdentity();
- //now give three info
- //1. where is the camera (viewer)?
- //2. where is the camera is looking?
- //3. Which direction is the camera's UP direction?
- //instead of CONSTANT information, we will define a circular path.
- // gluLookAt(-30,-30,50, 0,0,0, 0,0,1);
- gluLookAt(cameraRadius*cos(cameraAngle), cameraRadius*sin(cameraAngle), cameraHeight, 0,0,0, 0,0,1);
- //********************EDit For Last Task
- //gluLookAt( 0,0,cameraRadius, cameraRadius*cos(cameraAngle), cameraRadius*sin(cameraAngle), cameraHeight, 0,0,1);
- //NOTE: the camera still CONSTANTLY looks at the center
- // cameraAngle is in RADIAN, since you are using inside COS and SIN
- //again select MODEL-VIEW
- glMatrixMode(GL_MODELVIEW);
- /****************************
- / Add your objects from here
- ****************************/
- //add objects
- //rotate this rectangle around the Z axis
- //************************************************CALL************************************************************************
- //**********************************************ALLL THE***************************************************************************
- //***********************************************DRAWING************************************************************************
- //TABLE, TABLE OBJECTS & cHANDELIER*******************************************************************************************************************************
- glPushMatrix();{
- glTranslatef(40, -40, 0);
- glScalef(0.8, 0.8, 0.8);
- //TABLE DRAW CALLING+++++++++++++++++++++++++++++++++++++++++
- glPushMatrix();{
- float translateTop = 40;
- glScalef(0.6, 0.6, 0.6);
- callTableDraw(translateTop);
- }glPopMatrix();
- //TABLE DRAW CALLING+++++++++++++++++++++++++++++++++++++++++
- //Table Objects Draw+++++++++++++++++++++++++++++++++++++++++
- glPushMatrix();{
- glTranslatef(0,0,27);
- glScalef(0.6, 0.6, 0.6);
- callTableobjectsGlassesDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,27);
- glScalef(0.6, 0.6, 0.6);
- callTableobjectContainerDraw();
- }glPopMatrix();
- //Table Objects Draw+++++++++++++++++++++++++++++++++++++++++
- //Chandeier Draw+++++++++++++++++++++++++++++++++++++++++
- glPushMatrix();{
- glTranslatef(0,0,70);
- glScalef(.6, .6, .6);
- glRotatef(chandelierRotation, 0,0,1);
- callChandelierInTotal();
- }glPopMatrix();
- }glPopMatrix();
- //*****************************************************************************************************************************************************************
- //KITCHEN CLOSET DRAWING*******************************************************************************************************************************************
- glPushMatrix();{
- glTranslatef(-80,90,65);// prothom co - ordinate diye sinker dan dike
- glScalef(0.50, 2.30, .20);
- glPushMatrix();{
- glRotatef(90, 1,0,0);
- glPushMatrix();{
- glTranslatef(50,30,0);
- glRotatef(180, 0,0,1);
- callKitchenClosetDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(50,30,0);
- glRotatef(180, 0,0,1);
- callKitchenCloset1Draw();
- }glPopMatrix();
- glPushMatrix();{
- callKitchenCloset2Draw();
- }glPopMatrix();
- glPushMatrix();{
- callKitchenCloset3Draw();
- }glPopMatrix();
- }glPopMatrix();
- }glPopMatrix();
- //*****************************************************************************************************************************************************************
- // Ktchen Drawer, Sink Draw***************************************************************************************************************************************
- glPushMatrix();{
- glTranslatef(-10,90,20);
- glRotatef(180, 0, 0, 1);
- glScalef(0.8, 0.8, 0.8);
- glPushMatrix();{
- glScalef(.55, .55, .90);
- glPushMatrix();{
- float palcementofX = 170;
- callKitchenDrawerDraw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- float palcementofX = 120;
- callKitchenDrawer1Draw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- float palcementofX = 70;
- callKitchenDrawer2Draw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- float palcementofX = 20;
- callKitchenDrawer3Draw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(-36.5,0,-22);
- glScalef(1,10,1.15);
- callSteelContainerDraw();
- }glPopMatrix();
- glPushMatrix();{
- float palcementofX = -91;
- callKitchenDrawer4Draw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- float palcementofX = -141;
- callKitchenDrawer5Draw(palcementofX);
- }glPopMatrix();
- glPushMatrix();{
- callCoverKitchenDraw();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,50);
- callKitchenObjectDraw();
- }glPopMatrix();
- }glPopMatrix();
- }glPopMatrix();
- //*****************************************************************************************************************************************************************
- /*
- //++++++++Chair Draw++++++++++++
- glPushMatrix();{
- callChairDraw();
- }glPopMatrix();
- //++++++++++++++++++++++++++++++
- */
- //++++Screeen Draw++++++++++++++
- /* glPushMatrix();{
- callScreenDraw();
- }glPopMatrix();*/
- //++++++++++++++++++++++++++++++
- //****************************************************************************************************************************
- //****************************************************************************************************************************
- //****************************************************************************************************************************
- //************************************************************************************************************************
- /* glPushMatrix();{ //STORE the state
- glRotatef(rectAngle, 0,0,1); // in DEGREE
- //a simple rectangles
- glColor3f(0.3, 0.4, 0.8);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,30);
- glVertex3f(10,0,30);
- glVertex3f(10,20,30);
- glVertex3f(0,20,30);
- }glEnd();
- ///lets draw another one in the XY plane --- i.e. Z = 0
- glColor3f(0.15, 0.2, 0.4);
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(10,0,0);
- glVertex3f(10,20,0);
- glVertex3f(0,20,0);
- }glEnd();
- }glPopMatrix(); //the effect of rotation is not there now.
- */
- /* //FORGET THE FIELD
- //an square field
- glColor3f(0.4, 1, 0.4);
- glBegin(GL_QUADS);{
- glVertex3f(-100,-100,0);
- glVertex3f(100,-100,0);
- glVertex3f(100,100,0);
- glVertex3f(-100,100,0);
- }glEnd();
- */
- //some gridlines along the field
- int i;
- //WILL draw grid IF the "canDrawGrid" is true:
- if(canDrawGrid == true){
- glColor3f(0.3, 0.3, 0.3); //grey
- glBegin(GL_LINES);{
- for(i=-10;i<=10;i++){
- if(i==0)
- continue; //SKIP the MAIN axes
- //lines parallel to Y-axis
- glVertex3f(i*10, -100, 0);
- glVertex3f(i*10, 100, 0);
- //lines parallel to X-axis
- glVertex3f(-100, i*10, 0);
- glVertex3f( 100, i*10, 0);
- }
- }glEnd();
- }
- // draw the two AXES
- glColor3f(1, 1, 1); //100% white
- glBegin(GL_LINES);{
- //Y axis
- glVertex3f(0, -150, 0); // intentionally extended to -150 to 150, no big deal
- glVertex3f(0, 150, 0);
- //X axis
- glVertex3f(-150, 0, 0);
- glVertex3f( 150, 0, 0);
- }glEnd();
- //FOUR spheres
- //draw first two : as half spheres: bottom half.
- /// the cutting plane equation: z = 30
- /// we will keep the points with
- // z <= 30
- //OR 0.x + 0.y + 1.z - 30 <= 0
- //OR 0.x + 0.y - 1.z + 30 >= 0 //// standard format:: ax + by + cz + d >= 0
- /* double equ[4];
- equ[0] = 0; //0.x
- equ[1] = 0; //0.y
- equ[2] = -1;//-1.z
- equ[3] = 30;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- //now we enable the clip plane
- glEnable(GL_CLIP_PLANE0);{
- glColor3f(0,0.3,0.8); //blue
- glPushMatrix();{
- glTranslatef(50,50,30);
- glutWireSphere(20, 20, 20); //radius, slices(XY), stacks(Z) -- like earth
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(50,-50,30);
- glutWireSphere(20, 20, 20);
- }glPopMatrix();
- }
- glColor3f(0.8,0.3,0);
- glPushMatrix();{
- glTranslatef(-50,-50,30);
- glScalef(2, 2, 0.5);
- glutWireSphere(10, 20, 20);
- }glPopMatrix();
- glColor3f(0.7,0.8,0);
- glPushMatrix();{
- glScalef(2, 2, 0.5);
- glTranslatef(-50,-50,30);
- glutWireSphere(10, 20, 20);
- }glPopMatrix();
- glDisable(GL_CLIP_PLANE0);
- */
- //////// ------ NOTE ---- ORDER matters. compare last two spheres!
- //ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE)
- glutSwapBuffers();
- }
- void animate(){
- //codes for any changes in Camera
- cameraAngle += cameraAngleDelta; // camera will rotate at 0.002 radians per frame. // keep the camera steady NOW!!
- //codes for any changes in Models
- rectAngle -= 0.01;
- chandelierRotation += 1;
- //MISSING SOMETHING? -- YES: add the following
- glutPostRedisplay(); //this will call the display AGAIN
- }
- void keyboardListener(unsigned char key, int x,int y){
- switch(key){
- case '1': //reverse the rotation of camera
- cameraAngleDelta = -cameraAngleDelta;
- break;
- case '2': //increase rotation of camera by 10%
- cameraAngleDelta *= 1.1;
- break;
- case '3': //decrease rotation
- cameraAngleDelta /= 1.1;
- break;
- case '8': //toggle grids
- canDrawGrid = 1 - canDrawGrid;
- break;
- case 27: //ESCAPE KEY -- simply exit
- exit(0);
- break;
- default:
- break;
- }
- }
- void specialKeyListener(int key, int x,int y){
- switch(key){
- case GLUT_KEY_DOWN: //down arrow key
- cameraRadius += 10;
- break;
- case GLUT_KEY_UP: // up arrow key
- if(cameraRadius > 10)
- cameraRadius -= 10;
- break;
- case GLUT_KEY_RIGHT:
- break;
- case GLUT_KEY_LEFT:
- break;
- case GLUT_KEY_PAGE_UP:
- cameraHeight += 10;
- break;
- case GLUT_KEY_PAGE_DOWN:
- cameraHeight -= 10;
- break;
- case GLUT_KEY_INSERT:
- break;
- case GLUT_KEY_HOME:
- break;
- case GLUT_KEY_END:
- break;
- default:
- break;
- }
- }
- void mouseListener(int button, int state, int x, int y){ //x, y is the x-y of the screen (2D)
- switch(button){
- case GLUT_LEFT_BUTTON:
- if(state == GLUT_DOWN){ // 2 times?? in ONE click? -- solution is checking DOWN or UP
- cameraAngleDelta = -cameraAngleDelta;
- }
- break;
- case GLUT_RIGHT_BUTTON:
- //........
- break;
- case GLUT_MIDDLE_BUTTON:
- //........
- break;
- default:
- break;
- }
- }
- void init(){
- //codes for initialization
- cameraAngle = 0; //// init the cameraAngle
- cameraAngleDelta = 0.007;
- chandelierRotation=0;
- rectAngle = 0;
- canDrawGrid = true;
- cameraHeight = 80;
- cameraRadius = 110;
- //clear the screen
- glClearColor(BLACK, 0);
- /************************
- / set-up projection here
- ************************/
- //load the PROJECTION matrix
- glMatrixMode(GL_PROJECTION);
- //initialize the matrix
- glLoadIdentity();
- //give PERSPECTIVE parameters
- gluPerspective(70, 1, 0.1, 10000.0);
- //field of view in the Y (vertically)
- //aspect ratio that determines the field of view in the X direction (horizontally)
- //near distance
- //far distance
- }
- int main(int argc, char **argv){
- glutInit(&argc,argv);
- glutInitWindowSize(500, 500);
- glutInitWindowPosition(0, 0);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); //Depth, Double buffer, RGB color
- glutCreateWindow("My OpenGL Program");
- init();
- glEnable(GL_DEPTH_TEST); //enable Depth Testing
- glutDisplayFunc(display); //display callback function
- glutIdleFunc(animate); //what you want to do in the idle time (when no drawing is occuring)
- //ADD keyboard listeners:
- glutKeyboardFunc(keyboardListener);
- glutSpecialFunc(specialKeyListener);
- //ADD mouse listeners:
- glutMouseFunc(mouseListener);
- glutMainLoop(); //The main loop of OpenGL
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement