Esempio n. 1
0
	ModelPtr GetModel(const std::string& modelName)
	{
		std::string name = boost::to_lower_copy(modelName) + ".mod";
		auto fileIter = m_modelsByFile.find(name);
		if (fileIter != m_modelsByFile.end())
		{
			return fileIter->second;
		}

		auto iter = m_models.find(modelName);
		if (iter != m_models.end())
		{
			return iter->second;
		}

		EQEmu::EQGModelLoader model_loader;
		ModelPtr model;

		if (model_loader.Load(m_archive, name, model))
		{
			model->SetName(modelName);
			m_models[modelName] = model;
		}

		return model;
	}
Esempio n. 2
0
	virtual bool Load() override
	{
		bool loadedSomething = m_archive.Open(GetZoneFile(m_zd));

		std::string base_filename = (boost::format("%s\\%s")
			% m_zd->GetEQPath()
			% m_zd->GetZoneName()).str();

		// next we need to try to read an _assets file and load more eqg based data.
		std::string assets_file = base_filename + "_assets.txt";
		std::error_code ec;
		if (sys::exists(assets_file, ec))
		{
			std::vector<std::string> filenames;
			std::ifstream assets(assets_file.c_str());

			if (assets.is_open())
			{
				std::copy(std::istream_iterator<std::string>(assets),
					std::istream_iterator<std::string>(),
					std::back_inserter(filenames));

				for (auto& name : filenames)
				{
					std::string asset_file = (boost::format("%s\\%s") % m_zd->GetEQPath() % name).str();
					EQEmu::PFS::Archive archive;

					if (!archive.Open(asset_file))
						continue;

					std::vector<std::string> models;

					if (archive.GetFilenames("mod", models))
					{
						for (auto& modelName : models)
						{
							EQEmu::EQGModelLoader model_loader;
							ModelPtr model;

							model_loader.Load(archive, modelName, model);
							if (model)
							{
								model->SetName(modelName);
								m_modelsByFile[modelName] = model;
								loadedSomething = true;
							}
						}
					}
				}
			}
		}

		return loadedSomething;
	}
Esempio n. 3
0
	virtual bool Load() override
	{
		std::vector<EQEmu::S3D::WLDFragment> zone_object_frags;

		std::string base_filename = (boost::format("%s\\%s")
			% m_zd->GetEQPath()
			% m_zd->GetZoneName()).str();
		bool loadedSomething = false;

		EQEmu::PFS::Archive archive;

		for (int i = 0; i < 3; i++)
		{
			std::string suffix;
			if (i > 0)
				suffix = "_obj";
			if (i > 1)
				suffix += std::to_string(i);

			std::string wld_name = m_zd->GetZoneName() + suffix + ".wld";
			std::string file_name = (boost::format("%s\\%s.s3d")
				% m_zd->GetEQPath() % (m_zd->GetZoneName() + suffix)).str();

			EQEmu::S3DLoader loader;
			std::vector<EQEmu::S3D::WLDFragment> frags;

			if (loader.ParseWLDFile(file_name, wld_name, frags))
			{
				for (auto& frag : frags)
				{
					if (frag.type == 0x36)
					{
						EQEmu::S3D::WLDFragment36 &frag36 = reinterpret_cast<EQEmu::S3D::WLDFragment36&>(frag);
						auto model = frag36.GetData();

						if (m_s3dModels.find(model->GetName()) == m_s3dModels.end())
						{
							m_s3dModels[model->GetName()] = model;
							loadedSomething = true;
						}
					}
				}
			}
		}

		// next we need to try to read an _assets file and load more eqg based data.
		std::string assets_file = base_filename + "_assets.txt";
		std::error_code ec;
		if (sys::exists(assets_file, ec))
		{
			std::vector<std::string> filenames;
			std::ifstream assets(assets_file.c_str());

			if (assets.is_open())
			{
				std::copy(std::istream_iterator<std::string>(assets),
					std::istream_iterator<std::string>(),
					std::back_inserter(filenames));

				if (m_zd->GetZoneName() == "poknowledge")
				{
					filenames.push_back("poknowledge_obj3.eqg");
				}

				for (auto& name : filenames)
				{
					std::string asset_file = (boost::format("%s\\%s") % m_zd->GetEQPath() % name).str();
					EQEmu::PFS::Archive archive;

					if (!archive.Open(asset_file))
						continue;

					std::vector<std::string> models;

					if (archive.GetFilenames("mod", models))
					{
						for (auto& modelName : models)
						{
							EQEmu::EQGModelLoader model_loader;
							ModelPtr model;

							model_loader.Load(archive, modelName, model);
							if (model)
							{
								model->SetName(modelName);
								m_eqgModels[modelName] = model;
								loadedSomething = true;
							}
						}
					}
				}
			}
		}

		return loadedSomething;
	}