Beispiel #1
0
void
makeDinosaur(void)
{
  extrudeSolidFromPolygon(body, sizeof(body), bodyWidth,
    BODY_SIDE, BODY_EDGE, BODY_WHOLE);
  extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4,
    ARM_SIDE, ARM_EDGE, ARM_WHOLE);
  extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2,
    LEG_SIDE, LEG_EDGE, LEG_WHOLE);
  extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2,
    EYE_SIDE, EYE_EDGE, EYE_WHOLE);
  glNewList(DINOSAUR, GL_COMPILE);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
  glCallList(BODY_WHOLE);
  glPushMatrix();
  glTranslatef(0.0, 0.0, bodyWidth);
  glCallList(ARM_WHOLE);
  glCallList(LEG_WHOLE);
  glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4);
  glCallList(ARM_WHOLE);
  glTranslatef(0.0, 0.0, -bodyWidth / 4);
  glCallList(LEG_WHOLE);
  glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
  glCallList(EYE_WHOLE);
  glPopMatrix();
  glEndList();
}
Beispiel #2
0
void makeDinosaur(void)
{
  extrudeSolidFromPolygon(body, sizeof(body), bodyWidth,
    BODY_SIDE, BODY_EDGE, BODY_WHOLE);
  extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4,
    ARM_SIDE, ARM_EDGE, ARM_WHOLE);
  extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2,
    LEG_SIDE, LEG_EDGE, LEG_WHOLE);
  extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2,
    EYE_SIDE, EYE_EDGE, EYE_WHOLE);
}
void display(void)
{
	int i, j;
	GLfloat xPos = -0.34;
	glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		
	glTranslatef(0.0, 0.0, -10.0);

	extrudeSolidFromPolygon(letterM, sizeof(letterM), width2, REPEAT_SIDE, 
		REPEAT_EDGE, REPEAT1);
	extrudeSolidFromPolygon(letterO, sizeof(letterO), width2, REPEAT2_SIDE, 
		REPEAT2_EDGE, REPEAT2);
	extrudeSolidFromPolygon(letterT, sizeof(letterT), width2, REPEAT3_SIDE, 
		REPEAT3_EDGE, REPEAT3);
	extrudeSolidFromPolygon(letterH, sizeof(letterH), width2, REPEAT4_SIDE, 
		REPEAT4_EDGE, REPEAT4);			

	for(j = 1; j < 5; j++){ 
		width = 0.0;
checkErrors();
		for(i = 0; i < 10; i++){ 

			glPushMatrix();
				repeat(j);
			glPopMatrix();
			
			glPushMatrix();
				glRotatef(90.0, 0.0, 1.0, 0.0); 
				if(j == 1){
					extrudeSolidFromPolygon(letterM, sizeof(letterM), width, M_SIDE, 
						M_EDGE, M_WHOLE);
					glCallList(M_WHOLE);					
				}
				if(j == 2){
					extrudeSolidFromPolygon(letterO, sizeof(letterO), width, O_SIDE, 
						O_EDGE, O_WHOLE);
					glCallList(O_WHOLE);
				}				
				if(j == 3){
					extrudeSolidFromPolygon(letterT, sizeof(letterT), width, T_SIDE, 
						T_EDGE, T_WHOLE);
					glCallList(T_WHOLE);
				}
				if(j == 4){
					extrudeSolidFromPolygon(letterH, sizeof(letterH), width, H_SIDE, 
						H_EDGE, H_WHOLE);
					glCallList(H_WHOLE);
				}				
				glutSwapBuffers();
		    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				width = width + 0.2;
			glPopMatrix();
		}
		for(i = 0; i < 45 ; i++){
				
			glPushMatrix();
				repeat(j);
			glPopMatrix();					
			
			glPushMatrix();					
				glRotatef(90.0 - (2.0 * i), 0.0, 1.0, 0.0);
				if(j == 1){
				glCallList(M_WHOLE);
				}
				if(j == 2){
				glCallList(O_WHOLE);
				}
				if(j == 3){
				glCallList(T_WHOLE);
				}
				if(j == 4){
				glCallList(H_WHOLE);
				}			
				glutSwapBuffers();
		    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		
			glPopMatrix();
		} 
		for(i = 1; i < 32 ; i++){
			
			glPushMatrix();
				repeat(j);
			glPopMatrix();
			
			glPushMatrix();
				glTranslatef(i * xPos, i * 0.3, i * -0.3);
				if(j == 1){
				glCallList(M_WHOLE);
				}
				if(j == 2){
				glCallList(O_WHOLE);
				}
				if(j == 3){
				glCallList(T_WHOLE);
				}
				if(j == 4){
				glCallList(H_WHOLE);
				}		
				glutSwapBuffers();
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				
			glPopMatrix();
		}				

		if(j == 1){
			xPos = xPos + 0.25;
		}
		else{
			xPos = xPos + 0.21;
		}
	}
	glFlush();
}