Monday, March 12, 2007

Buy Element Tech Decks



Previous Practice No.2
This is the archive of humanoid that moves according to the parameter is muevete function.

# include # include # include


# include # include void

pint (xAxis float, float ejey, ejez float, float r, char c) void
muevete (abd float, float abi, apd float, float api);

void init (void) {
glClearColor
(0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);}


void display (void) {

glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.1, 0.1, 0.1);
glLoadIdentity ();
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (1.0, 1.0, 1.0);

glEnable (GL_DEPTH_TEST);
glPushMatrix ();
glLoadIdentity ();
muevete ( 8, -8.8, -8);
glPopMatrix ();
Sleep (1000);
surface (0,0,1, -15, 'r');
glutPostRedisplay ();
Sleep (1000);
glDisable (GL_DEPTH_TEST);
glPushMatrix ();
Sleep (1000);
muevete(8,-8,8,-8);
glPopMatrix();
glLoadIdentity();
pinta(0,0,1,-15,'r');
glutSwapBuffers();
glFlush ();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}

/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE GLUT_RGB);
glutInitWindowSize (500, 300);
glutInitWindowPosition (300,230);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();

return 0;
}


void pinta(float ejex, float ejey, float ejez,float r,char c)
{
float x1,y1,z1,r1;
char c1;
x1=ejex;
y1=ejey;
z1=ejez;
r1=r;
c1=c;
glPushMatrix();
if (c1 == 'r')
glRotatef (r1, x1, Y1, z1);
else if (c1 == 't')
glTranslatef (x1, Y1, z1);

/ / glTranslatef cabeza
(0.0f, 2.5f, 0.0f);
glutWireCube (0.5);
glScalef (2.5,2.5,2.0);
glTranslatef (0.0f,-0.45f, 0.0f);
glutWireCube (0.5);
/ / tronco
glPushMatrix ();
glTranslatef (-0.1f,-0.55f, 0.0f);
glScalef (-. 3,1.2,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ / glPushMatrix piernas
();
glTranslatef (0.1f,-0.55f, 0.0f);
glScalef (-. 3,1.2,1.0);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (0.0f,-0.7f, 0.0f);
glutWireCube (0.5);
glPopMatrix ();


glTranslatef (0.7f,-0.7f, 0.0f);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (0.0f, .35 f, 0.0f);
glScalef (1.1, .4,1.0);
glutWireCube (0.5);
glPopMatrix ();

glPushMatrix ();
glTranslatef (-0.7f , .35 f, 0.0f);
glScalef (1.1, .4,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ / pies
glPushMatrix ();
glTranslatef (.3 f, -. 3f, 0.0 f);
glScalef (1.6, .2,1.0);
glutWireCube (0.5);
glPopMatrix ();

glTranslatef (-. 8f, -. 3f, 0.0f);
glScalef (1.6, .2,1.0)
glutWireCube (0.5);


glPopMatrix ();
/ / right arm
glPushMatrix ();
glTranslatef (0.35f, 0.1f, 0.0f);
glScalef (0.5,0.4, .5);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (0.4f, 0.0f, 0.0f);
glScalef (0.5,1.2,1.0);
glutWireCube (0.5);

glPopMatrix ();
glTranslatef (0.8f, 0.0f, 0.0f);
glutWireCube (0.5);
/ / left arm
glPopMatrix ();
glTranslatef (-0.35f, 0.1f, 0.0f);
glScalef (0.5,0.4, .5);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (-0.4f, 0.0f, 0.0f);
glScalef (0.5,1.2,1.0);
glutWireCube (0.5);

glPopMatrix ();
glTranslatef (- 0.8f, 0.0f, 0.0f);
glutWireCube (0.5);
glPopMatrix ();}



void muevete (brader float, float braizq, belongs to float, float pieizq)
{float
brazod, brazoi, pied , piei;

brazod = brader;
brazoi = braizq;
pied = owned;
piei = pieizq;

glPushMatrix ();
/ / cabeza
glTranslatef (0.0f, 2.5f, 0.0f);
glutWireCube ( 0.5);

/ / tronco
glScalef (2.5,3.0,2.0);
glTranslatef (0.0f,-0.45f, 0.0f);
glutWireCube (0.5);
/ / legs

glPushMatrix ();
glPushMatrix ();
/ / left leg
glRotatef (PIEI, 0,0,1 )
glTranslatef (-0.1f,-0.55f, 0.0f);
glScalef (-. 3,1.2,1.0)
glutWireCube (0.5);
glPushMatrix ();

glTranslatef (0.0f,-0.7f , 0.0f);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (0.0f, .35 f, 0.0f);
glScalef (1.1, .4,1.0)
glutWireCube (0.5);
glPopMatrix ( )
glPopMatrix ();
/ / feet
glPushMatrix ();
glTranslatef (.3 f,-1.0f, 0.0f);
glScalef (1.6, .2,1.0)
glutWireCube (0.5);
glPopMatrix ();
glPopMatrix ();

/ / right leg
glRotatef (pied, 0,0,1);
glTranslatef (0.1f ,-0.55f, 0.0f);
glScalef (-. 3,1.2,1.0)
glutWireCube (0.5);
glPushMatrix ();

glTranslatef (0.0f,-0.7f, 0.0f);
glutWireCube ( 0.5);

glPushMatrix ();
glTranslatef (0.0f, .35 f, 0.0f);
glScalef (1.1, .4,1.0)
glutWireCube (0.5);
glPopMatrix ();
glPopMatrix ();

/ / feet
glTranslatef (-. 3f,-1.0f, 0.0f);
glScalef (1.6, .2,1.0)
glutWireCube (0.5);


glPopMatrix ();
/ / right arm
glPushMatrix ();
glRotatef (brazod, 0,0,1);
glTranslatef (0.35f, 0.1f, 0.0f);
glScalef ( 0.5,0.4, .5);
glutWireCube (0.5);
glPushMatrix
();

glTranslatef (0.4f, 0.0f, 0.0f);
glScalef (0.5,1.2,1.0);
glutWireCube (0.5);

glPopMatrix ();
glTranslatef (0.8f, 0.0f, 0.0f);
glutWireCube (0.5);
/ / left arm
glPopMatrix ();
glRotatef (brazoi, 0,0,1);
glTranslatef ( -0.35f, 0.1f, 0.0f);
glScalef (0.5,0.4, .5);
glutWireCube (0.5);

glPushMatrix ();
glTranslatef (-0.4f, 0.0f, 0.0f);
glScalef (0.5,1.2,1.0);
glutWireCube (0.5);

glPopMatrix ();
glTranslatef (- 0.8f, 0.0f, 0.0f);
glutWireCube (0.5);
glPopMatrix ();}


0 comments:

Post a Comment