MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / main

Function main

examples/internals/ProjectionSample.cpp:102–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100};
101
102int main(int argc, char *argv[]) {
103 BoundsList xBounds;
104 xBounds.push_back(-1);
105 xBounds.push_back(1);
106
107 BoundsList yBounds(xBounds);
108#if 1
109 BoundsList zBounds(xBounds);
110#else
111 BoundsList zBounds{{0., 1.}};
112#endif
113
114 double near = 0.1;
115 double far = 1000;
116 auto rect =
117 osvr::util::computeSymmetricFOVRect(50. * degrees, 40. * degrees, near);
118 std::cout << "Near: " << near << "\tFar: " << far << "\n";
119 std::cout << rect << std::endl;
120 auto projection = osvr::util::createProjectionMatrix(rect, near, far);
121 std::cout << "Projection matrix:\n";
122 std::cout << projection << std::endl;
123
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"
131 << osvr::util::extractPoint(inv * bound).transpose()
132 << "\n";
133 }
134 }
135 }
136
137 {
138 ProjectionDemo demo(0.1, 1000);
139 demo.tryProjection<0>();
140 demo.tryProjection<opts::LeftHandedInput>();
141 demo.tryProjection<opts::ZOutputUnsigned>();
142 demo.tryProjection<opts::LeftHandedInput | opts::ZOutputUnsigned>();
143 return 0;
144 }
145 return 0;
146}

Callers

nothing calls this directly

Calls 4

computeSymmetricFOVRectFunction · 0.85
createProjectionMatrixFunction · 0.85
extractPointFunction · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected