@@ -35,8 +35,7 @@ int main(int argc, char* argv[]) {
35
35
36
36
CLI::App app{
37
37
fmt::sprintf (
38
- " FBX2glTF %s: Generate a glTF 2.0 representation of an FBX model." ,
39
- FBX2GLTF_VERSION),
38
+ " FBX2glTF %s: Generate a glTF 2.0 representation of an FBX model." , FBX2GLTF_VERSION),
40
39
" FBX2glTF" };
41
40
42
41
app.add_flag (
@@ -45,32 +44,22 @@ int main(int argc, char* argv[]) {
45
44
" Include blend shape tangents, if reported present by the FBX SDK." );
46
45
47
46
app.add_flag_function (" -V,--version" , [&](size_t count) {
48
- fmt::printf (
49
- " FBX2glTF version %s\n Copyright (c) 2016-2018 Oculus VR, LLC.\n " ,
50
- FBX2GLTF_VERSION);
47
+ fmt::printf (" FBX2glTF version %s\n Copyright (c) 2016-2018 Oculus VR, LLC.\n " , FBX2GLTF_VERSION);
51
48
exit (0 );
52
49
});
53
50
54
51
std::string inputPath;
55
- app.add_option (" FBX Model" , inputPath, " The FBX model to convert." )
56
- ->check (CLI::ExistingFile);
57
- app.add_option (" -i,--input" , inputPath, " The FBX model to convert." )
58
- ->check (CLI::ExistingFile);
52
+ app.add_option (" FBX Model" , inputPath, " The FBX model to convert." )->check (CLI::ExistingFile);
53
+ app.add_option (" -i,--input" , inputPath, " The FBX model to convert." )->check (CLI::ExistingFile);
59
54
60
55
std::string outputPath;
61
- app.add_option (
62
- " -o,--output" ,
63
- outputPath,
64
- " Where to generate the output, without suffix." );
56
+ app.add_option (" -o,--output" , outputPath, " Where to generate the output, without suffix." );
65
57
66
58
app.add_flag (
67
59
" -e,--embed" ,
68
60
gltfOptions.embedResources ,
69
61
" Inline buffers as data:// URIs within generated non-binary glTF." );
70
- app.add_flag (
71
- " -b,--binary" ,
72
- gltfOptions.outputBinary ,
73
- " Output a single binary format .glb file." );
62
+ app.add_flag (" -b,--binary" , gltfOptions.outputBinary , " Output a single binary format .glb file." );
74
63
75
64
app.add_option (
76
65
" --long-indices" ,
@@ -119,32 +108,28 @@ int main(int argc, char* argv[]) {
119
108
" --flip-u" ,
120
109
[&](size_t count) {
121
110
if (count > 0 ) {
122
- texturesTransforms.emplace_back (
123
- [](Vec2f uv) { return Vec2f (1 .0f - uv[0 ], uv[1 ]); });
111
+ texturesTransforms.emplace_back ([](Vec2f uv) { return Vec2f (1 .0f - uv[0 ], uv[1 ]); });
124
112
if (verboseOutput) {
125
113
fmt::printf (" Flipping texture coordinates in the 'U' dimension.\n " );
126
114
}
127
115
}
128
116
},
129
117
" Flip all U texture coordinates." );
130
118
131
- app.add_flag (" --no-flip-u" , " Don't flip U texture coordinates." )
132
- ->excludes (" --flip-u" );
119
+ app.add_flag (" --no-flip-u" , " Don't flip U texture coordinates." )->excludes (" --flip-u" );
133
120
134
121
app.add_flag_function (
135
122
" --no-flip-v" ,
136
123
[&](size_t count) {
137
124
if (count > 0 ) {
138
- texturesTransforms.emplace_back (
139
- [](Vec2f uv) { return Vec2f (uv[0 ], 1 .0f - uv[1 ]); });
125
+ texturesTransforms.emplace_back ([](Vec2f uv) { return Vec2f (uv[0 ], 1 .0f - uv[1 ]); });
140
126
if (verboseOutput) {
141
127
fmt::printf (" NOT flipping texture coordinates in the 'V' dimension.\n " );
142
128
}
143
129
}
144
130
},
145
131
" Flip all V texture coordinates." );
146
- app.add_flag (" --flip-v" , " Don't flip U texture coordinates." )
147
- ->excludes (" --no-flip-v" );
132
+ app.add_flag (" --flip-v" , " Don't flip U texture coordinates." )->excludes (" --no-flip-v" );
148
133
149
134
app.add_flag (
150
135
" --pbr-metallic-rougnness" ,
@@ -181,8 +166,8 @@ int main(int argc, char* argv[]) {
181
166
app.add_option (
182
167
" -k,--keep-attribute" ,
183
168
[&](std::vector<std::string> attributes) -> bool {
184
- gltfOptions.keepAttribs = RAW_VERTEX_ATTRIBUTE_JOINT_INDICES |
185
- RAW_VERTEX_ATTRIBUTE_JOINT_WEIGHTS;
169
+ gltfOptions.keepAttribs =
170
+ RAW_VERTEX_ATTRIBUTE_JOINT_INDICES | RAW_VERTEX_ATTRIBUTE_JOINT_WEIGHTS;
186
171
for (std::string attribute : attributes) {
187
172
if (attribute == " position" ) {
188
173
gltfOptions.keepAttribs |= RAW_VERTEX_ATTRIBUTE_POSITION;
@@ -212,9 +197,7 @@ int main(int argc, char* argv[]) {
212
197
->type_name (" (position|normal|tangent|binormial|color|uv0|uv1|auto)" );
213
198
214
199
app.add_flag (
215
- " -d,--draco" ,
216
- gltfOptions.draco .enabled ,
217
- " Apply Draco mesh compression to geometries." )
200
+ " -d,--draco" , gltfOptions.draco .enabled , " Apply Draco mesh compression to geometries." )
218
201
->group (" Draco" );
219
202
220
203
app.add_option (
@@ -301,16 +284,12 @@ int main(int argc, char* argv[]) {
301
284
302
285
} else {
303
286
// in gltf mode, we create a folder and write into that
304
- outputFolder = fmt::format (
305
- " {}_out{}" ,
306
- outputPath.c_str (),
307
- (const char )StringUtils::GetPathSeparator ());
308
- modelPath =
309
- outputFolder + StringUtils::GetFileNameString (outputPath) + " .gltf" ;
287
+ outputFolder =
288
+ fmt::format (" {}_out{}" , outputPath.c_str (), (const char )StringUtils::GetPathSeparator ());
289
+ modelPath = outputFolder + StringUtils::GetFileNameString (outputPath) + " .gltf" ;
310
290
}
311
291
if (!FileUtils::CreatePath (modelPath.c_str ())) {
312
- fmt::fprintf (
313
- stderr, " ERROR: Failed to create folder: %s'\n " , outputFolder.c_str ());
292
+ fmt::fprintf (stderr, " ERROR: Failed to create folder: %s'\n " , outputFolder.c_str ());
314
293
return 1 ;
315
294
}
316
295
@@ -334,14 +313,9 @@ int main(int argc, char* argv[]) {
334
313
std::ofstream outStream; // note: auto-flushes in destructor
335
314
const auto streamStart = outStream.tellp ();
336
315
337
- outStream.open (
338
- modelPath,
339
- std::ios::trunc | std::ios::ate | std::ios::out | std::ios::binary);
316
+ outStream.open (modelPath, std::ios::trunc | std::ios::ate | std::ios::out | std::ios::binary);
340
317
if (outStream.fail ()) {
341
- fmt::fprintf (
342
- stderr,
343
- " ERROR:: Couldn't open file for writing: %s\n " ,
344
- modelPath.c_str ());
318
+ fmt::fprintf (stderr, " ERROR:: Couldn't open file for writing: %s\n " , modelPath.c_str ());
345
319
return 1 ;
346
320
}
347
321
data_render_model = Raw2Gltf (outStream, outputFolder, raw, gltfOptions);
@@ -371,8 +345,7 @@ int main(int argc, char* argv[]) {
371
345
const std::string binaryPath = outputFolder + extBufferFilename;
372
346
FILE* fp = fopen (binaryPath.c_str (), " wb" );
373
347
if (fp == nullptr ) {
374
- fmt::fprintf (
375
- stderr, " ERROR:: Couldn't open file '%s' for writing.\n " , binaryPath);
348
+ fmt::fprintf (stderr, " ERROR:: Couldn't open file '%s' for writing.\n " , binaryPath);
376
349
return 1 ;
377
350
}
378
351
@@ -381,16 +354,12 @@ int main(int argc, char* argv[]) {
381
354
unsigned long binarySize = data_render_model->binary ->size ();
382
355
if (fwrite (binaryData, binarySize, 1 , fp) != 1 ) {
383
356
fmt::fprintf (
384
- stderr,
385
- " ERROR: Failed to write %lu bytes to file '%s'.\n " ,
386
- binarySize,
387
- binaryPath);
357
+ stderr, " ERROR: Failed to write %lu bytes to file '%s'.\n " , binarySize, binaryPath);
388
358
fclose (fp);
389
359
return 1 ;
390
360
}
391
361
fclose (fp);
392
- fmt::printf (
393
- " Wrote %lu bytes of binary data to %s.\n " , binarySize, binaryPath);
362
+ fmt::printf (" Wrote %lu bytes of binary data to %s.\n " , binarySize, binaryPath);
394
363
}
395
364
396
365
delete data_render_model;
0 commit comments