-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprimitive.cpp
More file actions
32 lines (26 loc) · 868 Bytes
/
Copy pathprimitive.cpp
File metadata and controls
32 lines (26 loc) · 868 Bytes
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
#include "primitive.h"
Vert operator+(const Vert &lhs, const Vert &rhs) {
return Vert(lhs.pos + rhs.pos, lhs.norm + rhs.norm, lhs.tex + rhs.tex, lhs.pos_view + rhs.pos_view);
}
Vert operator*(float t, const Vert &rhs) {
return Vert(rhs.pos * t, rhs.norm * t, rhs.tex * t, rhs.pos_view * t);
}
Vert operator*(const Vert &lhs, float t) {
return Vert(lhs.pos * t, lhs.norm * t, lhs.tex * t, lhs.pos_view * t);
}
Triangle toTriangle(Vert &v0, Vert &v1, Vert &v2) {
Triangle t;
t.poses[0] = v0.pos.value();
t.norms[0] = v0.norm;
t.texs[0] = v0.tex;
t.poses_view[0] = v0.pos_view;
t.poses[1] = v1.pos.value();
t.norms[1] = v1.norm;
t.texs[1] = v1.tex;
t.poses_view[1] = v1.pos_view;
t.poses[2] = v2.pos.value();
t.norms[2] = v2.norm;
t.texs[2] = v2.tex;
t.poses_view[2] = v2.pos_view;
return t;
}