Monday, April 16, 2007

Do You Capitalize Existentialism



# include # include stdio.h string.h
# include GL / glut.h
# include GL / gl.h

windows.h # include # include # include math.h

# include malloc.h stdarg.h
/ * Windows parameters * / # define

# define WIDTH 600 HEIGHT 600
# define TITLE "GLUT Demo: Using Subwindows"
void conv (void);
onMouse void (int button, int state, int x, int y);
hand void (void);
void Humanoide(void);
void Movimiento(void);
void onMouse2(int button, int state, int x, int y);
void onMotion2(int x, int y) ;
void onMotion(int x, int y);
void idle2(void);
int winIdMain;
int winIdSub;
int xo,im,yo,alpha,beta,ven,ven2,inif,aux;
int winIdSub2;
float xf,yf;
char xm[3]="000";
char ym[3]="000";
float r1,r2,r3,r4,r5,r6,rmu1,xmu,ymu,zmu,zp,xp;
float r7,r8,r9,r10,r11,r12,r13,r14,r15;
float x,y,z,brazod, brazoi, pied, piei;
int k=0;
xf=150;
yf=200;
ven=0;
ven2=0;
INIF = 0;
void init (void) {

glClear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);}

void text (GLuint x, GLuint and, GLfloat scale, char * format, char * format2) {/ / Function to write text
va_list args;
char buffer [255], * p;
GLfloat font_scale = 33.33f 119.05f +;
va_start (args, format);
vsprintf (buffer, format, args);
va_end (args);
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gluOrtho2D (0, glutGet (GLUT_WINDOW_WIDTH), 0,
glutGet (GLUT_WINDOW_HEIGHT));
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glTranslatef(x, y, 0.0);
glScalef(scale/font_scale, scale/font_scale, scale/font_scale);
//len = (int) strlen(format);
glutStrokeCharacter(GLUT_STROKE_ROMAN, 40);
for(p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glutStrokeCharacter(GLUT_STROKE_ROMAN, 44);
va_start(args, format2);
vsprintf(buffer, format2, args);
va_end(args);
//len = (int) strlen(format2);
for(p = buffer; * P, p + +)
glutStrokeCharacter (GLUT_STROKE_ROMAN, * p);
glutStrokeCharacter (GLUT_STROKE_ROMAN, 41);
glPopAttrib ();
glPopMatrix ();
glMatrixMode (GL_PROJECTION);
glPopMatrix ();
glMatrixMode (GL_MODELVIEW);

} void fractal (void) {/ / Function which calculates the fractal
int ran;
ran = rand ()% 4;
if (ran == 1) {
xf = (50 + xf) / 2;
f = (200 + f) / 2;

} if (ran == 2) {
xf = (250 + xf) / 2;
f = (200 + f) / 2;

} if (ran == 3) {
xf = (150 + xf) / 2;
f = (50 + f) / 2;
}}

void paint (void) {/ / Function
fractal painting int xe, ze,
float x2, y2;
glColor3f (1.0,1.0,0.0) glBegin
(GL_POINTS)
glVertex3f (50.0f, 200.0f, 0.0 f)
glVertex3f (250.0f, 200.0f, 0.0f);
glVertex3f (150.0f, 50.0f, 0.0f);
glEnd ();
if (K == 0) {glBegin
(GL_POINTS)
glVertex3f (xf, yf, 0);
glEnd ();
k = 1;}

fractal ();
glBegin (GL_POINTS)
glVertex3f (xf, yf, 0);
glEnd ();}

void Display (void) / / Function that shows the main panatalla

{/ * Clean drawing board * /
glutSetWindow (winIdMain)
/ / glLoadIdentity ();
paint ();
glFlush ();}

/ * Another display function, this one
Will Be Used to update the graphic subwindow * / void
subDisplay () {/ / function that displays content of the sub
/ * Clear subwindow * /
if (im == 1) {
glutSetWindow (winIdSub)
glutSetCursor (GLUT_CURSOR_CYCLE)
glutPositionWindow (20, 20);
glClearColor (0.0, 0.0, 1.0, 0.0 )
glClear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)
itoa (x, xm, 10);
itoa (I, m, 10);
glColor3f (1.0,1., 0.0);
glutPassiveMotionFunc (onMotion2)
text (xo , (500-I), 20, xm, ym);
}
if(im==2){
glutSetWindow (winIdSub2);
glutSetCursor (GLUT_CURSOR_SPRAY);
glutPositionWindow (100, 100);
glClearColor (1.0, 0.0,0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glutMouseFunc(onMouse2);
glPushMatrix();
glScalef(0.2,.2,.2);
//glTranslatef(0,0,0.0f);
glPushMatrix();
glScalef(0.4,2.4,2.0);
glTranslatef(-21,2.75f,0.0f);
glRotatef(90,0,0,1);
mano( );
glPopMatrix();
glPushMatrix();
glScalef(0.4,2.4,2.0);
glTranslatef(21,2.75f,0.0f);
glRotatef(-90,0,0,1);
mano();
glPopMatrix();
Humanoide();
glPopMatrix();
glutSwapBuffers ();
}
}
/* Callback function for reshaping the main window */
void Reshape (int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, w, h, 0);
glMatrixMode(GL_MODELVIEW);
}
/* Callback function for reshaping the subwindow */
void subReshape (int w, int h)
{
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0.0f, 1.0F, 0.0f, 1.0F);}

idle2 void (void) / / handles the subwindow
{
Movement ();
subDisplay ();}

void idle (void) / / main window handle {

glutSetWindow (winIdMain)
glutPostRedisplay ();
glutSetWindow (winIdSub)
glutPostRedisplay ();
glutSetWindow (winIdSub2)
glutPostRedisplay ();}

onMouse void (int button, int state , int x, int y) / / Function main window mouse

{if ((button == GLUT_LEFT_BUTTON) & (state == GLUT_DOWN)) {
if (ven2 == 1) {
ven2 = 0;
glutDestroyWindow (winIdSub2);
goto yy;
}
if(ven==0){
winIdSub = glutCreateSubWindow (winIdMain, 500,500, 500 , 500);
glutMouseFunc(onMouse);
im=1;
glutDisplayFunc (subDisplay);
ven=1;
xo=x;
yo=y;
}
else ven=1;
yy: aux=0;
}
if ( (button == GLUT_RIGHT_BUTTON) & (state == GLUT_DOWN) ) {
if(ven==1){
ven=0;
glutDestroyWindow(winIdSub);
goto xx;
}
if(ven2==0){
winIdSub2 = glutCreateSubWindow (winIdMain, 500,500, 500 , 500);
glutMouseFunc(onMouse2);
im=2;
glutDisplayFunc (subDisplay);
glutIdleFunc (idle2);
ven2=1;
xo=x;
yo=y;
}
else ven2=1;
}
xx: aux=1;
}
void onMouse2(int button, int state, int x, int y) //Funcion mouse subventana
{
if ( (button == GLUT_LEFT_BUTTON) & (state == GLUT_DOWN) ) {
if(ven2==1){
ven2=0;
glutSetWindow (winIdMain);
main();
glutDestroyWindow (winIdSub2);
goto yy;
}
if(ven==0){
winIdSub = glutCreateSubWindow (winIdMain, 500,500, 500 , 500);
glutMouseFunc(onMouse);
im=1;
glutDisplayFunc (SubDisplay) are
= 1;
xo = x;
yo = y;}

else seen = 1;
yy: aux = 0;

}} void
onMotion (int x, int y) {/ / mouse motion function main window
alpha = (alpha + (y - yo));
beta = (beta + (x - xo));
xo = x, I = y;
glutPostRedisplay ();}

onMotion2 void (int x, int y) {/ / Function subwindow mouse movement
alpha = (alpha + (y - yo));
beta = (beta + (x - xo));
xo = x; I = y;
glutPostRedisplay ();}

void keyboard (unsigned char key, int x, int y) / / keyboard event
{
switch (key) {
case 27:
exit(0);
break;
}
}
int main (int argc, char **argv)
{
/* Glut initializations */
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE GLUT_RGBA GLUT_DEPTH);
glutInitWindowPosition (20,20);
glutInitWindowSize (WIDTH, HEIGHT);
/* Main window creation and setup */
winIdMain = glutCreateWindow (TITLE);
// glutSetWindow (winIdMain);
init ();
glutDisplayFunc (Display);
glutReshapeFunc (Reshape);
glutMouseFunc(onMouse);
glutPassiveMotionFunc(onMotion);
glutKeyboardFunc(keyboard);
glutIdleFunc (idle);
glutMainLoop ();
return 0;}

void Move (void) / / Random motion of humanoid

{x = rand ()% 2;
y = rand ()% 2;
z = rand ()% 2;
brazod = rand ()% 80;
brazoi = rand ()% 80;
pied = rand ()% 80;
PIEI = rand ()% 80;
/ / axis of rotation
wrist xmu = rand ()% 2;
YMU = rand ()% 2;
UMZ = rand ()% 2;
/ / angle of the wrist
RMU1 = rand ()% 90;
/ / angles of degrees of freedom of the middle finger
r1 = rand ()% 180;
r2 = rand ()% 180;
r3 = rand ()% 180;
/ / angles of degrees of freedom of the index finger
r4 = rand ()% 180;
r5 = rand ()% 180;
r6 = rand ()% 180;
/ / angles of degrees of freedom of finger
cancel r7 = rand ()% 180;
r8 = rand ()% 180;
r9 = rand ()% 180;
/ / angles of degrees of freedom of the little finger
r10 = rand ()% 180;
r11 = rand ()% 180;
r12 = rand ()% 180;
/ / angles of degrees of freedom of the thumb
r13 = rand ()% 180;
r14 = rand ()% 180;
r15 = rand ()% 180;
/ / axis of rotation of the thumb
zp = 1;
xp = 0;}

Humanoid void (void) / / Function of Humanoid

{glPushMatrix ();
/ / head
glTranslatef (0.0f, 2.5f, 0.0f);
glutWireCube (0.5);
/ / trunk
glScalef (2.5,2.5,2.0);
glTranslatef (0.0 f,-0.45f, 0.0f);
glutWireCube (0.5);
/ / legs
glPushMatrix ();
glPushMatrix ();
/ / left leg
glRotatef (PIEI, x, y, z);
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, x, y, z);
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, x, y, z);
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.7f, 0.0f, 0.0f) ;
glScalef (.7,1,1.0)
glutWireCube (0.5);
/ / left arm
glPopMatrix ();
glRotatef(brazoi,x,y,z);
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.7f,0.0f,0.0f);
glScalef(.7,1,1.0);
glutWireCube (0.5);
glPopMatrix();

}
void mano(void) //Funcion de la mano
{
glRotatef(rmu1,xmu,ymu,zmu);
glPushMatrix();
glTranslatef(-0.1,0.0,0.0f);
glScalef(1.7,2.5,1.0);
glutWireCube (0.5);
glPopMatrix();
/ /
middle finger glPushMatrix ();
glTranslatef (0.0,0.9,0.0 f);
glRotatef (r1, 1,0,0);
glScalef (.3,1.2,1.0)
glutWireCube (0.5);
glTranslatef (0.0, .45,0.0 f);
glRotatef (r2, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glTranslatef (0.0, f .47,0.0 )
glRotatef (r3, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ /
index finger glPushMatrix ();
glTranslatef (0.2, 0.0,0.0 f);
glTranslatef (0.0,0.9,0.0 f);
glRotatef (r4, 1,0,0);
glScalef (.3,1.2,1.0)
glutWireCube (0.5);
glTranslatef (0.0, .45,0.0 f);
glRotatef (r5, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glTranslatef (0.0, .47,0.0 f);
glRotatef (r6, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ /
finger glPushMatrix ();
glTranslatef (-0.2,0.0,0.0 f);
glTranslatef (0.0,0.9,0.0 f);
glRotatef (r7, 1,0,0);
glScalef (.3,1.2,1.0)
glutWireCube (0.5 )
glTranslatef (0.0, .45,0.0 f);
glRotatef (r8, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glTranslatef (0.0, .47,0.0 f);
glRotatef (r9, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ / dedo meñique
glPushMatrix ();
glTranslatef (-0.4,0.0,0.0 f);
glTranslatef (0.0,0.9,0.0 f);
glRotatef (r10, 1,0,0);
glScalef (.3,1.2,1.0) ;
glutWireCube (0.5);
glTranslatef (0.0, .45,0.0 f);
glRotatef (R11, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glTranslatef ( 0.0, .47,0.0 f);
glRotatef (R12, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glPopMatrix ();
/ / thumb
glPushMatrix ();
glTranslatef (0.45, -0.8,0.0 f);
glTranslatef (0.0,0.9,0.0 f);
glRotatef (r13, xp, 0, zp);
glScalef (.3 , 1.2,1.0);
glutWireCube (0.5);
glTranslatef (0.0, .45,0.0 f);
glRotatef (r14, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5 )
glTranslatef (0.0, .47,0.0 f);
glRotatef (r15, 1,0,0);
glScalef (1.0,0.7,1.0);
glutWireCube (0.5);
glPopMatrix ();}

0 comments:

Post a Comment