void Model_Robot::draw(Model::DrawMode mode)
{

float lua = theta[LUA];
float lla = theta[LLA];
float rua = theta[RUA];
float rla = theta[RLA];
float lul = theta[LUL];
float lll = theta[LLL];
float rul = theta[RUL];
float rll = theta[RLL];


  torso();
  glPushMatrix();
    glTranslatef(0, head_height / 2, 0);
    head();
  glPopMatrix();
  glPushMatrix();
    glTranslatef(torso_radius, 0, 0);
    glRotatef(lua, 0, 0, 1);
    left_upper_arm();
    glTranslatef(upper_arm_height, 0, 0);
    glRotatef(lla, 0, 0, 1);
    left_lower_arm();
  glPopMatrix();
  glPushMatrix();
    glTranslatef(-torso_radius, 0, 0);
    glRotatef(rua, 0, 0, 1);
    right_upper_arm();
    glTranslatef(-upper_arm_height, 0, 0);
    glRotatef(rla, 0, 0, 1);
    right_lower_arm();
  glPopMatrix();
  glPushMatrix();
    glTranslatef(torso_radius, -torso_height, 0);
    glRotatef(lul, 1, 0, 0);
    left_upper_leg();
    glTranslatef(0, -upper_leg_height, 0);
    glRotatef(lll, 1, 0, 0);
    left_lower_leg();
  glPopMatrix();
  glPushMatrix();
    glTranslatef(-torso_radius, -torso_height, 0);
    glRotatef(rul, 1, 0, 0);
    right_upper_leg();
    glTranslatef(0, -upper_leg_height, 0);
    glRotatef(rll, 1, 0, 0);
    right_lower_leg();
  glPopMatrix();
}
Example #2
0
void
display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    mvstack.push( model_view );
    model_view = RotateY( theta[Torso] );
    torso();

    model_view *= ( Translate( 0.0, TORSO_HEIGHT + 0.5 * HEAD_HEIGHT, 0.0 ) *
		    RotateX( theta[Head1] ) *
		    RotateY( theta[Head2] ) *
		    Translate( 0.0, -0.5 * HEAD_HEIGHT, 0.0 ) );

    head();
    model_view = mvstack.pop();

    mvstack.push( model_view );
    model_view *= ( Translate( -( TORSO_WIDTH + UPPER_ARM_WIDTH ),
                                0.9 * TORSO_HEIGHT, 0.0 ) *
		    RotateX( theta[LeftUpperArm] ) );
    left_upper_arm();

    model_view *= ( Translate( 0.0, UPPER_ARM_HEIGHT, 0.0 ) *
		    RotateX( theta[LeftLowerArm] ) );

    left_lower_arm();
    model_view = mvstack.pop();

    mvstack.push( model_view );
    model_view *= ( Translate( TORSO_WIDTH + UPPER_ARM_WIDTH,
                                0.9 * TORSO_HEIGHT, 0.0 ) *
		   RotateX( theta[RightUpperArm] ) );

    right_upper_arm();

    model_view *= ( Translate( 0.0, UPPER_ARM_HEIGHT, 0.0 ) *
		   RotateX( theta[RightLowerArm] ) );

    right_lower_arm();
    model_view = mvstack.pop();

    mvstack.push( model_view );
    model_view *= ( Translate( -( TORSO_WIDTH + UPPER_LEG_WIDTH ),
                                0.1 * UPPER_LEG_HEIGHT, 0.0 ) *
		    RotateX( theta[LeftUpperLeg] ) );

    left_upper_leg();

    model_view *= ( Translate( 0.0, UPPER_LEG_HEIGHT, 0.0 ) *
		    RotateX( theta[LeftLowerLeg] ) );

    left_lower_leg();
    model_view = mvstack.pop();

    mvstack.push( model_view );
    model_view *= ( Translate( TORSO_WIDTH + UPPER_LEG_WIDTH,
			       0.1 * UPPER_LEG_HEIGHT, 0.0 ) *
		    RotateX( theta[RightUpperLeg] ) );

    right_upper_leg();

    model_view *= ( Translate( 0.0, UPPER_LEG_HEIGHT, 0.0 ) *
		    RotateX( theta[RightLowerLeg] ) );

    right_lower_leg();
    model_view = mvstack.pop();

    glutSwapBuffers();
}