1#ifndef DANDELION_UTILS_JSON_SERIALIZE_HPP
2#define DANDELION_UTILS_JSON_SERIALIZE_HPP
4#include <nlohmann/json.hpp>
5#include <spdlog/spdlog.h>
28template<
typename T,
int Rows,
int Cols>
29void to_json(json& j,
const Matrix<T, Rows, Cols>& m)
31 std::vector<T> flat_data(m.data(), m.data() + m.size());
35template<
typename T,
int Rows,
int Cols>
36void from_json(
const json& j, Matrix<T, Rows, Cols>& m)
38 if ((
size_t)j.size() != (
size_t)m.size()) {
39 spdlog::error(
"JSON array size does not match matrix size.");
42 std::vector<T> flat_data = j.get<std::vector<T>>();
45 m = Eigen::Map<const Matrix<T, Rows, Cols>>(flat_data.data());
51void to_json(json& j,
const Object& o);
52void from_json(
const json& j,
Object& o);
55void to_json(json& j,
const Camera& c);
56void from_json(
const json& j,
Camera& c);
59void to_json(json& j,
const Light& l);
60void from_json(
const json& j,
Light& l);
表示观察点的相机,既可以用于预览视角,也可以用于渲染视角。
定义 camera.h:24