| 141 | } |
| 142 | |
| 143 | Urho3D::Model *buildModel(Urho3D::Context *ctx,SEGS::Model *mdl) |
| 144 | { |
| 145 | ResourceCache* cache = ctx->m_ResourceCache.get(); |
| 146 | auto parts=mdl->geoset->geopath.split('/'); |
| 147 | while(!parts.isEmpty()) |
| 148 | { |
| 149 | QString str=parts.takeFirst(); |
| 150 | if(str.compare(QLatin1Literal("object_library"),Qt::CaseInsensitive)==0) |
| 151 | break; |
| 152 | } |
| 153 | QString cache_path="converted/Models/"+parts.join('/')+"/"+mdl->name+".mdl"; |
| 154 | if(cache->Exists(cache_path)) |
| 155 | { |
| 156 | auto lf3d_model=cache->GetResource<Urho3D::Model>(cache_path); |
| 157 | if(lf3d_model) |
| 158 | { |
| 159 | std::vector<SEGS::HTexture> v2 = getModelTextures(ctx,mdl->geoset->tex_names); |
| 160 | initLoadedModel([ctx](const QString &v) -> SEGS::HTexture { return tryLoadTexture(ctx, v); },mdl,v2); |
| 161 | return lf3d_model; |
| 162 | } |
| 163 | } |
| 164 | QFile fl(basepath+mdl->geoset->geopath); |
| 165 | if(!fl.exists() || !fl.open(QFile::ReadOnly) || s_coh_model_to_engine_model.size()>5000) |
| 166 | { |
| 167 | if(s_coh_model_to_engine_model.size()<=3) // this will report first few missing geometry files |
| 168 | { |
| 169 | qDebug() << "Missing geo file" << basepath+mdl->geoset->geopath; |
| 170 | } |
| 171 | return nullptr; |
| 172 | } |
| 173 | if(!mdl->geoset->data_loaded) { |
| 174 | geosetLoadData(fl,mdl->geoset); |
| 175 | if (!mdl->geoset->subs.empty()) |
| 176 | createEngineModelsFromPrefabSet(ctx,mdl->geoset); |
| 177 | |
| 178 | } |
| 179 | QDir modeldir("converted/Models"); |
| 180 | modeldir.mkpath(parts.join('/')); |
| 181 | auto res_static=s_coh_model_to_engine_model[mdl]; |
| 182 | File model_res(ctx,cache_path,FILE_WRITE); |
| 183 | res_static->Save(model_res); |
| 184 | res_static->SetName("Models/"+parts.join('/')+"/"+mdl->name+".mdl"); |
| 185 | cache->AddManualResource(res_static); |
| 186 | return res_static; |
| 187 | } |
| 188 | |
| 189 | void convertMaterial(Urho3D::Context *ctx,CoHModel *mdl,StaticModel* boxObject) |
| 190 | { |
no test coverage detected