-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapes.cpp
executable file
·114 lines (100 loc) · 2.86 KB
/
shapes.cpp
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
#include "includes.h"
void drawBike(float x, float y, float z,
float len, float high, float wid,
float x_deg, float y_deg, float z_deg,
float tyre,float tyre_turn)
{
y+=0.65;
glPushMatrix();
glTranslatef(x,y,z);
glRotatef(y_deg,0.0,1.0,0.0);
glRotatef(z_deg,0.0,0.0,1.0);
glRotatef(x_deg,1.0,0.0,0.0);
//back
glColor3f(1.0,1.0,0.0);
glBegin(GL_QUADS);
glVertex3f(-1*len/2,high/2,wid/2);
glVertex3f(-1*len/2,high/2,-1*wid/2);
glVertex3f(0,-1*high/2,-1*wid/2);
glVertex3f(0,-1*high/2,wid/2);
glEnd();
//front
glColor3f(0.0,1.0,1.0);
glBegin(GL_QUADS);
glVertex3f(1*len/2,high/2,wid/2);
glVertex3f(1*len/2,high/2,-1*wid/2);
glVertex3f(0,-1*high/2,-1*wid/2);
glVertex3f(0,-1*high/2,wid/2);
glEnd();
//headlight
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glTranslatef(len/1.5,high/2,0.0);
glRotatef(tyre_turn, 0.0f, 1.0f, 0.0f);
glRotatef(-90,0,1.0,0);
glutSolidCone(0.2,0.2,20,30);
glPopMatrix();
//seat
glColor3f(1.0,0.0,1.0);
glBegin(GL_QUADS);
glVertex3f(-1*len/2,high/2,wid/2);
glVertex3f(-1*len/2,high/2,-1*wid/2);
glVertex3f(1*len/2,high/2,-1*wid/2);
glVertex3f(1*len/2,high/2,wid/2);
glEnd();
//side left
glColor3f(0.0,0.5,1.0);
glBegin(GL_TRIANGLES);
glVertex3f(-1*len/2,high/2,wid/2);
glVertex3f(0,-1*high/2,wid/2);
glVertex3f(1*len/2,high/2,wid/2);
glEnd();
//side right
glColor3f(0.5,0.5,1.0);
glBegin(GL_TRIANGLES);
glVertex3f(-1*len/2,high/2,-1*wid/2);
glVertex3f(0,-1*high/2,-1*wid/2);
glVertex3f(1*len/2,high/2,-1*wid/2);
glEnd();
//handle
glPushMatrix();
glColor3f(0.0,0.0,0.0);
GLUquadricObj *quadratic1;
quadratic1 = gluNewQuadric();
glTranslatef(BIKE_LEN/2,BIKE_HIGH/2,-0.0);
glRotatef(tyre_turn, 0.0f, 1.0f, 0.0f);
gluCylinder(quadratic1,0.035f,0.035f,0.5f,32,32);
glPopMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
GLUquadricObj *quadratic2;
quadratic2 = gluNewQuadric();
glTranslatef(BIKE_LEN/2,BIKE_HIGH/2,-0.0);
glRotatef(tyre_turn+180, 0.0f, 1.0f, 0.0f);
gluCylinder(quadratic2,0.035f,0.035f,0.5f,32,32);
glPopMatrix();
glColor3f(1.0,1.0,1.0);
//Front Tyre
glPushMatrix();
glTranslatef( len/2 , -high/2 , 0.0 );
glRotatef(tyre_turn,0.0,1.0,0.0);
glRotatef(tyre,0.0,0.0,1.0);
glutWireTorus(0.1,0.3,10,20);
glPopMatrix();
//Rear Tyre
glPushMatrix();
glTranslatef( -len/2 ,-high/2 ,0.0 );
glRotatef(tyre,0.0,0.0,1.0);
glutWireTorus(RIM_RADIUS,TYRE_RADIUS,10,20);
glPopMatrix();
glPopMatrix();
}
void drawFossil(float x,float y,float z,float angle,float color[3])
{
glPushMatrix();
glColor3f(color[0],color[1],color[2]);
glTranslatef(x,y,z);
glRotatef(angle,0.0,1.0,0.0);
glutSolidOctahedron();
glPopMatrix();
}