/** * @file LVL.h * @date 07/02/2023 * @author JackCarterSmith * @copyright GPL-v3.0 * @brief LVL object class. * * This special handler concatenate all levels resources in one class for easy access. * * Game level is represented by 3 elements : * - HMP: heightmap and tiles textures mappings * - DAT: globals levels informations like name, win conditions, spawns rules, etc. * - GVM: Unknown usage for now * * Others level elements: * - opkg_HOB: level specific models * - ref_TM: Unknown usage for now * */ #include #include #include #include #ifndef LVL_H_ #define LVL_H_ #if defined(_MSC_VER) # define RDI_ABI_EXPORT __declspec(dllexport) # define RDI_ABI_IMPORT __declspec(dllimport) #elif __GNUC__ >= 4 # define RDI_ABI_EXPORT __attribute__ ((visibility("default"))) # define RDI_ABI_IMPORT __attribute__ ((visibility("default"))) #else # define RDI_ABI_EXPORT # define RDI_ABI_IMPORT #endif #if defined(RDI_DLL) # if defined(WIN32) # if defined(RDI_DLLBUILD) # define RDI_EXTERN RDI_ABI_EXPORT # else # define RDI_EXTERN RDI_ABI_IMPORT # endif # endif #endif #ifndef RDI_EXTERN # define RDI_EXTERN #endif namespace RDI { class LVL final : public GenericFile { public: /* struct Vertex { Vertex() noexcept = default; Vertex(float x, float y, float z) noexcept : x(x),y(y),z(z) {} Vertex(std::array vArray) noexcept : x(vArray[0]),y(vArray[1]),z(vArray[2]) {} Vertex(const Vertex&) = default; Vertex& operator=(const Vertex&) = default; Vertex(Vertex&&) = default; Vertex& operator=(Vertex&&) = default; float x = 0.0f, y = 0.0f, z = 0.0f; }; */ struct Mesh { std::vector*> vertices; //std::vector indices; //TODO: Replaced by 32bits integer until indices optimization std::vector indices; }; /* -------------------------------------------------------------------------- */ LVL( DatFile::DatFileEntryFile* hDat, DatFile::DatFileEntryFile* hHmp, DatFile::DatFileEntryFile* hGvm ); ~LVL(); LVL(const LVL&) = default; LVL& operator=(const LVL&) = default; LVL(LVL&&) = default; LVL& operator=(LVL&&) = default; // Mandatory function from base class RDI_EXTERN void Load(); RDI_EXTERN void Dispose(); // Specific handler methods override for level instance std::string getFileName() const { return levelName; } std::string getFullPath() const { return fullLevelDirPath; } /* -------------------------------------------------------------------------- */ RDI_EXTERN LVL::Mesh* getLevelMesh() const { if (!this->isLoaded()) throw std::runtime_error("LVL handler has not been loaded prior to function calling."); return mapMesh; } //std::vector getLevelTextures(); //ObjectTexture* getLevelTileTexture( const unsigned short x, const unsigned short y ); private: std::string levelName, fullLevelDirPath; unsigned long hmpFileSize, gvmFileSize; MEMFILE pHmpMemLoc = nullptr; MEMFILE pGvmMemLoc = nullptr; void* hmpInstance = nullptr; // RSPTerrain mesh instance void* txtInstance = nullptr; // RSPTexture instance LVL::Mesh* mapMesh = nullptr; }; } #endif /* LVL_H_ */