示例#1
0
void Robot::render(float xPos, float yPos, float zPos)
{
    glPushMatrix();
        glTranslatef(xPos, yPos, zPos);	// move to (0, 0, -30)
        // draw head and torso parts
	    renderHead(0.0f, 3.5f, 0.0f);
        renderTorso(0.0f, 0.0f, 0.0f);

	    // move the left arm away from the torso and rotate it to give "walking" effect
	    glPushMatrix();
		    glTranslatef(0.0f, -0.5f, 0.0f);
		    glRotatef(m_armAngles[LEFT], 1.0f, 0.0f, 0.0f);
		    renderArm(2.0f, 0.0f, -0.0f);
	    glPopMatrix();

	    // move the right arm away from the torso and rotate it to give "walking" effect
	    glPushMatrix();
		    glTranslatef(0.0f, -0.5f, 0.0f);
		    glRotatef(m_armAngles[RIGHT], 1.0f, 0.0f, 0.0f);
		    renderArm(-2.0f, 0.0f, -0.0f);
	    glPopMatrix();

	    // move the left leg away from the torso and rotate it to give "walking" effect
	    glPushMatrix();
		    glTranslatef(0.0f, -0.5f, 0.0f);
		    glRotatef(m_legAngles[LEFT], 1.0f, 0.0f, 0.0f);
		    renderLeg(-1.0f, -5.0f, -0.5f);
	    glPopMatrix();

	    // move the right leg away from the torso and rotate it to give "walking" effect
	    glPushMatrix();
		    glTranslatef(0.0f, -0.5f, 0.0f);
		    glRotatef(m_legAngles[RIGHT], 1.0f, 0.0f, 0.0f);
		    renderLeg(1.0f, -5.0f, -0.5f);
	    glPopMatrix();
    glPopMatrix();
}
void RobotTorsoModel::traverseNode()
{
   renderTorso();
}