-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFloor.cpp
62 lines (47 loc) · 1.16 KB
/
Floor.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
/*
* Floor.cpp
*
* Created on: 18/10/2014
* Author: sam
*/
#include "Floor.h"
Floor::Floor(glm::vec3 position, float width, float depth, glm::vec4 color) {
this->pos = position;
this->width = width;
this->depth = depth;
this->color = color;
leftX = pos.x - (width/2),
rightX = pos.x + (width/2),
backZ = pos.z - (depth/2),
frontZ = pos.z + (depth/2);
}
Floor::~Floor() {
// TODO Auto-generated destructor stub
}
void Floor::collision(std::vector<Particle> *particles) {
for (std::vector<Particle>::size_type i = 0; i < particles->size(); i++) {
glm::vec3 posP = (*particles)[i].pos;
if (posP.y <= pos.y)
(*particles)[i].pos += glm::vec3(0, pos.y - posP.y, 0);
}
}
void Floor::display(Shader *shader) {
shader->setModelMatrix(glm::mat4());
glColor3fv(glm::value_ptr(color));
glBegin(GL_QUADS);
float normal[] = {0,1,0};
// lx,bz rx,bz
// lx,fz rx,fz
glNormal3fv(normal);
glVertex3f(leftX, pos.y, backZ);
glNormal3fv(normal);
glVertex3f(rightX, pos.y, backZ);
glNormal3fv(normal);
glVertex3f(rightX, pos.y, frontZ);
glNormal3fv(normal);
glVertex3f(leftX, pos.y, frontZ);
glEnd();
}
void Floor::move(glm::vec3 v) {
(void)v;
}