whiteoutlib 0.1.4

Read and write Blizzard game assets from Rust: models (MDX, M2, M3), textures (BLP, DDS, PNG, JPEG, BMP, TGA, TIFF, GIF) and archives (CASC, MPQ).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026 Fernando Sahmkow

#include "whiteout/models/mdx/parser.h"
#include "whiteout/models/mdx/writer.h"
#include "whiteout/models/wem/converters.h"

#include <algorithm>
#include <cmath>

namespace whiteout {
namespace models {
namespace wem {

// ============================================================================
// Helpers
// ============================================================================

namespace {

wem::Extent convertExtent(const mdx::Extent& src) {
    wem::Extent dst;
    dst.minimum = src.minimum;
    dst.maximum = src.maximum;
    dst.sphereRadius = src.boundsRadius;
    return dst;
}

mdx::Extent convertExtentBack(const wem::Extent& src) {
    mdx::Extent dst;
    dst.minimum = src.minimum;
    dst.maximum = src.maximum;
    dst.boundsRadius = src.sphereRadius;
    return dst;
}

BlendMode convertFilterMode(mdx::Layer::FilterMode fm) {
    switch (fm) {
    case mdx::Layer::FilterMode::None:
        return BlendMode::Opaque;
    case mdx::Layer::FilterMode::Transparent:
        return BlendMode::Transparent;
    case mdx::Layer::FilterMode::Blend:
        return BlendMode::AlphaBlend;
    case mdx::Layer::FilterMode::Additive:
        return BlendMode::Additive;
    case mdx::Layer::FilterMode::AddAlpha:
        return BlendMode::AdditiveAlpha;
    case mdx::Layer::FilterMode::Modulate:
        return BlendMode::Modulate;
    case mdx::Layer::FilterMode::Modulate2x:
        return BlendMode::Modulate2x;
    default:
        return BlendMode::Opaque;
    }
}

mdx::Layer::FilterMode convertBlendModeToFilterMode(BlendMode bm) {
    switch (bm) {
    case BlendMode::Opaque:
        return mdx::Layer::FilterMode::None;
    case BlendMode::Transparent:
        return mdx::Layer::FilterMode::Transparent;
    case BlendMode::AlphaBlend:
        return mdx::Layer::FilterMode::Blend;
    case BlendMode::Additive:
        return mdx::Layer::FilterMode::Additive;
    case BlendMode::AdditiveAlpha:
        return mdx::Layer::FilterMode::AddAlpha;
    case BlendMode::Modulate:
        return mdx::Layer::FilterMode::Modulate;
    case BlendMode::Modulate2x:
        return mdx::Layer::FilterMode::Modulate2x;
    default:
        return mdx::Layer::FilterMode::None;
    }
}

MaterialFlags convertShadingFlags(mdx::Layer::ShadingFlag sf) {
    auto flags = MaterialFlags::None;
    auto sfval = static_cast<u32>(sf);
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::Unshaded))
        flags |= MaterialFlags::Unlit;
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::SphereEnvMap))
        flags |= MaterialFlags::SphereEnvMap;
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::TwoSided))
        flags |= MaterialFlags::TwoSided;
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::Unfogged))
        flags |= MaterialFlags::Unfogged;
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::NoDepthTest))
        flags |= MaterialFlags::NoDepthTest;
    if (sfval & static_cast<u32>(mdx::Layer::ShadingFlag::NoDepthSet))
        flags |= MaterialFlags::NoDepthWrite;
    return flags;
}

mdx::Layer::ShadingFlag convertMaterialFlagsToShading(MaterialFlags mf) {
    auto result = mdx::Layer::ShadingFlag::None;
    if (hasFlag(mf, MaterialFlags::Unlit))
        result = result | mdx::Layer::ShadingFlag::Unshaded;
    if (hasFlag(mf, MaterialFlags::SphereEnvMap))
        result = result | mdx::Layer::ShadingFlag::SphereEnvMap;
    if (hasFlag(mf, MaterialFlags::TwoSided))
        result = result | mdx::Layer::ShadingFlag::TwoSided;
    if (hasFlag(mf, MaterialFlags::Unfogged))
        result = result | mdx::Layer::ShadingFlag::Unfogged;
    if (hasFlag(mf, MaterialFlags::NoDepthTest))
        result = result | mdx::Layer::ShadingFlag::NoDepthTest;
    if (hasFlag(mf, MaterialFlags::NoDepthWrite))
        result = result | mdx::Layer::ShadingFlag::NoDepthSet;
    return result;
}

FresnelProperties convertLayerFresnel(const mdx::Layer& layer) {
    FresnelProperties fp;
    fp.color = layer.fresnelColor;
    fp.opacity = layer.fresnelOpacity;
    fp.teamColor = layer.fresnelTeamColor;
    return fp;
}

} // anonymous namespace

// ============================================================================
// fromMdx
// ============================================================================

ConvertResult MdxConverter::fromMdx(const mdx::Model& mdxModel) const {
    ConvertResult result;
    auto& model = result.model;
    auto& issues = result.issues;

    model.name = mdxModel.modelName;
    model.bounds = convertExtent(mdxModel.modelExtent);

    // ── Textures ───────────────────────────────────────────────────
    model.textures.reserve(mdxModel.textures.size());
    for (const auto& tex : mdxModel.textures) {
        TextureRef ref;
        ref.path = tex.fileName;
        ref.flags = static_cast<u32>(tex.flags);
        ref.replaceableId = tex.replaceableId;
        model.textures.push_back(std::move(ref));
    }

    // ── Materials ──────────────────────────────────────────────────
    // MDX materials have 1+ layers. Single-layer → Standard, multi-layer → Composite.
    model.materials.reserve(mdxModel.materials.size());
    for (const auto& mat : mdxModel.materials) {
        if (mat.layers.size() == 1) {
            // Single layer → Standard material
            const auto& layer = mat.layers[0];
            Material wMat;
            wMat.type = MaterialType::Standard;
            wMat.priorityPlane = static_cast<i32>(mat.priorityPlane);
            wMat.blendMode = convertFilterMode(layer.filterMode);
            wMat.flags = convertShadingFlags(layer.shadingFlags);
            wMat.shader = mat.shader;
            wMat.emissiveGain = layer.emissiveGain;
            wMat.fresnel = convertLayerFresnel(layer);

            // Primary texture slot
            if (layer.is_hd && !layer.subTextures.empty()) {
                // Reforged HD: subTextures define named slots
                for (const auto& sub : layer.subTextures) {
                    TextureSlot slot;
                    slot.textureIndex = sub.textureId;
                    slot.uvSetIndex = layer.coordId;
                    slot.alpha = layer.alpha;
                    switch (sub.slot) {
                    case mdx::Layer::SlotType::DiffuseMap:
                        slot.semantic = TextureSlotSemantic::Diffuse;
                        break;
                    case mdx::Layer::SlotType::NormalMap:
                        slot.semantic = TextureSlotSemantic::Normal;
                        break;
                    case mdx::Layer::SlotType::ORMMap:
                        slot.semantic = TextureSlotSemantic::AmbientOcclusion;
                        break;
                    case mdx::Layer::SlotType::EmissiveMap:
                        slot.semantic = TextureSlotSemantic::Emissive1;
                        break;
                    case mdx::Layer::SlotType::TeamColor:
                        slot.semantic = TextureSlotSemantic::Custom;
                        break;
                    case mdx::Layer::SlotType::EnvironmentMap:
                        slot.semantic = TextureSlotSemantic::Environment;
                        break;
                    default:
                        slot.semantic = TextureSlotSemantic::Custom;
                        break;
                    }
                    wMat.textureSlots.push_back(std::move(slot));
                }
            } else {
                // Classic: single texture per layer
                TextureSlot slot;
                slot.textureIndex = layer.textureId;
                slot.uvSetIndex = layer.coordId;
                slot.alpha = layer.alpha;
                slot.semantic = TextureSlotSemantic::Diffuse;
                wMat.textureSlots.push_back(std::move(slot));
            }

            model.materials.push_back(std::move(wMat));
        } else {
            // Multi-layer → Composite material wrapping per-layer Standards
            // First, create one Standard per layer
            [[maybe_unused]] u32 const baseIdx = static_cast<u32>(model.materials.size());
            std::vector<CompositeSection> sections;
            sections.reserve(mat.layers.size());

            for (const auto& layer : mat.layers) {
                Material layerMat;
                layerMat.type = MaterialType::Standard;
                layerMat.priorityPlane = static_cast<i32>(mat.priorityPlane);
                layerMat.blendMode = convertFilterMode(layer.filterMode);
                layerMat.flags = convertShadingFlags(layer.shadingFlags);
                layerMat.shader = mat.shader;
                layerMat.emissiveGain = layer.emissiveGain;
                layerMat.fresnel = convertLayerFresnel(layer);

                TextureSlot slot;
                slot.textureIndex = layer.textureId;
                slot.uvSetIndex = layer.coordId;
                slot.alpha = layer.alpha;
                slot.semantic = TextureSlotSemantic::Diffuse;
                layerMat.textureSlots.push_back(std::move(slot));

                CompositeSection section;
                section.materialIndex = static_cast<u32>(model.materials.size());
                section.blendWeight = 1.0f;
                section.blendMode = convertFilterMode(layer.filterMode);
                sections.push_back(section);

                model.materials.push_back(std::move(layerMat));
            }

            // Then the Composite that references them
            Material compMat;
            compMat.type = MaterialType::Composite;
            compMat.priorityPlane = static_cast<i32>(mat.priorityPlane);
            compMat.sections = std::move(sections);
            model.materials.push_back(std::move(compMat));
        }
    }

    // ── Geosets → Meshes ───────────────────────────────────────────
    model.meshes.reserve(mdxModel.geosets.size());
    for (size_t gi = 0; gi < mdxModel.geosets.size(); ++gi) {
        const auto& geo = mdxModel.geosets[gi];
        Mesh mesh;
        mesh.name = geo.lodName.empty() ? "geoset_" + std::to_string(gi) : geo.lodName;
        mesh.lodLevel = geo.lod;
        mesh.bounds = convertExtent(geo.extent);

        // Vertex data
        mesh.positions = geo.vertexPositions;
        mesh.normals = geo.vertexNormals;
        mesh.tangents = geo.tangents;

        // UV sets
        mesh.uvSets.reserve(geo.textureCoordinateSets.size());
        for (const auto& uvSet : geo.textureCoordinateSets) {
            mesh.uvSets.push_back(uvSet);
        }

        // Indices: u16 → u32
        mesh.indices.reserve(geo.faces.size());
        for (u16 idx : geo.faces) {
            mesh.indices.push_back(static_cast<u32>(idx));
        }

        // Skinning data: MDX stores as packed u8 array (4 bone indices + 4 bone weights per vertex)
        if (!geo.skinData.empty()) {
            size_t const vertCount = geo.vertexPositions.size();
            mesh.boneIndices.resize(vertCount);
            mesh.boneWeights.resize(vertCount);
            for (size_t v = 0; v < vertCount && (v * 8 + 7) < geo.skinData.size(); ++v) {
                size_t const offset = v * 8;
                mesh.boneIndices[v] = {geo.skinData[offset + 0], geo.skinData[offset + 1],
                                       geo.skinData[offset + 2], geo.skinData[offset + 3]};
                mesh.boneWeights[v] = {geo.skinData[offset + 4], geo.skinData[offset + 5],
                                       geo.skinData[offset + 6], geo.skinData[offset + 7]};
            }
        }

        // Single submesh per geoset (the whole geoset is one draw section)
        Submesh sub;
        sub.name = mesh.name;
        sub.indexStart = 0;
        sub.indexCount = static_cast<u32>(mesh.indices.size());
        sub.vertexStart = 0;
        sub.vertexCount = static_cast<u32>(mesh.positions.size());
        sub.selectionGroup = static_cast<u16>(geo.selectionGroup);
        sub.selectionFlags = static_cast<u16>(geo.selectionFlags);
        sub.bounds = mesh.bounds;

        // Resolve material index: MDX materialId indexes into mdxModel.materials[].
        // For single-layer materials this maps 1:1. For multi-layer materials,
        // the composite was appended after its per-layer standards.
        // We need to map this correctly.
        u32 const mdxMatIdx = geo.materialId;
        if (mdxMatIdx < mdxModel.materials.size()) {
            // Walk through materials to find the correct WEM index
            u32 wemIdx = 0;
            for (u32 mi = 0; mi < mdxMatIdx; ++mi) {
                size_t const layerCount = mdxModel.materials[mi].layers.size();
                if (layerCount <= 1) {
                    wemIdx += 1;
                } else {
                    wemIdx += static_cast<u32>(layerCount) + 1; // N standards + 1 composite
                }
            }
            // Point to the actual material for this geoset
            size_t const layerCount = mdxModel.materials[mdxMatIdx].layers.size();
            if (layerCount <= 1) {
                sub.materialIndex = wemIdx;
            } else {
                // Use the composite (last one in the group)
                sub.materialIndex = wemIdx + static_cast<u32>(layerCount);
            }
        } else {
            sub.materialIndex = 0;
            issues.push_back("Geoset " + std::to_string(gi) + " has out-of-range materialId " +
                             std::to_string(mdxMatIdx));
        }

        mesh.submeshes.push_back(std::move(sub));
        model.meshes.push_back(std::move(mesh));
    }

    return result;
}

// ============================================================================
// toMdx
// ============================================================================

MdxConvertResult MdxConverter::toMdx(const Model& wemModel, u32 targetVersion) const {
    MdxConvertResult result;
    auto& mdx = result.model;
    auto& issues = result.issues;

    mdx.version = targetVersion;
    mdx.modelName = wemModel.name;
    mdx.modelExtent = convertExtentBack(wemModel.bounds);

    // ── Textures ───────────────────────────────────────────────────
    mdx.textures.reserve(wemModel.textures.size());
    for (const auto& ref : wemModel.textures) {
        mdx::Texture tex;
        tex.fileName = ref.path;
        tex.flags = static_cast<mdx::Texture::Flag>(ref.flags);
        tex.replaceableId = ref.replaceableId;
        mdx.textures.push_back(std::move(tex));
    }

    // ── Materials ──────────────────────────────────────────────────
    // Build a mapping from WEM material index → MDX material index
    // Standard → single-layer MDX material
    // Composite → multi-layer MDX material (layers from referenced standards)
    for (size_t mi = 0; mi < wemModel.materials.size(); ++mi) {
        const auto& wMat = wemModel.materials[mi];

        if (wMat.type == MaterialType::Composite) {
            mdx::Material mat;
            mat.priorityPlane = static_cast<u32>(wMat.priorityPlane);
            mat.shader = wMat.shader;

            for (const auto& section : wMat.sections) {
                mdx::Layer layer;
                layer.filterMode = convertBlendModeToFilterMode(section.blendMode);

                // Pull data from the referenced standard material
                if (section.materialIndex < wemModel.materials.size()) {
                    const auto& srcMat = wemModel.materials[section.materialIndex];
                    layer.shadingFlags = convertMaterialFlagsToShading(srcMat.flags);
                    layer.emissiveGain = srcMat.emissiveGain;
                    layer.fresnelColor = srcMat.fresnel.color;
                    layer.fresnelOpacity = srcMat.fresnel.opacity;
                    layer.fresnelTeamColor = srcMat.fresnel.teamColor;
                    if (!srcMat.textureSlots.empty()) {
                        layer.textureId = srcMat.textureSlots[0].textureIndex;
                        layer.coordId = srcMat.textureSlots[0].uvSetIndex;
                        layer.alpha = srcMat.textureSlots[0].alpha;
                    }
                }

                mat.layers.push_back(std::move(layer));
            }

            mdx.materials.push_back(std::move(mat));
        } else if (wMat.type == MaterialType::Standard) {
            // Check if this standard is referenced by a composite;
            // if so, skip it (it was folded into the composite's layers above)
            bool isChild = false;
            for (const auto& other : wemModel.materials) {
                if (other.type == MaterialType::Composite) {
                    for (const auto& sec : other.sections) {
                        if (sec.materialIndex == mi) {
                            isChild = true;
                            break;
                        }
                    }
                }
                if (isChild)
                    break;
            }
            if (isChild)
                continue;

            // Standalone Standard → single-layer MDX material
            mdx::Material mat;
            mat.priorityPlane = static_cast<u32>(wMat.priorityPlane);
            mat.shader = wMat.shader;

            mdx::Layer layer;
            layer.filterMode = convertBlendModeToFilterMode(wMat.blendMode);
            layer.shadingFlags = convertMaterialFlagsToShading(wMat.flags);
            layer.emissiveGain = wMat.emissiveGain;
            layer.fresnelColor = wMat.fresnel.color;
            layer.fresnelOpacity = wMat.fresnel.opacity;
            layer.fresnelTeamColor = wMat.fresnel.teamColor;
            if (!wMat.textureSlots.empty()) {
                layer.textureId = wMat.textureSlots[0].textureIndex;
                layer.coordId = wMat.textureSlots[0].uvSetIndex;
                layer.alpha = wMat.textureSlots[0].alpha;
            }

            mat.layers.push_back(std::move(layer));
            mdx.materials.push_back(std::move(mat));
        }
    }

    // Build a reverse map: WEM material idx → MDX material idx for geoset assignment
    std::vector<u32> wemToMdxMat(wemModel.materials.size(), 0);
    {
        u32 mdxIdx = 0;
        for (size_t mi = 0; mi < wemModel.materials.size(); ++mi) {
            const auto& wMat = wemModel.materials[mi];
            if (wMat.type == MaterialType::Composite) {
                wemToMdxMat[mi] = mdxIdx;
                mdxIdx++;
            } else if (wMat.type == MaterialType::Standard) {
                bool isChild = false;
                for (const auto& other : wemModel.materials) {
                    if (other.type == MaterialType::Composite) {
                        for (const auto& sec : other.sections) {
                            if (sec.materialIndex == mi) {
                                isChild = true;
                                break;
                            }
                        }
                    }
                    if (isChild)
                        break;
                }
                if (!isChild) {
                    wemToMdxMat[mi] = mdxIdx;
                    mdxIdx++;
                }
            }
        }
    }

    // ── Meshes → Geosets ───────────────────────────────────────────
    mdx.geosets.reserve(wemModel.meshes.size());
    for (size_t mi = 0; mi < wemModel.meshes.size(); ++mi) {
        const auto& mesh = wemModel.meshes[mi];
        mdx::Geoset geo;
        geo.lodName = mesh.name;
        geo.lod = mesh.lodLevel;
        geo.extent = convertExtentBack(mesh.bounds);
        geo.vertexPositions = mesh.positions;
        geo.vertexNormals = mesh.normals;
        geo.tangents = mesh.tangents;
        geo.textureCoordinateSets = mesh.uvSets;

        // Indices: u32 → u16 (MDX limit)
        geo.faces.reserve(mesh.indices.size());
        for (u32 idx : mesh.indices) {
            if (idx > 0xFFFF) {
                issues.push_back("Mesh " + std::to_string(mi) + " has index > 65535, clamped");
                geo.faces.push_back(0xFFFF);
            } else {
                geo.faces.push_back(static_cast<u16>(idx));
            }
        }

        // Skinning data: pack bone indices + weights into u8 array
        if (!mesh.boneIndices.empty() && !mesh.boneWeights.empty()) {
            size_t const vertCount = mesh.positions.size();
            geo.skinData.resize(vertCount * 8);
            for (size_t v = 0; v < vertCount; ++v) {
                size_t const offset = v * 8;
                const auto& bi = mesh.boneIndices[v];
                const auto& bw = mesh.boneWeights[v];
                geo.skinData[offset + 0] = bi[0];
                geo.skinData[offset + 1] = bi[1];
                geo.skinData[offset + 2] = bi[2];
                geo.skinData[offset + 3] = bi[3];
                geo.skinData[offset + 4] = bw[0];
                geo.skinData[offset + 5] = bw[1];
                geo.skinData[offset + 6] = bw[2];
                geo.skinData[offset + 7] = bw[3];
            }
        }

        // Use first submesh's material
        if (!mesh.submeshes.empty()) {
            const auto& sub = mesh.submeshes[0];
            geo.materialId = wemToMdxMat[sub.materialIndex];
            geo.selectionGroup = sub.selectionGroup;
            geo.selectionFlags = sub.selectionFlags;
        }

        mdx.geosets.push_back(std::move(geo));
    }

    return result;
}

// ============================================================================
// MdxConverter — FormatConverter interface
// ============================================================================

std::string MdxConverter::formatId() const {
    return "mdx";
}
std::string MdxConverter::formatName() const {
    return "Warcraft III MDX";
}
bool MdxConverter::supportsImport() const {
    return true;
}
bool MdxConverter::supportsExport() const {
    return true;
}
u32 MdxConverter::defaultExportVersion() const {
    return 800;
}

ConvertResult MdxConverter::importFromBytes(std::span<const u8> data) const {
    mdx::Parser parser;
    auto mdxModel = parser.parse(data);
    auto result = fromMdx(mdxModel);
    for (const auto& issue : parser.getIssues()) {
        result.issues.push_back(issue);
    }
    return result;
}

ExportResult MdxConverter::exportToBytes(const Model& model, u32 version) const {
    auto mdxResult = toMdx(model, version == 0 ? defaultExportVersion() : version);
    ExportResult result;
    result.issues = std::move(mdxResult.issues);
    mdx::Writer writer;
    result.data = writer.write(mdxResult.model);
    return result;
}

// ============================================================================
// Legacy free functions
// ============================================================================

ConvertResult fromMdx(const mdx::Model& mdxModel) {
    static const MdxConverter converter;
    return converter.fromMdx(mdxModel);
}

MdxConvertResult toMdx(const Model& wemModel, u32 targetVersion) {
    static const MdxConverter converter;
    return converter.toMdx(wemModel, targetVersion);
}

} // namespace wem
} // namespace models
} // namespace whiteout