-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobstacle.cpp
75 lines (58 loc) · 1.66 KB
/
obstacle.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
#include "obstacle.h"
obstacle::obstacle()
{
}
obstacle::obstacle(Point3D position, GLfloat width, GLfloat length, GLfloat height)
{
this->position = position;
this->CollisionMesh = CollisionMesh;
this->width = width;
this->length = length;
this->height = height;
this->CollisionMesh.x1 = position.x - width/2;
this->CollisionMesh.y1 = position.y + length/2;
this->CollisionMesh.x2 = position.x + width/2;
this->CollisionMesh.y2 = position.y - length/2;
}
obstacle::~obstacle()
{
}
bool obstacle::initialize()
{
return true;
}
void obstacle::render()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
//glLoadIdentity();
glTranslatef(position.x, position.y, position.z);
GLfloat w = width * 0.5f, l = length * 0.5f, h = height * 0.5f;
glBegin(GL_QUADS);
glVertex3f(-w, l, h); // Top face
glVertex3f(w, l, h);
glVertex3f(w, -l, h);
glVertex3f(-w, -l, h);
glVertex3f(-w, l, -h); // Bottom face
glVertex3f(w, l, -h);
glVertex3f(w, -l, -h);
glVertex3f(-w, -l, -h);
glVertex3f(-w, -l, h); // Forward face
glVertex3f(w, -l, h);
glVertex3f(w, -l, -h);
glVertex3f(-w, -l, -h);
glVertex3f(-w, l, h); // Rear face
glVertex3f(w, l, h);
glVertex3f(w, l, -h);
glVertex3f(-w, l, -h);
glVertex3f(w, l, h); // Right face
glVertex3f(w, l, -h);
glVertex3f(w, -l, -h);
glVertex3f(w, -l, h);
glVertex3f(-w, l, h); // Left face
glVertex3f(-w, l, -h);
glVertex3f(-w, -l, -h);
glVertex3f(-w, -l, h);
glEnd();
glPopMatrix();
}