コード例 #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
}
コード例 #2
0
ファイル: Meteor.cpp プロジェクト: PhiTheta/stellarium
void Meteor::draw(const StelCore* core, StelPainter& sPainter)
{
	if (!m_alive)
	{
		return;
	}

	float thickness;
	float bolideSize;
	calculateThickness(core, thickness, bolideSize);

	drawTrain(sPainter, thickness);

	drawBolide(sPainter, bolideSize);
}
コード例 #3
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();
}