next up previous
Next: Helper Functions Up: Code Previous: main

Initialization

The initialization function sets all of the initial data to be used in the program. The Quadric object qobj is given default value to be modified and used later. this quadric object is sent to specific shape display functions

void myinit(void) // initialization
{
	qobj = gluNewQuadric();
	//gluQuadricDrawStyle(qobj, GLU_FILL);
	gluQuadricOrientation(qobj, GLU_INSIDE);
	gluQuadricNormals(qobj, GLU_FLAT);  // GLU_FLAT  GLU_SMOOTH  GLU_NONE
	
													 // original values
    GLfloat light_ambient[] = {.2, .2, .2, 1.0};	 // .3 .3 .3 1.0
    GLfloat light_diffuse[] = {.9, .9, .9, 1.0};	 // 1 1 1 1
    GLfloat light_specular[] = {.0, .0, .0, 1.0};		 // 1 1 1 1   
    GLfloat light_position[] = {0.0, 4.0, 10.0, 0.0};	     
    
    //************* Mr. Hyatt's light initialization statements************
        
    GLfloat mat_specular[] = {.5, .5, .5, 1.0};       // .5, .5, .5, 1.0
    GLfloat mat_diffuse[] = {0.8, 0.8, 0.8, 1.0};     
    GLfloat mat_shininess[]= {30.0};      		 // 30

    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);

    // Material Properties
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);  
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); 

    // Enable Various Components
    glEnable(GL_COLOR_MATERIAL);  
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);

    glColorMaterial(GL_FRONT,GL_DIFFUSE); 
    
    //********************************** END ******************************	
	
	// my data initiation
	// joints are largest and longest at the base of the middle finger and 
	// get smaller as you move away from that digit
	 glColor3f(1.0, 1.0, 0.0);  // yellow
	//  glColor3f(0, 0, 1);     // test colors
 	
	 // glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
	  
	  for(int x=0; x<4; x++)
		for(int y=0; y<4; y++)
	      {
		  joint[x][y]= .95-.05*abs(x-1)-.1*y;
		  }
	  for(int x=0; x<4; x++)
	    for(int y=0; y<3; y++)
		  {
	      dist[x][y]= 2.2-.4*y-.05*pow((x-1), 2);
	      angle[x][y]=15;  
		  }			
	    for(int y=0; y<3; y++) // for the thumb-diff proportions from the rest of the hand
		{
			dist[4][y] = 2.5-.5*double(y);
			angle[4][y] = 15;
			joint[4][y] = 1.1-.1*y;
			spread[y] = 10*y;
		}
		joint[4][3] = .7;
		angle[4][0] = 40;
}

The final for loops are used to set the initial values of my arrays. These arrays are used for different



Michael Hull 2003-06-11