-
Notifications
You must be signed in to change notification settings - Fork 0
/
Renderable.hh
53 lines (48 loc) · 1.31 KB
/
Renderable.hh
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
#ifndef RENDERABLE_HH
#define RENDERABLE_HH
template<class F>
class Renderable :
virtual public Object<F>
{
public:
virtual void Render(std::ostream& out) = 0;
protected:
void OutputPosition(std::ostream& out)
{
#if 0
if (mPI == 0) {
mPI = 4*atan(1);
}
out << "scale " << Object<F>::mRadius << std::endl;
F y = Object<F>::mOrientation(1, 0);
F z = Object<F>::mOrientation(2, 0);
if (z == 1) {
out << "rotate y * -90" << std::endl;
} else if (z == -1) {
out << "rotate y * 90" << std::endl;
} else {
F yrotation = asin(-z);
F zrotation = asin(-(y / sqrt((1 - z * z))));
out << "rotate y * " << (yrotation * 360 / 2 / mPI) << std::endl;
out << "rotate z * " << (zrotation * 360 / 2 / mPI) << std::endl;
}
#endif
out << "matrix <";
ZenMatrix<F, 3, 3> matrix = Object<F>::mRotation.GetRotationMatrix();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
// if ((i == 2 || j == 2) && i != j) {
// out << -(matrix(i, j) * Object<F>::mRadius) << ", ";
// } else {
out << (matrix(j, i) * Object<F>::mRadius) << ", ";
// }
}
}
out << Object<F>::mLocation(0, 0) << ", ";
out << Object<F>::mLocation(1, 0) << ", ";
out << Object<F>::mLocation(2, 0) << ">" << std::endl;
}
private:
F mPI;
};
#endif