HOB file handler prototype Mesh building should be moved to RSPModel lib Tree rendering unicode chars fix Updated version detection HOB file handler Debug HOB handler Pointer probably deallocated, need to check it Fix HOB loader and disposer Using HOB instance instead of static methods Review DLL support for MSVC build Vertices values calculation fix Added export obj method to debug tool Missed levels name separation Cleaned model processing Multithreading branch reported to later
121 lines
3.0 KiB
C++
121 lines
3.0 KiB
C++
/**
|
|
* @file HOB.h
|
|
* @date 31/01/2023
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief HOB file object class.
|
|
*
|
|
* Rogue data files use a specific (and size optimized) storage method of model.
|
|
* HOB handler parse these datas and store them in a more GPU-frienly BOOST-Lib
|
|
* type.
|
|
*
|
|
*/
|
|
|
|
#include <array>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <boost/qvm_lite.hpp>
|
|
#include <FileHandler/Generic.h>
|
|
|
|
|
|
#ifndef HOB_H_
|
|
#define HOB_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 HOB 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<float, 3> 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 {
|
|
// Empty vertices mesh should be considered as root/main mesh struct.
|
|
std::vector<boost::qvm::vec<float, 3>*> vertices;
|
|
std::vector<uint16_t> indices;
|
|
|
|
// Transform matrix not used for now, equal to identity matrix.
|
|
boost::qvm::mat<float,4,4> transform;
|
|
//Material material;
|
|
|
|
// Submesh are divided by material/texture
|
|
std::vector<HOB::Mesh*> subMeshs;
|
|
};
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
HOB( DatFile::DatFileEntryFile* hDat );
|
|
~HOB();
|
|
|
|
HOB(const HOB&) = default;
|
|
HOB& operator=(const HOB&) = default;
|
|
|
|
HOB(HOB&&) = default;
|
|
HOB& operator=(HOB&&) = default;
|
|
|
|
// Mandatory function from base class
|
|
RDI_EXTERN void Load();
|
|
RDI_EXTERN void Dispose();
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
RDI_EXTERN unsigned int getObjectCount() const;
|
|
RDI_EXTERN std::string* getObjectName( unsigned short index ) const;
|
|
|
|
RDI_EXTERN HOB::Mesh* getMeshFromObject( unsigned short index ) const;
|
|
RDI_EXTERN HOB::Mesh* getMeshFromObject( std::string name ) const;
|
|
|
|
//ObjectMaterials getMaterialFromObject( unsigned short index, unsigned short materialIndex );
|
|
//ObjectMaterials getMaterialFromObject( std::string name, unsigned short materialIndex );
|
|
//std::vector<ObjectMaterials> getMaterialsFromObject( unsigned short index );
|
|
//std::vector<ObjectMaterials> getMaterialsFromObject( std::string name );
|
|
|
|
|
|
private:
|
|
void* hobInstance = nullptr;
|
|
unsigned int objCnt = 0;
|
|
std::unordered_map<std::string, HOB::Mesh*> objectMeshList; // Each object mesh ordered by index
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* HOB_H_ */
|