void TileAssembler::exportGameobjectModels() { FILE* model_list = fopen((iSrcDir + "/" + "temp_gameobject_models").c_str(), "rb"); if (!model_list) return; FILE* model_list_copy = fopen((iDestDir + "/" + GAMEOBJECT_MODELS).c_str(), "wb"); if (!model_list_copy) { fclose(model_list); return; } uint32 name_length, displayId; char buff[500]; while (!feof(model_list)) { if (fread(&displayId, sizeof(uint32), 1, model_list) != 1 || fread(&name_length, sizeof(uint32), 1, model_list) != 1 || name_length >= sizeof(buff) || fread(&buff, sizeof(char), name_length, model_list) != name_length) { std::cout << "\nFile 'temp_gameobject_models' seems to be corrupted" << std::endl; break; } std::string model_name(buff, name_length); WorldModel_Raw raw_model; if ( !raw_model.Read((iSrcDir + "/" + model_name).c_str()) ) continue; spawnedModelFiles.insert(model_name); AABox bounds; bool boundEmpty = true; for (uint32 g = 0; g < raw_model.groupsArray.size(); ++g) { std::vector<Vector3>& vertices = raw_model.groupsArray[g].vertexArray; uint32 nvectors = vertices.size(); for (uint32 i = 0; i < nvectors; ++i) { Vector3& v = vertices[i]; if (boundEmpty) bounds = AABox(v, v), boundEmpty = false; else bounds.merge(v); } } fwrite(&displayId, sizeof(uint32), 1, model_list_copy); fwrite(&name_length, sizeof(uint32), 1, model_list_copy); fwrite(&buff, sizeof(char), name_length, model_list_copy); fwrite(&bounds.low(), sizeof(Vector3), 1, model_list_copy); fwrite(&bounds.high(), sizeof(Vector3), 1, model_list_copy); } fclose(model_list); fclose(model_list_copy); }
void merger::update_references() { typedef std::pair<qname, origin_types> value_type; std::map<std::string, value_type> references_by_model_name; for (const auto& pair : models_) { const auto& model(pair.second); const auto value(std::make_pair(model.name(), model.origin_type())); const auto p(std::make_pair(model.name().model_name(), value)); references_by_model_name.insert(p); } std::unordered_map<qname, origin_types> updated_references; for (auto& pair : merged_model_.references()) { const auto qn(pair.first); const auto mn(qn.model_name()); const auto i(references_by_model_name.find(mn)); if (i == references_by_model_name.end()) { BOOST_LOG_SEV(lg, error) << msising_dependency << mn; BOOST_THROW_EXCEPTION(merging_error(msising_dependency + mn)); } const auto p(std::make_pair(i->second.first, i->second.second)); updated_references.insert(p); } merged_model_.references(updated_references); }
std::shared_ptr<::gua::node::Node> PBRLoader::create_geometry_from_file(std::string const& node_name, std::string const& file_name) { node_counter_ = 0; std::shared_ptr<::gua::node::Node> new_node; std::shared_ptr<pbr::ren::RawPointCloud> point_cloud = std::make_shared<pbr::ren::RawPointCloud>(model_counter_); if (point_cloud->Load(file_name)) { // load point cloud std::string model_name("type=file&file=" + file_name); GeometryDatabase::instance()->add(model_name, std::make_shared<PBRRessource>(point_cloud)); ++model_counter_; auto node(std::make_shared<::gua::node::PBRNode>(model_name)); node->set_filename(model_name); node->set_material("gua_pbr"); return node; } else { Logger::LOG_WARNING << "Failed to load object \"" << file_name << "\": File does not exist!" << std::endl; return nullptr; } }
//------------------------------------------------------------- // exports car model. Car models are typical MODEL structures //------------------------------------------------------------- void ExportCarModel(MODEL* model, int size, int index, const char* name_suffix) { EqString model_name(varargs("%s/CARMODEL_%d_%s", g_levname_moddir.c_str(), index, name_suffix)); // export model ExportDMODELToOBJ(model, model_name.c_str(), index, true); // save original dmodel2 IFile* dFile = GetFileSystem()->Open(varargs("%s.dmodel", model_name.c_str()), "wb", SP_ROOT); if(dFile) { dFile->Write(model, size, 1); GetFileSystem()->Close(dFile); } }
void Update() { for (int i = 1; i < HIGHEST_ENTITY; i++) { CachedEntity *ent = ENTITY(i); if (CE_BAD(ent)) continue; const model_t *model = RAW_ENT(ent)->GetModel(); bool issandwich = false; if (model && tickcount % 33 == 0) { std::string model_name(g_IModelInfo->GetModelName(model)); if (model_name.find("plate") != std::string::npos) { issandwich = true; Vector abs_orig = RAW_ENT(ent)->GetAbsOrigin(); float movement = prevloc[i].DistTo(abs_orig); logging::Info("Sandwich movement: %f", movement); prevloc[i] = abs_orig; } } if (ent->m_Type() == ENTITY_PROJECTILE || issandwich) { /*int owner = CE_INT(ent, 0x894) & 0xFFF; if (owner != LOCAL_W->m_IDX) continue;*/ if (tickcount % 20 == 0) { Vector abs_orig = RAW_ENT(ent)->GetAbsOrigin(); float movement = prevloc[i].DistTo(abs_orig); logging::Info("movement: %f", movement); prevloc[i] = abs_orig; const Vector &v = ent->m_vecVelocity; const Vector &a = ent->m_vecAcceleration; Vector eav; velocity::EstimateAbsVelocity(RAW_ENT(ent), eav); // logging::Info("%d [%s]: CatVelocity: %.2f %.2f //%.2f //(%.2f) | EAV: %.2f %.2f %.2f (%.2f)", i, // RAW_ENT(ent)->GetClientClass()->GetName(), v.x, v.y, v.z, // v.Length(), a.x, a.y, a.z); logging::Info("%d [%s]: CatVelocity: %.2f %.2f %.2f (%.2f) | " "EAV: %.2f %.2f %.2f (%.2f)", i, RAW_ENT(ent)->GetClientClass()->GetName(), v.x, v.y, v.z, v.Length(), eav.x, eav.y, eav.z, eav.Length()); } } } }
inline void smc_do (vsmc::Sampler<T> &sampler, std::ostream &zconst_file, const std::string schedule_name, std::size_t model_num, std::size_t iter_num) { if (model_num == 0) return; sampler.particle().value().comp_num(model_num); sampler.initialize(); vsmc::StopWatch watch; watch.start(); if (iter_num == 0) { while (sampler.particle().value().state(0, 0).alpha() < 1) sampler.iterate(); } else { sampler.iterate(iter_num); } watch.stop(); std::fprintf(stderr, "time.model.order.%u %f\n", static_cast<unsigned>(model_num), watch.seconds()); std::fflush(stderr); zconst_file << sampler.iter_size() - 1 << ' '; zconst_file << sampler.particle().value().zconst() + sampler.particle().value().log_likelihood_const() << ' '; zconst_file << sampler.path_sampling() + sampler.particle().value().log_likelihood_const() << ' '; #ifdef VSMC_PET_HPP zconst_file << sampler.monitor("vd").record(0) << ' '; zconst_file << sampler.monitor("vd").record(1) - sampler.monitor("vd").record(0) * sampler.monitor("vd").record(0); #endif zconst_file << ' '; std::ofstream sampler_file; std::string fn; std::stringstream ss; ss << model_num; std::string model_name(ss.str()); fn = std::string("smc.sampler."); fn += Suffix + "." + schedule_name + "." + model_name; sampler_file.open(fn.c_str()); sampler_file << sampler; sampler_file.close(); sampler_file.clear(); }
void fx_disp_window::setup_name() { regress_pro *app = (regress_pro *) getApp(); FXHorizontalFrame *modelfm = new FXHorizontalFrame(this, LAYOUT_FILL_X|FRAME_GROOVE, 0,0,0,0, 0,0,0,0, 0,0); FXString model_name(disp->dclass->full_name); model_name.append(" Model"); FXLabel *model_label = new FXLabel(modelfm, model_name, NULL, LABEL_NORMAL|LAYOUT_FILL_X, 0, 0, 0, 0, 2*DEFAULT_PAD, 2*DEFAULT_PAD, 3*DEFAULT_PAD, 3*DEFAULT_PAD); model_label->setFont(&app->big_web_font); model_label->setTextColor(app->blue_web); model_label->setBackColor(FXRGB(255, 206, 91)); FXHorizontalFrame *namehf = new FXHorizontalFrame(this, LAYOUT_FILL_X); new FXLabel(namehf, "Name "); FXTextField *tf = new FXTextField(namehf, 24, this, ID_NAME, FRAME_SUNKEN); tf->setText(CSTR(disp->name)); }
void DecodableModel::choosePath(const Sequence &s, Sequence &path){ std::cerr << model_name() << ": not implemented choosePath" << std::endl; }
static void update_ahci_device(char *path, char *shortname) { struct device_data *ptr; FILE *file; char fullpath[4096]; char name[4096], *c; ptr = devices; sprintf(fullpath, "%s/ahci_alpm_accounting", path); if (access(fullpath, R_OK)) return; if (first_time) { file = fopen(fullpath, "w"); if (file) fprintf(file, "1\n"); if (file) fclose(file); } while (ptr) { if (strcmp(ptr->pathname, path)==0) { sprintf(fullpath, "%s/ahci_alpm_active", path); file = fopen(fullpath, "r"); if (!file) return; fgets(name, 4096, file); ptr->active = strtoull(name, NULL, 10); fclose(file); sprintf(fullpath, "%s/ahci_alpm_partial", path); file = fopen(fullpath, "r"); if (!file) return; fgets(name, 4096, file); ptr->partial = strtoull(name, NULL, 10); fclose(file); sprintf(fullpath, "%s/ahci_alpm_slumber", path); file = fopen(fullpath, "r"); if (!file) return; fgets(name, 4096, file); ptr->slumber = strtoull(name, NULL, 10); fclose(file); ptr->total = ptr->active + ptr->partial + ptr->slumber; return; } ptr = ptr->next; } /* no luck, new one */ ptr = malloc(sizeof(struct device_data)); assert(ptr!=0); memset(ptr, 0, sizeof(struct device_data)); ptr->next = devices; devices = ptr; strcpy(ptr->pathname, path); c = model_name(path, shortname); strcpy(ptr->human_name, c); free(c); }