Ejemplo n.º 1
0
void GLWidget::drawNeck(const float NECK_X_SCALE, const float NECK_Y_SCALE,
                         const float BEAK_UP_X_SCALE, const float BEAK_UP_Y_SCALE,
                         const float BEAK_DOWN_X_SCALE, const float BEAK_DOWN_Y_SCALE,
                         const float BODY_Y_SCALE)
{
    transformStack().pushMatrix();
    // position neck and joint together
    transformStack().translate(-2.5, BODY_Y_SCALE/2.5);

    transformStack().pushMatrix();
    transformStack().rotateInDegrees(neck_joint_angle);

    // Draw beak
    drawBeak(NECK_X_SCALE,BEAK_DOWN_X_SCALE,BEAK_DOWN_Y_SCALE,
                BEAK_UP_X_SCALE,BEAK_UP_Y_SCALE);

    transformStack().scale(NECK_X_SCALE,NECK_Y_SCALE); // 50,40
    transformStack().translate(0.0, 0.4);
    m_gl_state.setColor(0.0, 1.0, 1.0);
    m_unit_neck.draw();
    transformStack().popMatrix();

    transformStack().pushMatrix();
    drawJoint(1.0, NECK_Y_SCALE/5.0);
    transformStack().popMatrix();

    transformStack().popMatrix();
}
Ejemplo n.º 2
0
void drawHead(){
	glPushMatrix();{
		// Move the head up to the hinge
		glTranslatef(0.0, HEAD_SCALE, 0.0);
		// Rotate the head along the hinge
		glRotatef(headRotation, 0.0, 0.0, 1.0);
		// Scale the head down from the size of the body
		glScalef(HEAD_SCALE, HEAD_SCALE, 1.0);
		// Move the head into its correct position
		glTranslatef(0.0, HEAD_SCALE/4, 0.0);
		glColor3f(1.0, 0.0, 0.0);
		Point headPoints[] = {
		        // top point
		        {-0.2, 0.5},
		        // top right point
		        {0.35, 0.25},
		        // bottom right point
				{0.5, -0.35},
				// bottom left point
				{-0.5, -0.35},
				// top left point
				{-0.4, 0.3}};
		drawPolygon(5, headPoints);

		drawBeak();

		// Draw eye
		glPushMatrix();
		{
			// Move the eye to the top left part of the head
		    glTranslatef(-0.2, 0.2, 0.0);
		    // Scale the eye down
		    glScalef(0.05, 0.05, 1.0);
		    glColor3f(1.0, 1.0, 1.0);

			drawCircle(1.0);

		    glPushMatrix();
		    {
		    	// Move the pupil a bit to the left so it looks like
		    	// the penguin is looking forward
		        glTranslatef(-0.1, 0.0, 0.0);
		        // Scale the pupil down
		        glScalef(0.5, 0.5, 1.0);
                glColor3f(0.0, 0.0, 0.0);
                drawCircle(1.0);
		    }
		    glPopMatrix();
		}
		glPopMatrix();
	}
	glPopMatrix();

	// Draw neck joint
	glPushMatrix();
	{
        glTranslatef(0.0, HEAD_SCALE, 0.0);
        glScalef(LEG_SCALE * 0.1, LEG_SCALE * 0.1, 1.0);
        glColor3f(1.0, 1.0, 1.0);
        drawCircle(1.0);
	}
	glPopMatrix();
}
Ejemplo n.º 3
0
/* draws a penguin centered (roughly) at the origin
   Also moves him around in a circle
   It now takes a parameter that indicates whether or
   no the penguin is a shadow (just for coloring purposes) */
void drawPenguin( int is_shadow )
{
	/* the colors we apply to the bird */
	/* Black does not really show lighting very well,
	   (or at all!) so the bird is now a blusih colour */
	GLfloat bluish[3];
	GLfloat orange[3];

	if( is_shadow )
	{
		/* bluish and orange are both grey for a shadow */
		bluish[0] = bluish[1] = bluish[2] = 0.2;
		orange[0] = orange[1] = orange[2] = 0.2;
	}
	else
	{
		/* for normal penguin, normal colors */
		bluish[0] = 0.08;
		bluish[1] = 0.2;
		bluish[2] = 0.35;

		orange[0] = 1.0;
		orange[1] = 0.5;
		orange[2] = 0.0;
	}

	/* draw main body and head bluish */
	glColor3fv( bluish );

	glPushMatrix( );
		/* Wobble the body a little bit */
		glRotatef( wobble_amount, 0.0, 0.0, 1.0 );
		drawHead( );
		drawBody( );

		/* draw the beak orange */
		glColor3fv( orange );
		drawBeak( );
	glPopMatrix( );

	/* draw penguin's left wing bluish */
	glColor3fv( bluish );
	drawLeftWing( );

	/* draw the left foot orange */
	glColor3fv( orange );
	drawLeftFoot( );

	/* to draw the penguins' right appendages, we just invert the world
	   along the X axis, and draw the left ones over again... */
	glScalef( -1.0, 1.0, 1.0 );

	glColor3fv( bluish );		/* bluish wing */
	drawLeftWing( );
	
	/* orange */
	glColor3fv( orange );
	/* to make the left and right rotate on an opposite way, we invert the right one... */
	GLfloat temp = foot_move_amount;
	foot_move_amount = abs( 90.0 - foot_move_amount );
	drawLeftFoot( );
	foot_move_amount = temp;	/* reset the value for the left foot */
}