#include "ff7DataInstaller.h" #include #include #include #include #include #include #include #include "QGearsGameState.h" #include "data/QGearsAFileManager.h" #include "data/QGearsBackgroundFileManager.h" #include "data/QGearsCameraMatrixFileManager.h" #include "data/QGearsHRCFileManager.h" #include "data/QGearsLZSFLevelFileManager.h" #include "data/QGearsPaletteFileManager.h" #include "data/QGearsPFileManager.h" #include "data/QGearsRSDFileManager.h" #include "data/QGearsTexCodec.h" #include "map/QGearsBackground2DFileManager.h" #include "map/QGearsWalkmeshFileManager.h" #include "data/FF7ModelListFileManager.h" #include "data/QGearsLGPArchiveFactory.h" #include "common/QGearsStringUtil.h" #include "common/FF7NameLookup.h" FF7DataInstaller::FF7DataInstaller() { m_root = std::make_unique("", "", "installer.log"); Ogre::ArchiveManager::getSingleton().addArchiveFactory(new QGears::LGPArchiveFactory()); mResourceManagers.emplace_back(std::make_shared()); mResourceManagers.emplace_back(std::make_shared()); mResourceManagers.emplace_back(std::make_shared()); mResourceManagers.emplace_back(std::make_shared()); } FF7DataInstaller::~FF7DataInstaller() { } void FF7DataInstaller::Convert(std::string inputDir, std::string outputDir, const std::vector& files) { for (const auto& file : files) { if (file == "field\\char.lgp") { auto fullPath = inputDir + file; // m_root->addResourceLocation(inputDir, "FileSystem", "FFVII"); m_root->addResourceLocation(fullPath, "LGP", "FFVII"); ConvertFieldModels(fullPath, outputDir); } } } // TOOD: Share with pc model exporter static void exportMesh(std::string outdir, const Ogre::MeshPtr &mesh) { Ogre::MeshSerializer mesh_ser; mesh_ser.exportMesh(mesh.getPointer(), outdir + mesh->getName()); Ogre::SkeletonPtr skeleton(mesh->getSkeleton()); Ogre::SkeletonSerializer sk_ser; sk_ser.exportSkeleton(skeleton.getPointer(), outdir + skeleton->getName()); Ogre::Mesh::SubMeshIterator it(mesh->getSubMeshIterator()); Ogre::MaterialSerializer mat_ser; size_t i(0); while (it.hasMoreElements()) { Ogre::SubMesh *sub_mesh(it.getNext()); Ogre::MaterialPtr mat(Ogre::MaterialManager::getSingleton().getByName(sub_mesh->getMaterialName())); if (!mat.isNull()) { mat_ser.queueForExport(mat); } ++i; } QGears::String base_name; QGears::StringUtil::splitFull(mesh->getName(), base_name); mat_ser.exportQueued(outdir + base_name + QGears::EXT_MATERIAL); } void FF7DataInstaller::ConvertFieldModels(std::string archive, std::string outDir) { //QGears::LZSFLevelFileManager &fmgr(QGears::LZSFLevelFileManager::getSingleton()); // QGears::FLevelFilePtr f = fmgr.load(archive, "FFVII").staticCast(); Ogre::SceneManager* scene_manager(Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "Scene")); QGears::AFilePtr a; Ogre::ResourcePtr hrc = QGears::HRCFileManager::getSingleton().load("adda.hrc", "FFVII"); QGears::HRCFilePtr r = hrc.staticCast(); QGears::AFileManager &afl_mgr(QGears::AFileManager::getSingleton()); auto meshName = QGears::FF7::NameLookup::model("adda.hrc") + ".mesh"; // TODO: Crashes as technique index out of bounds in the material Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(meshName, "FFVII")); Ogre::SkeletonPtr skeleton(mesh->getSkeleton()); exportMesh(outDir, mesh); }