MDLParser
Simple and modern library for parsing the Source engine model formats
|
#include <mdl.hpp>
Classes | |
struct | BodyPart |
struct | Bone |
struct | Mesh |
struct | Model |
struct | Texture |
Public Member Functions | |
Mdl (const std::weak_ptr< std::vector< std::byte > > &data, const std::optional< int32_t > &checksum=std::nullopt) | |
int32_t | getChecksum () const |
const std::vector< BodyPart > & | getBodyParts () const |
const std::vector< std::string > & | getTextureDirectories () const |
const std::vector< Texture > & | getTextures () const |
const std::vector< std::vector< int16_t > > & | getSkinLookupTable () const |
const std::vector< Bone > & | getBones () const |
Parses a .mdl file from a buffer into an easier to traverse structure using STL containers.
|
explicit |
Parses a .mdl file contained in the given buffer into an easier to use and more modern structure. No ownership of the data is taken as all contents are copied into new structs.
data | |
checksum | Optional checksum to validate against the header's |
const std::vector< Mdl::BodyPart > & MdlParser::Mdl::getBodyParts | ( | ) | const |
Gets the list of body parts (body groups) that make up the model.
const std::vector< Mdl::Bone > & MdlParser::Mdl::getBones | ( | ) | const |
Gets the list of bones in the model.
int32_t MdlParser::Mdl::getChecksum | ( | ) | const |
Gets the checksum shared by the MDL, VTX and VVD from the header.
const std::vector< std::vector< int16_t > > & MdlParser::Mdl::getSkinLookupTable | ( | ) | const |
Gets the skin lookup table as a row-major 2-dimensional array. To map from a material index to a texture index for a given skin, simply do:
const std::vector< std::string > & MdlParser::Mdl::getTextureDirectories | ( | ) | const |
Gets the list of directories (relative to /materials) which contain the textures used by the model. As each texture only includes its filename, you must search through this list of directories to find the actual path to the image asset.
const std::vector< Mdl::Texture > & MdlParser::Mdl::getTextures | ( | ) | const |
Gets the list of textures used by this model. As each texture only stores its filename, you must use getTextureDirectories() to determine the actual path.