40 using osvr::util::degrees;
43 typedef std::vector<double> BoundsList;
53 : near(zNear), far(zFar), rect(std::move(inputRect)) {
54 xBounds.assign({-1, 1});
55 yBounds.assign({-1, 1});
56 std::cout <<
"Near: " << near <<
"\tFar: " << far <<
"\n";
57 std::cout << rect << std::endl;
59 template <opts::OptionType Options = 0>
inline void tryProjection() {
61 {(osvr::util::projection_options::IsZOutputUnsigned<Options>::value
66 <<
"\n Left handed input: " << std::boolalpha
67 << osvr::util::projection_options::IsLeftHandedInput<Options>::value
70 <<
"Unsigned Z output: " << std::boolalpha
71 << osvr::util::projection_options::IsZOutputUnsigned<Options>::value
74 osvr::util::parameterizedCreateProjectionMatrix<Options>(rect, near,
76 std::cout <<
"Projection matrix:\n";
77 std::cout << projection << std::endl;
79 std::cout <<
"Frustum corners:\n";
80 Eigen::Matrix4d inv = projection.inverse();
81 for (
auto z : zBounds) {
82 for (
auto y : yBounds) {
83 for (
auto x : xBounds) {
84 Eigen::Vector4d bound(x, y, z, 1);
86 << bound.transpose() <<
"\t<-\t"
102 int main(
int argc,
char *argv[]) {
104 xBounds.push_back(-1);
105 xBounds.push_back(1);
107 BoundsList yBounds(xBounds);
109 BoundsList zBounds(xBounds);
111 BoundsList zBounds{{0., 1.}};
118 std::cout <<
"Near: " << near <<
"\tFar: " << far <<
"\n";
119 std::cout << rect << std::endl;
121 std::cout <<
"Projection matrix:\n";
122 std::cout << projection << std::endl;
124 std::cout <<
"Frustum corners:\n";
125 Eigen::Matrix4d inv = projection.inverse();
126 for (
auto z : zBounds) {
127 for (
auto y : yBounds) {
128 for (
auto x : xBounds) {
129 Eigen::Vector4d bound(x, y, z, 1);
130 std::cout << bound.transpose() <<
"\t<-\t"
139 demo.tryProjection<0>();
140 demo.tryProjection<opts::LeftHandedInput>();
141 demo.tryProjection<opts::ZOutputUnsigned>();
142 demo.tryProjection<opts::LeftHandedInput | opts::ZOutputUnsigned>();
Rectd computeSymmetricFOVRect(AngleGeneric< System > hFov, AngleGeneric< System > vFov)
Compute a rectangle at unit distance for the given fov values.
detail::SameLayoutVector< 3, Derived > extractPoint(Eigen::MatrixBase< Derived > const &homogenous)
Pulls the 3D point or vector from a 4D vec, performing division by w if it is nonzero.
Eigen::Matrix4d createProjectionMatrix(Rectd const &bounds, double near, double far)
Takes in points at the near clipping plane, as well as the near and far clipping planes. Result matrix maps [l, r] and [b, t] to [-1, 1], and [n, f] to [-1, 1] (should be configurable)