Exemplo n.º 1
0
// this draws all of the stuff in the world
// NOTE: if you're drawing shadows, DO NOT set colors 
// (otherwise, you get colored shadows)
// this gets called twice per draw - once for the objects, once for the shadows
// TODO: if you have other objects in the world, make sure to draw them
void TrainView::drawStuff(bool doingShadows)
{
	// draw the control points
	// don't draw the control points if you're driving 
	// (otherwise you get sea-sick as you drive through them)
	if (!tw->trainCam->value()) {
		for(size_t i=0; i<world->points.size(); ++i) {
			if (!doingShadows) {
				if ( ((int) i) != selectedCube)
					glColor3ub(240,60,60);
				else
					glColor3ub(240,240,30);
			}
			world->points[i].draw();
		}
	}
	// draw the track
	// TODO: call your own track drawing code
#ifdef EXAMPLE_SOLUTION
	drawTrack(this, doingShadows);
#endif

	// draw the train
	// TODO: call your own train drawing code
#ifdef EXAMPLE_SOLUTION
	// don't draw the train if you're looking out the front window
	if (!tw->trainCam->value())
		drawTrain(this, doingShadows);
#endif
}
Exemplo n.º 2
0
/**
 * Updates the thumb according to the current list position.
 */
void ScrollBar::draw()
{
	Surface::draw();
	drawTrack();
	drawThumb();
}
Exemplo n.º 3
0
	void EditorTrack::onDraw(CL_GraphicContext &p_gc)
	{
		drawNet(p_gc);
		drawTrack(p_gc);
	}
Exemplo n.º 4
0
void renderScene(void) {
    
    //Set up Viewport 1 scene
    
    // Use the Projection Matrix
    glMatrixMode(GL_PROJECTION);
    
    // Reset Matrix
    glLoadIdentity();
    
    
    glScissor(0, 0, (GLsizei) windowWidth, (GLsizei) windowHeight*0.9);
    glEnable(GL_SCISSOR_TEST);
    glClearDepth(1.0);
    
    glClearColor(0.49f, 0.75f, 0.93f, 1.0f);
    
    // Set the viewport to be the entire window
    glViewport (0, 0, (GLsizei) windowWidth, (GLsizei) windowHeight*0.9);
    
    // Set the correct perspective.
    
    if (viewMode == PERSPECTIVE)
        gluPerspective(45.0f*zoom, ratio, 1.0f, 1000.0f);
    else if (viewMode == ORTHOGRAPHIC)
        glOrtho((-windowWidth/50)*zoom, (windowWidth/50)*zoom, (-windowHeight/50)*zoom, (windowHeight/50)*zoom, 1.0f, 1000);
    
    // Get Back to the Modelview
    glMatrixMode(GL_MODELVIEW);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    //Decide if wire frame or shaded
    if (polygonMode == WIREFRAME)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    else if (polygonMode == SHADED)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    
    glLoadIdentity();

    moveCamera();
    
    lx = (sin(heliRot+PI));
    lz = (cos(heliRot+PI));
    
    float camX = curX + lx * 10.0f;
    float camZ = curZ + lz * 10.0f;
    
    //Set camera
    if (viewPerson == THIRD) {
        gluLookAt(eyeX+curX, eyeY, eyeZ+curZ,
                  curX, 0.0f, curZ,
                  upX, upY, upZ);
    }

    else if (viewPerson == FIRST) {
        
        gluLookAt(camX, 1.5f, camZ,
                  camX+lx, 1.5f, camZ+lz,
                  0.0f, 1.0f, 0.0f);
        
    }
    
    glEnable(GL_DEPTH_TEST);
    
    glShadeModel(GL_SMOOTH); // smooth out lighting
    glEnable(GL_NORMALIZE);  // normalize lighting
    
    GLfloat mat_specular[] = {0.3, 0.3, 0.3, 1.0};
    GLfloat mat_shininess[] = { 10.0 };
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
    
    if (lightingEnabled) {
        
        glEnable(GL_LIGHTING);
    
        if (sunlight) {

            setSunlight();
    
        }
    
        else {
            glDisable(GL_LIGHT0);
        }
        
        
        if (thirdPersonLight) {
            setThirdPersonLight();
        }
        
        else {
            glDisable(GL_LIGHT3);
        }
        
        
    }
    
    else {
        glDisable(GL_LIGHTING);
    }

    glPushMatrix();
    glTranslatef(0.0f, -10, 0.0f);
    drawGround(250, 100);
    glPopMatrix();
    
    glPushMatrix();
    glTranslatef(0.0f, -9.9, 0.0f);
    drawTrack(100.0, 100.0);
    glPopMatrix();
    
    glPushMatrix();
    moveHelicopter();
    glRotatef(heliRot/PI*180, 0.0f, 1.0f, 0.0f);
    drawHelicopter();
    
    
    if (lightingEnabled) {
    
        if (circleLight) {
    moveLight();
    setCircularLight();
        }
        
        else {
            glDisable(GL_LIGHT2);
        }
    
    }
    
    glPopMatrix();
    
    //Set up Viewport 2 scene
    
    // Use the Projection Matrix
    glMatrixMode(GL_PROJECTION);
    
    // Reset Matrix
    glLoadIdentity();
    
    glScissor(0, windowHeight*0.9, (GLsizei) windowWidth, (GLsizei) windowHeight*0.1);
    glEnable(GL_SCISSOR_TEST);
    glClearDepth(1.0);
    glClearColor(1, 1, 1, 1);

    
    // Set the viewport to be the entire window
    glViewport (0, windowHeight*0.9, (GLsizei) windowWidth, (GLsizei) windowHeight*0.1);
    
    // Set the correct perspective.
    
    // Get Back to the Modelview
    glMatrixMode(GL_MODELVIEW);
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glEnable(GL_DEPTH_TEST);
    
    frame++;
    time=glutGet(GLUT_ELAPSED_TIME);
    if (time - timebase > 1000) {
        sprintf(s,"FPS:%4.2f",
                frame*1000.0/(time-timebase));
        timebase = time;
        frame = 0;
    }
    
    glColor3f(0.0f,0.0f,0.0f);
    
    glPushMatrix();
    glLoadIdentity();
    setOrthographicProjection();
    glTranslatef(100.0f, 150, 0.0f);
    renderBitmapString(5,30,0,GLUT_BITMAP_HELVETICA_18,s);
    glPopMatrix();
    restorePerspectiveProjection();
    
    glutSwapBuffers();
    
}
Exemplo n.º 5
0
 void AbstractInputWidget::drawTrack(QPainter& _p, double _pos) const
 {
   drawTrack(_p, rect().left(), _pos);
 }
Exemplo n.º 6
0
// this draws all of the stuff in the world
// NOTE: if you're drawing shadows, DO NOT set colors 
// (otherwise, you get colored shadows)
// this gets called twice per draw - once for the objects, once for the shadows
// TODO: if you have other objects in the world, make sure to draw them
void TrainView::drawStuff(bool doingShadows)
{
	// draw the control points
	// don't draw the control points if you're driving 
	// (otherwise you get sea-sick as you drive through them)
	if (!tw->trainCam->value()) {
		for(size_t i=0; i<world->points.size(); ++i) {
			if (!doingShadows) {
				if ( ((int) i) != selectedCube)
					glColor3ub(240,60,60);
				else
					glColor3ub(240,240,30);
			}
			world->points[i].draw();
		}
	}
	// draw the track
	// TODO: call your own track drawing code
	drawTrack(doingShadows);


	// draw the train
	// TODO: call your own train drawing code
	// don't draw the train if you're looking out the front window
	calcTrain();
	if (!tw->trainCam->value()) {
		drawTrain(doingShadows);
	}

	// draw trees

	t1 = new Tree();
	t1->x = -51.0f;
	t1->z = -54.0f;
	t1->angle1 = angle1;
	t1->angle2 = angle2;
	t1->draw(doingShadows);

	t2 = new Tree();
	t2->x = -58.0f;
	t2->z = -38.0f;
	t2->angle1 = angle1;
	t2->angle2 = -angle2;
	t2->draw(doingShadows);

	t3 = new Tree();
	t3->x = -45.0f;
	t3->z = -42.0f;
	t3->angle1 = -angle2;
	t3->angle2 = angle1;
	t3->draw(doingShadows);

	t4 = new Tree();
	t4->x = -13.0f;
	t4->z = -12.0f;
	t4->angle1 = angle2;
	t4->angle2 = -angle1;
	t4->draw(doingShadows);

	// draw ferris wheel cars

	car1 = new Car();
	car1->tcolor[0] = 1;
	car1->tcolor[1] = 0.5;
	car1->tcolor[2] = 1;
	car1->angle3 = angle3;
	car1->draw(doingShadows);

	car2 = new Car();
	car2->tcolor[0] = 1;
	car2->tcolor[1] = 1;
	car2->tcolor[2] = 0.5;
	car2->angle3 = angle3+60;
	car2->draw(doingShadows);

	car3 = new Car();
	car3->tcolor[0] = 0.5;
	car3->tcolor[1] = 1;
	car3->tcolor[2] = 1;
	car3->angle3 = angle3+120;
	car3->draw(doingShadows);

	car4 = new Car();
	car4->tcolor[0] = 1;
	car4->tcolor[1] = 0.5;
	car4->tcolor[2] = 1;
	car4->angle3 = angle3+180;
	car4->draw(doingShadows);

	car5 = new Car();
	car5->tcolor[0] = 1;
	car5->tcolor[1] = 1;
	car5->tcolor[2] = 0.5;
	car5->angle3 = angle3+240;
	car5->draw(doingShadows);

	car6 = new Car();
	car6->tcolor[0] = 0.5;
	car6->tcolor[1] = 1;
	car6->tcolor[2] = 1;
	car6->angle3 = angle3+300;
	car6->draw(doingShadows);
	
	// base of ferris wheel
	glPushMatrix();
		glTranslated(-60, 20, 70);

		glPushMatrix();
		glRotatef(120, 1.0f, 0.0f, 0.0f);
		glColor3f(0.8, 1, 0.8);
		glBegin(GL_POLYGON);
		GLUquadricObj *cola = gluNewQuadric();
		gluCylinder(cola, 1, 1, 30, 20, 30);
		glEnd();
		glPopMatrix();

		glPushMatrix();
		glRotatef(60, 1.0f, 0.0f, 0.0f);
		glColor3f(0.8, 1, 0.8);
		glBegin(GL_POLYGON);
		GLUquadricObj *colb = gluNewQuadric();
		gluCylinder(colb, 1, 1, 30, 20, 30);
		glEnd();
		glPopMatrix();
	
	glPopMatrix();

	// hemisphere
	int rad = 45;
	glPushMatrix();
		glTranslated(45, 0, 5);
		glRotatef(270, 1.0f, 0.0f, 0.0f);
	
	glEnable(GL_TEXTURE_2D);
	glTexImage2D(GL_TEXTURE_2D, 0, 3, texcar_w, texcar_h, 0, GL_RGB, GL_UNSIGNED_BYTE, texcar);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); // no
		glBegin(GL_QUADS);
		float ux,lx,uy,ly;
		int i,j;
		for(i = 0; i < 360; i += 18){
			if (i > 80 && i < 115) continue;
			if (i > 205 && i < 240) continue;
			for (j = 0; j < 90; j += 18)
			{	
				ux = i * (M_PI / 180);
				lx = (i + 18) * (M_PI / 180);
				uy = j * (M_PI / 180);
				ly = (j + 18) * (M_PI / 180);
				glNormal3f(cos(ux)*cos(uy),cos(ux)*sin(uy),sin(uy));
				glVertex3f(rad*cos(ux)*sin(ly),rad*sin(ux)*sin(ly),rad*cos(ly));
				glVertex3f(rad*cos(lx)*sin(ly),rad*sin(lx)*sin(ly),rad*cos(ly));
				glVertex3f(rad*cos(lx)*sin(uy),rad*sin(lx)*sin(uy),rad*cos(uy));
				glVertex3f(rad*cos(ux)*sin(uy),rad*sin(ux)*sin(uy),rad*cos(uy));
			}
		}
		glEnd();
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
}