-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.cc
More file actions
114 lines (103 loc) · 2.98 KB
/
train.cc
File metadata and controls
114 lines (103 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "cylinder.h"
#include "color.h"
#include "train.h"
#include "cube.h"
#include "pie.h"
#include "cover.h"
#include "wheel.h"
#include "pile.h"
#include "beam.h"
#include "smoke.h"
double angle = 0;
extern float black[4];
extern int ntexMetal;
extern int daytime;
extern float white[4];
extern Particle smokeparticles[2][1600];
//
// draw the cylinder.
//
void train(double x, double y, double z, double scaleX, double scaleY, double scaleZ, int lightnum, int smokeindex)
{
int iTimeElapsed = glutGet(GLUT_ELAPSED_TIME);
float fRevolveScale2 = 0.1f;
angle = iTimeElapsed * fRevolveScale2;
double moveDistX = -0.8 * angle / 360;
glPushMatrix();
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, black);
Color colorBlack(0, 0, 0, 1);
glColor3f(colorBlack.r, colorBlack.g, colorBlack.b);
glTranslated(x, y, z);
glScaled(scaleX, scaleY, scaleZ);
glTranslated(moveDistX, 0, 0);
if(!daytime)
{
beam(1, 0, 0, 45, -1, 0, 0, lightnum);
}
else
{
glDisable(lightnum);
}
glPushMatrix();
glRotatef(-90, 0, 0, 1);
cylinder(0.3333, 1.2, Color(0.02, 0.02, 0.02, 1));
glTranslated(0, -0.1, 0);
pie(0.3333 - 0.1 * Tan(60), Color(1,1,1,1));
glRotated(180, 0, 0, 1);
cover(0.3333 - 0.1 * Tan(60), 60, 0.1, Color(0.02, 0.02, 0.02, 1));
glRotated(180, 0, 0, 1);
glTranslated(0, 0.1, 0);
glRotated(180, 0, 0, 1);
glTranslated(0, -1.2, 0);
cover(0.3333, 60, 0.1, Color(0.02, 0.02, 0.02, 1));
glTranslated(0, -0.4, 0);
cylinder(0.3333 + Tan(60) * 0.1, 0.3, Color(0.02, 0.02, 0.02, 1));
glTranslated(0.1, -0.3, 0);
cube(0.3333 + Tan(60) * 0.2, 0.6, 0.3333 + Tan(60) * 0.1, Color(0.02, 0.02, 0.02, 1), 0X3F, 1, ntexMetal);
glTranslated(0.37, -0.6, 0);
glRotated(60, 0,1, 0);
pile(0.6, 1.2, 120, Color(1,0,0,1));
glPopMatrix();
glPushMatrix();
glTranslated(0.2333, 0.3, 0);
cylinder(0.1333, 0.2, colorBlack);
glTranslated(0, 0.15, 0);
glRotated(180, 0, 0, 1);
cover(0.1333, 30, 0.44, colorBlack);
glRotated(180, 0, 0, 1);
glTranslated(0, 0.44, 0);
cylinder(0.1333 + 0.44 * Tan(30), 0.1, colorBlack);
glTranslated(0, 0.15, 0);
cover(0.1333 + 0.44 * Tan(30) - 0.05 * Tan(60), 60, 0.05, colorBlack);
glPopMatrix();
glPushMatrix();
glTranslated(0.4, -0.3, 0);
cube(0.4, 0.1, 0.2, colorBlack, 0X3F, 1, ntexMetal);
glPopMatrix();
glPushMatrix();
glRotated(-90, 0, 0, 1);
glTranslated(0, 0, 0);
pie(0.3333, colorBlack);
glTranslated(0, 0.6667, 0);
pie(0.3333, Color(0, 0, 0, 1));
glPopMatrix();
glPushMatrix();
glTranslated(0.6, -0.4, 0);
cube(0.65, 0.1, 0.6, colorBlack, 0X3F, 1, ntexMetal);
glRotated(90, 1, 0, 0);
glTranslated(-0.2, -0.6, 0.1);
threewheels(0.20, 0.25, 0.35, 0.1, 0.05, 0.8, colorBlack, 1);
glRotated(180, 1, 0, 0);
glTranslated(0, -1.2, 0);
threewheels(0.20, 0.25, 0.35, 0.1, 0.05, 0.8, colorBlack, -1);
glPopMatrix();
glPopMatrix();
// glTranslated(x + scaleX * moveDistX, 10, 0);
// drawsmoke(smokeparticles[smokeindex], 1600, 1);
}