-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolidShape3D.cpp
68 lines (50 loc) · 1.25 KB
/
SolidShape3D.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
#include "SolidShape3D.h"
SolidShape3D::SolidShape3D() {
VectorN<float, 3> tmp;
center = velocity = tmp;
setMTL();
}
SolidShape3D::SolidShape3D(const SolidShape3D& sh3d) {
setCenter(sh3d.center);
setVelocity(sh3d.velocity);
mtl.setMTL(sh3d.mtl);
}
void SolidShape3D::setCenter(float x, float y, float z) {
center[0] = x;
center[1] = y;
center[2] = z;
}
void SolidShape3D::setCenter(const VectorN<float, 3>& c) {
center = c;
}
VectorN<float, 3> SolidShape3D::getCenter() const {
return center;
}
void SolidShape3D::setVelocity(float x, float y, float z) {
velocity[0] = x;
velocity[1] = y;
velocity[2] = z;
}
void SolidShape3D::setVelocity(const VectorN<float, 3>& v) {
velocity = v;
}
VectorN<float, 3> SolidShape3D::getVelocity() const {
return velocity;
}
void SolidShape3D::move() {
center = center + velocity;
}
void SolidShape3D::setMTL(const float* color) {
mtl.setEmission(0.1, 0.1, 0.1, 1);
mtl.setAmbient(color[0],color[1],color[2], 1);
mtl.setDiffuse(0.5, 0.5, 0.5, 1);
mtl.setSpecular(1.0, 1.0, 1.0, 1);
mtl.setShininess(10);
}
void SolidShape3D::setMTL() {
mtl.setEmission(0.1, 0.1, 0.1, 1);
mtl.setAmbient(0.3, 0.3, 0.3, 1);
mtl.setDiffuse(0.5, 0.5, 0.5, 1);
mtl.setSpecular(1.0, 1.0, 1.0, 1);
mtl.setShininess(10);
}