|
97 | 97 | #include <unistd.h> |
98 | 98 | #endif |
99 | 99 |
|
| 100 | +//#define VDB_TOOL_USE_IMG_TO_MPEG |
| 101 | + |
| 102 | +#ifdef VDB_TOOL_USE_IMG_TO_MPEG |
| 103 | +#include <cstdlib> |
| 104 | +#endif |
| 105 | + |
100 | 106 | namespace openvdb { |
101 | 107 | OPENVDB_USE_VERSION_NAMESPACE |
102 | 108 | namespace OPENVDB_VERSION_NAME { |
@@ -206,6 +212,21 @@ class Tool |
206 | 212 | /// @brief Converts all quads into triangles |
207 | 213 | void quadsToTriangles(); |
208 | 214 |
|
| 215 | + #ifdef VDB_TOOL_USE_IMG_TO_MPEG |
| 216 | + /// @brief Convert multiple image files to a mpeg movie file |
| 217 | + void imgToMpeg() { |
| 218 | + std::string cmd("ffmpeg -loglevel error -framerate 30 -i slice_%03d.ppm dragon_30fps_v2.mp4"), logFile("log.txt"); |
| 219 | + cmd += " > " + logFile + " 2>&1"; |
| 220 | + const int code = std::system(cmd.c_str()); |
| 221 | + if (code != 0) { |
| 222 | + std::stringstream ss; |
| 223 | + ss << "\nFatal error in Tool::imgToMpeg: " << code << "\n\"" << cmd << "\"\n" << std::ifstream(logFile).rdbuf(); |
| 224 | + throw std::runtime_error(ss.str()); |
| 225 | + } |
| 226 | + std::system(("rm " + logFile).c_str()); |
| 227 | + } |
| 228 | + #endif |
| 229 | + |
209 | 230 | /// @brief construct a LoD sequences of VDB trees with powers of two refinements |
210 | 231 | void multires(); |
211 | 232 |
|
@@ -441,6 +462,14 @@ void Tool::init() |
441 | 462 | {"keep", "", "1|0|true|false", "toggle wether the input geometry is preserved or deleted after the conversion"}}, |
442 | 463 | [&](){mParser.setDefaults();}, [&](){this->quadsToTriangles();}); |
443 | 464 |
|
| 465 | + #ifdef VDB_TOOL_USE_IMG_TO_MPEG |
| 466 | + mParser.addAction( |
| 467 | + {"img2mpeg"}, "Convert all quads in mesh to triangles, assuming they are both planar and convex", |
| 468 | + {{"geo", "0", "0", "age (i.e. stack index) of the geometry to be processed. Defaults to 0, i.e. most recently inserted geometry."}, |
| 469 | + {"keep", "", "1|0|true|false", "toggle wether the input geometry is preserved or deleted after the conversion"}}, |
| 470 | + [&](){mParser.setDefaults();}, [&](){this->imgToMpeg();}); |
| 471 | +#endif |
| 472 | + |
444 | 473 | mParser.addAction( |
445 | 474 | {"mesh2ls", "mesh2sdf"}, "Convert a watertight polygon surface into a narrow-band level set, i.e. a narrow-band signed distance to a polygon mesh", |
446 | 475 | {{"dim", "", "256", "largest dimension in voxel units of the mesh bbox (defaults to 256). If \"vdb\" or \"voxel\" is defined then \"dim\" is ignored"}, |
|
0 commit comments