Example #1
0
void display() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				// clear the color buffer

																	// set camera parameters
	GLdouble centerX = eyeX;
	GLdouble centerY = eyeY + 1;
	GLdouble centerZ = eyeZ;
	GLdouble upX = 0.;
	GLdouble upY = 0.;
	GLdouble upZ = 1.;

	glMatrixMode(GL_MODELVIEW);			        // indicate we are specifying camera transformations
	glLoadIdentity();

	gluLookAt(eyeX, eyeY, eyeZ,
		centerX, centerY, centerZ,
		upX, upY, upZ);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60, 1, 1, 100);

	// drawing is done here
	mainArm.draw();
//	secArm.draw();

	float c = 0.2;
	Point3f a0 = goal + Vector3f(-c, 0, c);
	Point3f a1 = goal + Vector3f(0, 0, -c);
	Point3f a2 = goal + Vector3f(c, 0, c);
	Vector3f n2(0, -1, 0);
	glBegin(GL_TRIANGLES);
	glNormal3f(n2[0], n2[1], n2[2]);
	glVertex3f(a0[0], a0[1], a0[2]);
	glVertex3f(a1[0], a1[1], a1[2]);
	glVertex3f(a2[0], a2[1], a2[2]);
	glEnd();

	/*Point3f secGoal = Point3f(goal[0], goal[1], -goal[2]);
	a0 = secGoal + Vector3f(-c, 0, c);
	a1 = secGoal + Vector3f(0, 0, -c);
	a2 = secGoal + Vector3f(c, 0, c);
	glBegin(GL_TRIANGLES);
	glNormal3f(n2[0], n2[1], n2[2]);
	glVertex3f(a0[0], a0[1], a0[2]);
	glVertex3f(a1[0], a1[1], a1[2]);
	glVertex3f(a2[0], a2[1], a2[2]);*/
	glEnd();
	// end drawing

	glFlush();
	glutSwapBuffers();					// swap buffers (we earlier set double buffer)
}
void Ex59AdvancedJointsApp::draw() {
    gl::clear( Color( 0.666, 0.666, 0.666 ) );
    arm->draw();
    floor->draw();
}
// GLUT callback. Called to draw the scene.
void My_Display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//GLfloat angleX = ((GLfloat)windowRotateX / ((GLfloat)window_width / 2)) * 180;
	//GLfloat angleY = ((GLfloat)windowRotateY / ((GLfloat)window_height / 2)) * 180;

	
	//Arm left_up_arm(1, -1, 1);
	//Arm right_up_arm(-1,-1,1);

	//initial matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

	gluLookAt(0.0, 0.0, nRange, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0);

	{
		glutSolidCube(0.08f*nRange/10.0f);
	}

	glMultMatrixf(World_Matrix);

	SpotlightPos[0] = 0.0f;
	SpotlightPos[1] = -13.5f;
	SpotlightPos[2] = 8.0f;
	SpotlightPos[3] = 1.0f;

	
	
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight);
	glLightfv(GL_LIGHT1, GL_SPECULAR, specular);
	glLightfv(GL_LIGHT1, GL_POSITION, SpotlightPos);
	glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, Vector3<GLfloat>(0.0f, 13.5f, -0.8f).toArray());
	glLighti(GL_LIGHT1, GL_SPOT_CUTOFF, 30);
	glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 1000.0f);

	SpotlightPos[0] = 0.0f;
	SpotlightPos[1] = -9.5f;
	SpotlightPos[2] = 0.0f;
	SpotlightPos[3] = 1.0f;

	glLightfv(GL_LIGHT2, GL_AMBIENT, ambientLight);
	glLightfv(GL_LIGHT2, GL_DIFFUSE, diffuseLight);
	glLightfv(GL_LIGHT2, GL_SPECULAR, specular);
	glLightfv(GL_LIGHT2, GL_POSITION, SpotlightPos);
	glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, Vector3<GLfloat>(0.0f, -1.0f, 0.0f).toArray());
	glLighti(GL_LIGHT2, GL_SPOT_CUTOFF, 60);
	glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 1000.0f);
	


	glPushMatrix();
	{
		
		//glRotatef(angleX, 0.0, 1.0, 0.0);
		//glRotatef(angleY, 1.0, 0.0, 0.0);
		//glRotatef(angle,0.0f,1.0f,0.0f);

		glPushMatrix();
		{
			glPushMatrix();
			{
				glTranslatef(0.0f,-13.5f,0.0f);
				magiccircle.draw();
			}
			glPopMatrix();
			
			glTranslatef(0.0f, body.torso_pos, 0.0f);
			
			glPushMatrix();
			{
				glRotateXYZ(body.torso_tilt);
				body.draw();    //body


				glPushMatrix();   //left wing
				{
					glTranslatef(1.3f, 3.0f, -1.1f);
					glRotatef(25.0f, 0.0f, 1.0f, 0.0f);
					glRotatef(-5.0f, 0.0f, 0.0f, 1.0f);
					left_wing.draw();
				}
				glPopMatrix();

				glPushMatrix();   //right wing
				{
					glTranslatef(-1.3f, 3.0f, -1.1f);
					glRotatef(-25.0f, 0.0f, 1.0f, 0.0f);
					glRotatef(5.0f, 0.0f, 0.0f, 1.0f);
					right_wing.draw();
				}
				glPopMatrix();

				glPushMatrix();   //head
				{
					glTranslatef(0.0f, 4.0f, 0.0f);
					head.draw();
				}
				glPopMatrix();

				glPushMatrix();    //left arm
				{
					glTranslatef(3.0f, 2.6f, 0.0f);
					left_arm.draw();
					
				}
				glPopMatrix();
				
				glPushMatrix();    //right arm
				{
					glTranslatef(-3.0f, 2.6f, 0.0f);
					right_arm.draw();
					
				}
				glPopMatrix();
				
				glPushMatrix();    //left leg
				{
					glTranslatef(1.7f, -4.0f, 0.0f);
					glRotateXYZ(-body.torso_tilt[0], 0.0f, 0.0f);
					left_leg.draw();

				}
				glPopMatrix();

				glPushMatrix();    //right leg
				{
					glTranslatef(-1.7f, -4.0f, 0.0f);
					glRotateXYZ(-body.torso_tilt[0], 0.0f, 0.0f);
					right_leg.draw();
				}
				glPopMatrix();
			}
			glPopMatrix();
			
			
		}
		glPopMatrix();

		
		/*
		glPushMatrix();
		{
			glTranslatef(2.2f, 0.7f, 0.0f);
			left_up_arm.draw();
		}
		glPopMatrix();

		glPushMatrix();
		{
			glTranslatef(-2.2f, 0.7f, 0.0f);
			right_up_arm.draw();
		}
		glPopMatrix();*/

	}
	glPopMatrix();

	glutSwapBuffers();
}