MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VDBWriter.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::IO {
6
7/**
8 * @class VDBWriter
9 * @brief VolumeWriter implementation backed by tinyvdb.
10 *
11 * Writes one .vdb per call, carrying every field of the supplied
12 * VolumeData as a separately named grid in that single file. Scalar
13 * fields become float grids, vector fields become vec3s grids. Values
14 * below the activity threshold are left inactive and take the background
15 * value, which is what makes the output sparse and therefore worth being
16 * a .vdb rather than a raw dump.
17 *
18 * The lattice becomes a linear transform: scale by cell_size(), then
19 * translate by bounds.min plus half a cell, so index (i,j,k) maps to the
20 * world position Lattice3D::cell_center reports for it.
21 *
22 * LatticeSemantics maps directly. LatticeValueClass corresponds to
23 * OpenVDB's GridClass and VectorVariance to its VecType, both one to one,
24 * so a field declared as a fog volume or a contravariant velocity arrives
25 * in Houdini, Blender or Maya resampling correctly rather than by
26 * coincidence.
27 *
28 * No time dimension: an animated sequence is a sequence of calls with
29 * numbered paths, which is how every consumer of .vdb expects to find one.
30 *
31 * Options honored:
32 * - VolumeWriteOptions::activity_threshold : global inactive cutoff
33 * - VolumeWriteOptions::field_thresholds : per-field override
34 * - VolumeWriteOptions::background : value of inactive cells
35 * - VolumeWriteOptions::half_float : store values at half precision
36 * - VolumeWriteOptions::compression : -1 selects the default
37 */
38class MAYAFLUX_API VDBWriter : public VolumeWriter {
39public:
40 VDBWriter() = default;
41 ~VDBWriter() override = default;
42
43 [[nodiscard]] bool can_write(const std::string& filepath) const override;
44
45 bool write(
46 const std::string& filepath,
47 const Kakshya::VolumeData& data,
48 const VolumeWriteOptions& options = {}) override;
49
50 [[nodiscard]] std::vector<std::string> get_supported_extensions() const override;
51 [[nodiscard]] std::string get_last_error() const override { return m_last_error; }
52
53 /**
54 * @brief Register this writer with the VolumeWriterRegistry.
55 *
56 * Called from engine/subsystem init alongside the image writers.
57 * Idempotent.
58 */
59 static void register_with_registry();
60
61private:
62 mutable std::string m_last_error;
63};
64
65} // namespace MayaFlux::IO
~VDBWriter() override=default
std::string get_last_error() const override
Last error message or empty string.
Definition VDBWriter.hpp:51
VolumeWriter implementation backed by tinyvdb.
Definition VDBWriter.hpp:38
Abstract base for volumetric format writers.
Configuration for volume writing.
A lattice and every field sampled over it, held in host memory.