Repository navigation
Expand file tree
/
Copy pathm3_writer_example.cpp
More file actions
50 lines (38 loc) · 1.53 KB
/
Copy pathm3_writer_example.cpp
File metadata and controls
50 lines (38 loc) · 1.53 KB
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
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026 Fernando Sahmkow
/// M3 writer example: reads an M3 file and writes it back.
#include <whiteout/models/m3/m3.h>
#include <iostream>
#include <fstream>
int main(int argc, char* argv[]) {
if (argc < 3) {
std::cout << "Usage: " << argv[0] << " <input_m3> <output_m3>" << std::endl;
std::cout << "\nExample: " << argv[0] << " model.m3 model_copy.m3" << std::endl;
return 1;
}
std::string inputPath = argv[1];
std::string outputPath = argv[2];
std::cout << "Loading input M3 file: " << inputPath << std::endl;
whiteout::m3::Parser parser;
whiteout::m3::Model model = parser.parse(inputPath);
const auto& issues = parser.getIssues();
if (!issues.empty()) {
std::cout << "Parsing warnings:" << std::endl;
for (const auto& issue : issues) {
std::cout << " - " << issue << std::endl;
}
}
std::cout << " Bones: " << model.bones.size() << std::endl;
std::cout << " Sequences: " << model.sequences.size() << std::endl;
std::cout << "\nWriting output M3 file: " << outputPath << std::endl;
whiteout::m3::Writer writer;
writer.write(outputPath, model);
std::cout << "\nModel written successfully!" << std::endl;
std::ifstream outFile(outputPath, std::ios::binary);
if (outFile.good()) {
outFile.seekg(0, std::ios::end);
size_t fileSize = outFile.tellg();
std::cout << "Output file size: " << fileSize << " bytes" << std::endl;
}
return 0;
}