| 83 | |
| 84 | static const char HEAD_PATH[] = "/me/head"; |
| 85 | DisplayConfigPtr DisplayConfigFactory::create(OSVR_ClientContext ctx) { |
| 86 | DisplayConfigPtr cfg(new DisplayConfig); |
| 87 | try { |
| 88 | auto const descriptorString = ctx->getStringParameter("/display"); |
| 89 | |
| 90 | auto desc = display_schema_1::DisplayDescriptor(descriptorString); |
| 91 | cfg->m_viewers.container().emplace_back(Viewer(ctx, HEAD_PATH)); |
| 92 | auto &viewer = cfg->m_viewers.container().front(); |
| 93 | auto eyesDesc = desc.getEyes(); |
| 94 | |
| 95 | /// Set up stereo vs mono |
| 96 | std::vector<uint8_t> eyeIndices; |
| 97 | Eigen::Vector3d offset; |
| 98 | if (eyesDesc.size() == 2) { |
| 99 | // stereo |
| 100 | offset = desc.getIPDMeters() / 2. * Eigen::Vector3d::UnitX(); |
| 101 | eyeIndices = {0, 1}; |
| 102 | } else { |
| 103 | // if (eyesDesc.size() == 1) |
| 104 | // mono |
| 105 | offset = Eigen::Vector3d::Zero(); |
| 106 | eyeIndices = {0}; |
| 107 | } |
| 108 | |
| 109 | /// Handle radial distortion parameters |
| 110 | boost::optional<OSVR_RadialDistortionParameters> distort; |
| 111 | auto k1 = desc.getDistortion(); |
| 112 | if (k1.k1_red != 0 || k1.k1_green != 0 || k1.k1_blue != 0) { |
| 113 | OSVR_RadialDistortionParameters params; |
| 114 | params.k1.data[0] = k1.k1_red; |
| 115 | params.k1.data[1] = k1.k1_green; |
| 116 | params.k1.data[2] = k1.k1_blue; |
| 117 | distort = params; |
| 118 | } |
| 119 | |
| 120 | /// Compute angular offset about Y of the optical (view) axis |
| 121 | util::Angle axisOffset = 0. * util::radians; |
| 122 | { |
| 123 | auto overlapPct = desc.getOverlapPercent(); |
| 124 | |
| 125 | if (overlapPct < 1.) { |
| 126 | const auto hfov = desc.getHorizontalFOV(); |
| 127 | const auto angularOverlap = hfov * overlapPct; |
| 128 | axisOffset = (hfov - angularOverlap) / 2.; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /// Infer the number of display inputs and their association with |
| 133 | /// eyes (actually surfaces) based on the descriptor. |
| 134 | std::vector<OSVR_DisplayInputCount> displayInputIndices; |
| 135 | if (eyesDesc.size() == 2 && |
| 136 | display_schema_1::DisplayDescriptor::FULL_SCREEN == |
| 137 | desc.getDisplayMode()) { |
| 138 | // two eyes, full screen - that means two screens. |
| 139 | |
| 140 | displayInputIndices = {0, 1}; |
| 141 | |
| 142 | cfg->m_displayInputs.push_back(DisplayInput( |
nothing calls this directly
no test coverage detected