11 const std::byte* vtxData, std::size_t vtxSize,
12 const std::byte* vvdData, std::size_t vvdSize) {
13 if (this->opened || !mdlData || !vtxData || !vvdData || !mdlSize || !vtxSize || !vvdSize) {
16 this->opened = this->
mdl.
open(mdlData, mdlSize) && this->
vtx.
open(vtxData, vtxSize, this->
mdl) && this->
vvd.
open(vvdData, vvdSize, this->
mdl);
21 const unsigned char* vtxData, std::size_t vtxSize,
22 const unsigned char* vvdData, std::size_t vvdSize) {
23 return this->
open(
reinterpret_cast<const std::byte*
>(mdlData), mdlSize,
24 reinterpret_cast<const std::byte*
>(vtxData), vtxSize,
25 reinterpret_cast<const std::byte*
>(vvdData), vvdSize);
29 const std::vector<std::byte>& vtxData,
30 const std::vector<std::byte>& vvdData) {
31 return this->
open(mdlData.data(), mdlData.size(),
32 vtxData.data(), vtxData.size(),
33 vvdData.data(), vvdData.size());
37 const std::vector<unsigned char>& vtxData,
38 const std::vector<unsigned char>& vvdData) {
39 return this->
open(mdlData.data(), mdlData.size(),
40 vtxData.data(), vtxData.size(),
41 vvdData.data(), vvdData.size());
55 for (
const auto& [LOD, sourceVertexID, vertexCount] : this->
vvd.
fixups) {
56 if (LOD < currentLOD) {
59 std::span fixupVertices{this->
vvd.
vertices.begin() + sourceVertexID,
static_cast<std::span<const VVD::Vertex>::size_type
>(vertexCount)};
60 std::ranges::copy(fixupVertices, std::back_inserter(model.
vertices));
64 for (
int bodyPartIndex = 0; bodyPartIndex < this->
mdl.
bodyParts.size(); bodyPartIndex++) {
65 auto& mdlBodyPart = this->
mdl.
bodyParts.at(bodyPartIndex);
66 const auto& [vtxModels] = this->
vtx.
bodyParts.at(bodyPartIndex);
68 for (
int modelIndex = 0; modelIndex < mdlBodyPart.models.size(); modelIndex++) {
69 auto& mdlModel = mdlBodyPart.models.at(modelIndex);
70 const auto& [vtxModelLODs] = vtxModels.at(modelIndex);
72 if (mdlModel.verticesCount == 0) {
76 for (
int meshIndex = 0; meshIndex < mdlModel.meshes.size(); meshIndex++) {
77 auto& mdlMesh = mdlModel.meshes.at(meshIndex);
78 const auto& [vtxStripGroups, vtxMeshFlags] = vtxModelLODs.at(currentLOD).meshes.at(meshIndex);
80 std::vector<uint16_t> indices;
81 for (
const auto& stripGroup : vtxStripGroups) {
82 for (
const auto& strip : stripGroup.strips) {
83 const auto addIndex = [&indices, mdlMesh, mdlModel, stripGroup](
int index) {
84 indices.push_back(stripGroup.vertices.at(index).meshVertexID + mdlMesh.verticesOffset + mdlModel.verticesOffset);
89 for (
int i = 0; i < strip.indices.size(); i += 3) {
90 addIndex(strip.indices[i+0]);
91 addIndex(strip.indices[i+2]);
92 addIndex(strip.indices[i+1]);
95 for (
int i = 0; i < strip.indices.size() - 2; i++) {
97 addIndex(strip.indices[i+0]);
98 addIndex(strip.indices[i+2]);
99 addIndex(strip.indices[i+1]);
101 addIndex(strip.indices[i+1]);
102 addIndex(strip.indices[i+2]);
103 addIndex(strip.indices[i+0]);
111 .indices = std::move(indices),
112 .materialIndex = mdlMesh.material,
bool open(const std::byte *mdlData, std::size_t mdlSize, const std::byte *vtxData, std::size_t vtxSize, const std::byte *vvdData, std::size_t vvdSize)