| 93 | } |
| 94 | |
| 95 | void BasicIBRScene::createFromData(const uint width) |
| 96 | { |
| 97 | _cams.reset(new CalibratedCameras()); |
| 98 | _imgs.reset(new InputImages()); |
| 99 | _proxies.reset(new ProxyMesh()); |
| 100 | |
| 101 | // setup calibrated cameras |
| 102 | if (_currentOpts.cameras) { |
| 103 | |
| 104 | _cams->setupFromData(_data); |
| 105 | |
| 106 | std::cout << "Number of Cameras set up: " << _cams->inputCameras().size() << std::endl; |
| 107 | } |
| 108 | |
| 109 | // load input images |
| 110 | |
| 111 | uint mwidth = width; |
| 112 | if (_currentOpts.images) { |
| 113 | _imgs->loadFromData(_data); |
| 114 | std::cout << "Number of Images loaded: " << _imgs->inputImages().size() << std::endl; |
| 115 | |
| 116 | if (width == 0) {// default |
| 117 | if (_imgs->inputImages()[0]->w() > 1920) { |
| 118 | SIBR_LOG << "Limiting width to 1920 for performance; use --texture-width to override" << std::endl; |
| 119 | mwidth = 1920; |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | _renderTargets.reset(new RenderTargetTextures(mwidth)); |
| 124 | |
| 125 | if (_currentOpts.mesh) { |
| 126 | // load proxy |
| 127 | _proxies->loadFromData(_data); |
| 128 | |
| 129 | |
| 130 | std::vector<InputCamera::Ptr> inCams = _cams->inputCameras(); |
| 131 | float eps = 0.1f; |
| 132 | if (inCams.size() > 0 && (abs(inCams[0]->znear() - 0.1) < eps || abs(inCams[0]->zfar() - 1000.0) < eps || abs(inCams[0]->zfar() - 100.0) < eps) && _proxies->proxy().triangles().size() > 0) { |
| 133 | std::vector<sibr::Vector2f> nearsFars; |
| 134 | CameraRaycaster::computeClippingPlanes(_proxies->proxy(), inCams, nearsFars); |
| 135 | _cams->updateNearsFars(nearsFars); |
| 136 | } |
| 137 | |
| 138 | //// Load the texture. |
| 139 | sibr::ImageRGB inputTextureImg; |
| 140 | |
| 141 | std::string texturePath, textureImageFileName; |
| 142 | |
| 143 | // Assumes that the texture is stored next to the mesh in the same directory |
| 144 | // This information comes from Assimp and the mtl file if available |
| 145 | if ((textureImageFileName = _proxies->proxy().getTextureImageFileName()) != "") { |
| 146 | texturePath = sibr::parentDirectory(_data->meshPath()) + "/" + textureImageFileName; |
| 147 | // check if full path given |
| 148 | if (!sibr::fileExists(texturePath) && sibr::fileExists(textureImageFileName)) |
| 149 | texturePath = textureImageFileName; |
| 150 | } |
| 151 | else { |
| 152 | texturePath = sibr::parentDirectory(_data->meshPath()) + "/mesh_u1_v1.png"; |
nothing calls this directly
no test coverage detected