Simple and modern library for parsing the Valve model format.
Documentation: https://taservers.github.io/MDLParser/
See also: https://github.com/TAServers/BSPParser and https://github.com/TAServers/VTFParser.
What's included
- Classes for parsing and abstracting the
MDL
, VVD
and VTX
file formats for the Source engine.
- Helper functions to simplify accessing the disparate but related data in all three files (see below).
- Enums, limits and structs with almost 100% coverage* of the formats.
- Runtime errors for issues when parsing the data due to corruption or a bug in the parser.
*Much of the MDL data is not currently parsed or exposed. These can be used to either implement your own more complex or specialised parser, or to easily extend - and hopefully PR - the MdlParser::Mdl
class.
Example
The following minimal example shows how you can easily and safely traverse the interconnected structure of the three files using the accessor helpers:
#include "MDLParser.hpp"
const auto mdlData = ...;
const auto vtxData = ...;
const auto vvdData = ...;
mdl,
vtx,
mdlBodyPart,
vtxBodyPart,
mdlModel,
vtxLod,
MdlParser::Accessors::iterateVertices(
vvd,
mdlModel,
mdlMesh,
stripGroup,
[&](
const MdlParser::Structs::Vtx::Vertex&,
const MdlParser::Structs::Vvd::Vertex& vvdVertex,
const MdlParser::Structs::Vector4D& tangent
) {
}
);
}
}
);
}
);
}
);
void iterateMeshes(const Mdl::Model &mdlModel, const Vtx::ModelLod &vtxModel, const std::function< void(const Mdl::Mesh &, const Vtx::Mesh &)> &iteratee)
Definition: accessors.cpp:38
void iterateModels(const Mdl::BodyPart &mdlBodyPart, const Vtx::BodyPart &vtxBodyPart, const std::function< void(const Mdl::Model &, const Vtx::Model &)> &iteratee)
Definition: accessors.cpp:30
void iterateBodyParts(const Mdl &mdl, const Vtx &vtx, const std::function< void(const Mdl::BodyPart &, const Vtx::BodyPart &)> &iteratee)
Definition: accessors.cpp:24
std::vector< StripGroup > stripGroups
Definition: vtx.hpp:78
std::vector< ModelLod > levelOfDetails
Definition: vtx.hpp:108