Thursday, 28 June 2012

Augmented Reality


    Augmented Reality (AR) is a variation of Virtual Environments (VE), or
Virtual Reality as it is more commonly called. VE technologies completely immerse
a user inside a synthetic environment. While immersed, the user cannot see the real
world around him. In contrast, AR allows the user to see the real world, with virtual
objects superimposed upon or composited with the real world. Therefore, AR
supplements reality, rather than completely replacing it. The figure shows an
example of what this might look like. It shows a real desk with a real phone. Inside
this room are also a virtual lamp and two virtual chairs. Note that the objects are
combined in 3-D, so that the virtual lamp covers the real table, and the real table
covers parts of the two virtual chairs.




    At least six classes of potential AR applications have been explored: medical
visualization, maintenance and repair, annotation, robot path planning, entertainment,
and military aircraft navigation and targeting.

Medical Application



Virtual Fetus


Mockup of virtual Breast Tumor


Manufacturing and Reapir Application



Annotation and Visualization


Robot Path Planning




Thanks for Mr. Ronald T. Azuma the first person who developed Augmented Reality

Tuesday, 26 June 2012

3D vase

3 Dimension vase

vase
===============================

#include <GL/glut.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

const GLfloat light_ambient[]  = { 0, 0, 0, 1 };
const GLfloat light_diffuse[]  = { 1, 1, 1, 1 };
const GLfloat light_specular[] = { 1, 1, 1, 1 };
const GLfloat light_position[] = { 10, 10, 0, 1 };

const GLfloat mat_ambient[]    = { .7, .7, .7, 1 };
const GLfloat mat_diffuse[]    = { .8, .8, .8, 1 };
const GLfloat mat_specular[]   = { 1, 1, 1, 1 };
const GLfloat high_shininess[] = { 90 };

// angle of rotation for the camera direction
float angle=1.0;
// actual vector representing the camera's direction
float lx=0.0f,lz=-1.0f;
// XZ position of the camera
float x=0,z=0,y=5;
GLUquadricObj* quad;
GLUquadric * quadz=gluNewQuadric();

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}

void vase()
{
     glPushMatrix();
     glRotatef(-90,1,0,0);
gluCylinder(quadz,0.1,0.2,0.1,50,50);
     glTranslatef(0,0,0.03);
gluCylinder(quadz,0.1,0,0.05,50,50);
glTranslatef(0,0,0.07);
gluCylinder(quadz,0.2,0.23,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.23,0.25,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.25,0.27,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.27,0.29,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.29,0.30,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.30,0.32,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.32,0.32,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.32,0.32,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.32,0.32,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.32,0.31,0.05,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.31,0.30,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.30,0.29,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.29,0.28,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.28,0.27,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.27,0.26,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.26,0.25,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.25,0.24,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.24,0.23,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.23,0.22,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.22,0.24,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.24,0.25,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.25,0.26,0.06,50,50);
glTranslatef(0,0,0.05);
gluCylinder(quadz,0.26,0.26,0.06,50,50);
     glPopMatrix();  
}

void changeSize(int w, int h)
{
if (h == 0) h = 1;

float ratio =  w * 1.0 / h;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,1,100);
glMatrixMode(GL_MODELVIEW);
}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt( x, y, z, x+lx, 1.0f,  z+lz, 0.0f, 1.0f,  0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
vase();
glFlush ();
glutSwapBuffers();
}


float mouse_klik,mouse_state,mouse_x,mouse_y,tamp_x,tamp_y,wheel=0.5,mx,my,rx,ry,l_x,l_y;

void klik(int button, int state,int x, int y)
{
     mouse_klik = button;
     mouse_state = state;
}

void pasif(int xx, int xy)
{
    if(mouse_klik==0&&mouse_state==0)
    {
        mouse_x=xx;
        mouse_y=xy;
        mx=(tamp_x-mouse_x)*0.005;
        my=(tamp_y-mouse_y)*0.005;
        angle+=mx;
        lx=sin(angle);
        lz=-cos(angle);
        y+=my;
        tamp_x=mouse_x;
        tamp_y=mouse_y;  
    }
    if(mouse_klik==2&&mouse_state==0)
    {
        mouse_x=x;
        mouse_y=y;
        mx=(tamp_x-mouse_x)*1.5;
        my=(tamp_y-mouse_y)*1.5;
        l_x=l_x+mx;
        l_y=l_y+my;
        tamp_x=mouse_x;
        tamp_y=mouse_y;  
    }
  
}

void pasif_v(int x, int y)
{
     tamp_x=x;
     tamp_y=y;    
}

void processNormalKeys(unsigned char key, int px, int py)
{
switch (key) {
case 'a' :
z-=lx*0.1;
x+=lz*0.1;
            break;
case 'd' :
z+=lx*0.1;
x-=lz*0.1;
            break;
case 'w' :
x += lx * 0.1;
z += lz * 0.1;
break;
case 's' :
x -= lx * 0.1;
z -= lz * 0.1;
break;
}
if (key == 27)
exit(0);
}

int main(int argc, char **argv) {

// init GLUT and create window

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(1024,720);
glutCreateWindow("7609040003 Muhammad Ridwan");
// register callbacks
glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
  
glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glutIdleFunc(renderScene);
init();
glutMouseFunc(klik);
    glutMotionFunc(pasif);
    glutPassiveMotionFunc(pasif_v);
glutKeyboardFunc(processNormalKeys);
glEnable(GL_DEPTH_TEST);
glutMainLoop();

return 1;
}


thanks a lot... ^^8

3D locomotive

3 Dimension of Locomotive with solid construction

locomotive
============================

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <math.h>

// angle of rotation for the camera direction
float angle=0.0;
// actual vector representing the camera's direction
float lx=0.0f,lz=-0.1f;
// XZ position of the camera
float x=0.0f,z=5.0f;

static int spin = 0;

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}

void drawhead()
{
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.1,-1);
glutSolidCube(2);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.3,-1);
glutSolidCube(2);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,1,0);
glutSolidCube(1);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,1,-1);
glutSolidCube(1);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,1.5,-1);
glutSolidCube(1);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,1.5,-1.5);
glutSolidCube(1);
glPopMatrix();
}

void topi()
{
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,2,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,2,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,2,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,2,-1.8);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,2,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,2,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,2,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,2,-1.4);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,2,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,2,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,2,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,2,-1);
glutSolidCube(0.5);
glPopMatrix();
///////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,2,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,2,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,2,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,2,-0.6);
glutSolidCube(0.5);
glPopMatrix();
/////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,2,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,2,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,2,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,2,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,2,-0.2);
glutSolidCube(0.5);
glPopMatrix();
}

void drawbody()
{
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,0);
glutSolidSphere(1,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,0.5);
glutSolidSphere(1,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,1);
glutSolidSphere(1,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,1.5);
glutSolidSphere(1,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,2);
glutSolidSphere(1,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,2.5);
glutSolidSphere(1,20,5);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,3);
glutSolidSphere(1,20,5);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0,3.5);
glutSolidSphere(1,20,5);
glPopMatrix();
}

void bawah()
{
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,-1,-1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,-1,-1.8);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,-1,-1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,-1,-1.4);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,-1,-1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,-1,-1);
glutSolidCube(0.5);
glPopMatrix();
///////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,-1,-0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,-1,-0.6);
glutSolidCube(0.5);
glPopMatrix();
/////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-1,-1,-0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(1,-1,-0.2);
glutSolidCube(0.5);
glPopMatrix();

////////////////////////////
////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1);
glutSolidCube(0.5);
glPopMatrix();
///////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();
/////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

////////////////////////////
////////////////////////////

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,2.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,2.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,2.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,0.2);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,2.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,2.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,2.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,0.6);
glutSolidCube(0.5);
glPopMatrix();
////////////////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,3);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,3);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,3);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1);
glutSolidCube(0.5);
glPopMatrix();
///////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,3.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,3.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,3.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1.4);
glutSolidCube(0.5);
glPopMatrix();
/////////////////////////
glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0,-1,3.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(0.5,-1,3.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
glTranslatef(-0.5,-1,3.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(-1,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();

glPushMatrix();
glColor3f(1,1,0);
//glTranslatef(1,-1,1.8);
glutSolidCube(0.5);
glPopMatrix();
}

void cerobong()
{
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.7,2);
glutSolidSphere(0.3,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.9,2);
glutSolidSphere(0.3,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,1.1,2);
glutSolidSphere(0.3,20,5);
glPopMatrix();

///////////////////////////////////

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.7,3);
glutSolidSphere(0.3,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,0.9,3);
glutSolidSphere(0.3,20,5);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0,1.1,3);
glutSolidSphere(0.3,20,5);
glPopMatrix();

//glRotatef(angle,x,y,z);
//glScalef(x,y,z);
}

void roda()
{
//////////kanan/////////
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0.8,-1,-0.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0.8,-1,-1.4);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0.8,-1,0.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0.8,-1,2.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(0.8,-1,3.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();

/////////////////kiri///////

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(-0.8,-1,-0.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();

glPushMatrix();
glColor3f(1,0,0);
glTranslatef(-0.8,-1,-1.4);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(-0.8,-1,0.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(-0.8,-1,2.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();


glPushMatrix();
glColor3f(1,0,0);
glTranslatef(-0.8,-1,3.5);
glRotatef(120,1,1,1);
glScalef(0.5,0.3,0.2);
glutSolidTorus(0.3,1,20,20);
glPopMatrix();
}

void changeSize(int w, int h)
{
if (h == 0) h = 1;

float ratio =  w * 1.0 / h;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,1,100);
glMatrixMode(GL_MODELVIEW);
}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(x,1,z,x+lx,1,z+lz,0,1,0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawhead();
topi();
drawbody();
bawah();
cerobong();
roda();
glFlush ();
glutSwapBuffers();
}

void processSpecialKeys(int key, int xx, int yy)
{
float fraction = 0.1f;
switch (key)
{
case GLUT_KEY_LEFT :
angle -= 0.1;
lx = sin(angle);
lz = -cos(angle);
break;
case GLUT_KEY_RIGHT :
angle += 0.1;
lx = sin(angle);
lz = -cos(angle);
break;
case GLUT_KEY_UP :
x += lx * fraction;
z += lz * fraction;
break;
case GLUT_KEY_DOWN :
x -= lx * fraction;
z -= lz * fraction;
break;
}
}

void processNormalKeys(unsigned char key, int x, int y)
{
if (key == 27) exit(0);
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,50);
glutInitWindowSize(1024,720);
glutCreateWindow("7609040003 - Muhammad Ridwan");

glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glutIdleFunc(renderScene);
init();
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(processSpecialKeys);

glEnable(GL_DEPTH_TEST);

glutMainLoop();

return 1;
}

thanks..

wire bed room

3 dimension bed room with wire construction

bed room
=======================================


#include <math.h>
#include <GL/glut.h>

typedef struct {
float m[4][4];
} matrix3D_t;

typedef struct {
float v[4];
} vector3D_t;

typedef struct {
float x;
float y;
float z;
} point3D_t;

typedef struct {
float x;
float y;
} point2D_t;

typedef struct {
float r;
float g;
float b;
} color_t;

typedef struct {
int NumberofVertices;
short int pnt[32];
} face_t;

typedef struct {
int NumberofVertices;
point3D_t pnt[100];
int NumberofFaces;
face_t fc[32];
} object3D_t;


matrix3D_t createIdentity(void)
{
matrix3D_t u;
int i,j;
for (i=0;i<4;i++) {
for(j=0;j<4;j++) u.m[i][j]=0.;
u.m[i][i]=1.;
}
return u;
}

matrix3D_t operator * (matrix3D_t a,matrix3D_t b)
{
matrix3D_t c;//c=a*b
int i,j,k;
for (i=0;i<4;i++) for (j=0;j<4;j++) {
c.m[i][j]=0;
for (k=0;k<4;k++) c.m[i][j]+=a.m[i][k]*b.m[k][j];
}
return c;
}

vector3D_t operator * (matrix3D_t a, vector3D_t b)
{
vector3D_t c;//c=a*b
int i,j;
for (i=0;i<4;i++) {
c.v[i]=0;
for (j=0;j<4;j++) c.v[i]+=a.m[i][j]*b.v[j];
}
return c;
}

matrix3D_t translationMTX(float dx,float dy,float dz)
{
matrix3D_t trans=createIdentity();
trans.m[0][3]=dx;
trans.m[1][3]=dy;
trans.m[2][3]=dz;
return trans;
}

matrix3D_t rotationXMTX(float theta)
{
matrix3D_t rotate=createIdentity();
float cs=cos(theta);
float sn=sin(theta);
rotate.m[1][1]=cs; rotate.m[1][2]=-sn;
rotate.m[2][1]=sn; rotate.m[2][2]=cs;
return rotate;
}

matrix3D_t rotationYMTX(float theta)
{
matrix3D_t rotate=createIdentity();
float cs=cos(theta);
float sn=sin(theta);
rotate.m[0][0]=cs; rotate.m[0][2]=sn;
rotate.m[2][0]=-sn; rotate.m[2][2]=cs;
return rotate;
}

matrix3D_t rotationZMTX(float theta)
{
matrix3D_t rotate=createIdentity();
float cs=cos(theta);
float sn=sin(theta);
rotate.m[0][0]=cs; rotate.m[0][1]=-sn;
rotate.m[1][0]=sn; rotate.m[1][1]=cs;
return rotate;
}

matrix3D_t scalingMTX(float factorx,float factory,float factorz)
{
matrix3D_t scale=createIdentity();
scale.m[0][0]=factorx;
scale.m[1][1]=factory;
scale.m[2][2]=factorz;
return scale;
}

matrix3D_t perspectiveMTX(float eyelength)
{
matrix3D_t perspective=createIdentity();
perspective.m[3][2]=-1./eyelength;
return perspective;
}

point2D_t Vector2Point2D(vector3D_t vec)
{
point2D_t pnt;
pnt.x=vec.v[0];
pnt.y=vec.v[1];
return pnt;
}

point3D_t Vector2Point3D(vector3D_t vec)
{
point3D_t pnt;
pnt.x=vec.v[0];
pnt.y=vec.v[1];
pnt.z=vec.v[2];
return pnt;
}

vector3D_t Point2Vector(point3D_t pnt)
{
vector3D_t vec;
vec.v[0]=pnt.x;
vec.v[1]=pnt.y;
vec.v[2]=pnt.z;
vec.v[3]=1.;
return vec;
}

vector3D_t homogenizeVector(vector3D_t vec)
{
int i;
for (i=0;i<3;i++) {
vec.v[i]/=vec.v[3];
}
vec.v[3]=1.;
return vec;
}

vector3D_t unitVector(vector3D_t vec)
{
int i;
float vec2=0.;
float vec1,invvec1;
for (i=0;i<3;i++) {
vec2+=vec.v[i]*vec.v[i];
}
vec1=sqrt(vec2);
if (vec1!=0.) {
invvec1=1./vec1;
for (i=0;i<3;i++) {
vec.v[i]*=invvec1;
}
}
vec.v[3]=1.;
return vec;
}


float operator * (vector3D_t a, vector3D_t b)
{
float c;//c=a*b
int i;
c=0;
for (i=0;i<3;i++) {
c+=a.v[i]*b.v[i];
}
return c;
}

// outer product (cross product ) of homogeneous vector
//       i         j         k
//       a0       a1        a2
//       b0       b1        b2
vector3D_t operator ^ (vector3D_t a, vector3D_t b)
{
vector3D_t c;//c=a*b
c.v[0]=a.v[1]*b.v[2]-a.v[2]*b.v[1];
c.v[1]=a.v[2]*b.v[0]-a.v[0]*b.v[2];
c.v[2]=a.v[0]*b.v[1]-a.v[1]*b.v[0];
c.v[3]=1.;
return c;
}

vector3D_t operator - (vector3D_t v1,vector3D_t v0)
{
vector3D_t c;//c=v1-v0
c.v[0]=v1.v[0]-v0.v[0];
c.v[1]=v1.v[1]-v0.v[1];
c.v[2]=v1.v[2]-v0.v[2];
c.v[3]=1.;
return c;
}

vector3D_t operator - (vector3D_t v)
{
vector3D_t c;//c=-v
c.v[0]=-v.v[0];
c.v[1]=-v.v[1];
c.v[2]=-v.v[2];
c.v[3]=1.;
return c;
}

vector3D_t operator * (float r, vector3D_t b)
{
vector3D_t c;//c=r*b
int i;
for (i=0;i<3;i++) {
c.v[i]=r*b.v[i];
}
c.v[3]=1.;
return c;
}

vector3D_t operator * (vector3D_t b, float r)
{
vector3D_t c;//c=r*b
int i;
for (i=0;i<3;i++) {
c.v[i]=r*b.v[i];
}
c.v[3]=1.;
return c;
}

void setColor(float red,float green,float blue)
{
glColor3f(red, green, blue);
}

void setColor(color_t col)
{
glColor3f(col.r, col.g, col.b);
}

void drawDot(float x,float y)
{
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
}

void drawLine(float x1, float y1, float x2, float y2)
{
glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glEnd();
}

void drawLine(point2D_t p1,point2D_t p2)
{
drawLine(p1.x,p1.y,p2.x,p2.y);
}

void drawPolyline(point2D_t pnt[],int n)
{
int i;
glBegin(GL_LINE_STRIP);
for (i=0;i<n;i++) {
glVertex2f(pnt[i].x, pnt[i].y);
}
glEnd();
}


void drawPolygon(point2D_t pnt[],int n)
{
int i;
glBegin(GL_LINE_LOOP);
for (i=0;i<n;i++) {
glVertex2f(pnt[i].x, pnt[i].y);
}
glEnd();
}


void fillPolygon(point2D_t pnt[],int n,color_t color)
{
int i;
setColor(color);
glBegin(GL_POLYGON);
for (i=0;i<n;i++) {
glVertex2f(pnt[i].x, pnt[i].y);
}
glEnd();
}


void gradatePolygon(point2D_t pnt[],color_t col[],int num)
{
int i;
glBegin(GL_POLYGON);
for (i=0;i<num;i++) {
setColor(col[i]);
glVertex2f(pnt[i].x, pnt[i].y);
}
glEnd();
}



void write(float x, float y, float z, void *font, char *string)
{
  char *c;
  glRasterPos3f(x, y,z);
  for (c=string; *c != '\0'; c++)
  {
    glutBitmapCharacter(font, *c);
  }
}

void title()
{
glColor3f(1.,1.,1.);
write(-300, 220, 0, GLUT_BITMAP_HELVETICA_12 , "Muhammad Ridwan");
write(-300, 200, 0, GLUT_BITMAP_HELVETICA_12 , "7609040003") ;
}


void drawcharX(float x,float y)
{
drawLine(x,y,x+10,y+12);drawLine(x,y+12,x+10,y);
}

void drawcharY(float x,float y)
{
drawLine(x+5,y,x+5,y+7);drawLine(x,y+12,x+5,y+7);drawLine(x+10,y+12,x+5,y+7);
}

void drawcharZ(float x,float y)
{
drawLine(x,y+12,x+10,y+12);drawLine(x+10,y+12,x,y);drawLine(x,y,x+10,y);
}

void drawAxes(matrix3D_t view)
{
#define HALFAXIS  220
#define HALFAXIS1 (HALFAXIS-10)
point3D_t axes[14]={
{-HALFAXIS,0,0},{HALFAXIS,0,0},{HALFAXIS1,5,0},{HALFAXIS1,0,0},{0,0,0},
{0,-HALFAXIS,0},{0,HALFAXIS,0},{0,HALFAXIS1,5},{0,HALFAXIS1,0},{0,0,0},
{0,0,-HALFAXIS},{0,0,HALFAXIS},{5,0,HALFAXIS1},{0,0,HALFAXIS1}
};
vector3D_t vec[14];
point2D_t buff[14];
int i;
for (i=0;i<14;i++) {
vec[i]=Point2Vector(axes[i]);
vec[i]=view*vec[i];
buff[i]=Vector2Point2D(vec[i]);
}
drawPolyline(buff,14);
drawcharX(buff[1].x,buff[1].y);
drawcharY(buff[6].x,buff[6].y);
drawcharZ(buff[11].x-14,buff[11].y);
}

///////////////////////////////////////////////////////////////////////////

void pillow()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{100,-90,30},{100,-90,-30},{70,-90,-30},{70,-90,30},
{100,-100,30},{100,-100,-30},{70,-100,-30},{70,-100,30}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};

/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void bed()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-100,50},{120,-100,-50},{-30,-100,-50},{-30,-100,50},
{120,-120,50},{120,-120,-50},{-30,-120,-50},{-30,-120,50}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};



/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void carpet()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{70,-119,70},{70,-119,-70},{-40,-119,-70},{-40,-119,70},
{70,-120,70},{70,-120,-70},{-40,-120,-70},{-40,-120,70}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};



/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void beddo()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-70,50},{120,-70,-50},{110,-70,-50},{110,-70,50},
{120,-120,50},{120,-120,-50},{110,-120,-50},{110,-120,50}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};



/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void window1()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{-50,-10,-170},{-50,-10,-175},{-90,-10,-175},{-90,-10,-170},
{-50,-70,-170},{-50,-70,-175},{-90,-70,-175},{-90,-70,-170}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};



/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[3];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void window2()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{50,-10,-170},{50,-10,-175},{90,-10,-175},{90,-10,-170},
{50,-70,-170},{50,-70,-175},{90,-70,-175},{90,-70,-170}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[3];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void door()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{-117,-10,-110},{-117,-10,-70},{-122,-10,-70},{-122,-10,-110},
{-117,-120,-110},{-117,-120,-70},{-122,-120,-70},{-122,-120,-110}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[3];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void drawer()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-100,-90},{120,-100,-60},{90,-100,-60},{90,-100,-90},
{120,-120,-90},{120,-120,-60},{90,-120,-60},{90,-120,-90}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[3];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-10,100},{120,-10,60},{110,-10,60},{110,-10,100},
{120,-120,100},{120,-120,60},{110,-120,60},{110,-120,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard1()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-98,100},{120,-98,60},{110,-98,60},{110,-98,100},
{120,-120,100},{120,-120,60},{110,-120,60},{110,-120,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard2()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-76,100},{120,-76,60},{110,-76,60},{110,-76,100},
{120,-98,100},{120,-98,60},{110,-98,60},{110,-98,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard3()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-54,100},{120,-54,60},{110,-54,60},{110,-54,100},
{120,-76,100},{120,-76,60},{110,-76,60},{110,-76,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard4()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-32,100},{120,-32,60},{110,-32,60},{110,-32,100},
{120,-54,100},{120,-54,60},{110,-54,60},{110,-54,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void cupboard5()
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);


object3D_t cube={
8,
{
{120,-10,100},{120,-10,60},{110,-10,60},{110,-10,100},
{120,-32,100},{120,-32,60},{110,-32,60},{110,-32,100}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};


/*{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}*/

vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[2];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;

}

void userdraw(void)
{
static int tick=0;
float theta=0.5;
matrix3D_t tilting=rotationXMTX(theta)*rotationYMTX(-theta);
setColor(1,1,1);
//drawAxes(tilting);



object3D_t cube={
8,
{
{120,120,120},{120,120,-120},{-120,120,-120},{-120,120,120},
{120,-120,200},{120,-120,-200},{-120,-120,-200},{-120,-120,200}
},
6,
{
{4,{0,1,2,3}},{4,{0,4,5,1}},{4,{1,5,6,2}},
{4,{2,6,7,3}},{4,{3,7,4,0}},{4,{7,6,5,4}}
}
};
vector3D_t vec[32];
vector3D_t vecbuff[32];
vector3D_t NormalVector;
point2D_t buff[32];
float normalzi;
int i,j;
setColor(0,1,0);
matrix3D_t rot,mat;

rot=rotationYMTX(0.001*tick);
mat=tilting*rot;
for (i=0;i<cube.NumberofVertices;i++) {
vec[i]=Point2Vector(cube.pnt[i]);
vec[i]=mat*vec[i];
}

for (i=0;i<cube.NumberofFaces;i++) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
vecbuff[j]=vec[cube.fc[i].pnt[j]];
}
NormalVector=(vecbuff[1]-vecbuff[0])^(vecbuff[2]-vecbuff[0]);
normalzi=NormalVector.v[3];
if (0.<normalzi) {
for (j=0;j<cube.fc[i].NumberofVertices;j++) {
buff[j]=Vector2Point2D(vecbuff[j]);
}
drawPolygon(buff,cube.fc[i].NumberofVertices);
}
}
tick++;
}

void display(void)
{
glClear( GL_COLOR_BUFFER_BIT);
title();
userdraw();
drawer();
beddo();
bed();
pillow();
cupboard();
cupboard1();
cupboard2();
cupboard3();
cupboard4();
cupboard5();
door();
window1();
window2();
carpet();
glutSwapBuffers();
}

int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowPosition(100,100);
glutInitWindowSize(640,480);
glutCreateWindow ("7609040003");
glClearColor(0.0, 0.0, 0.0, 0.0);
gluOrtho2D(-320., 320., -240.0, 240.0);
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}


thanks.. ^^