Skip to content
Discussion options

You must be logged in to vote

I tested it an it works. I added Color and kept the position vector the same.

Vector used as position "x", "y", "z"

#pragma once
#include <glm/glm.hpp>
#include <nlohmann/json.hpp>

namespace glm {
inline void to_json(nlohmann::json &j, const vec3 &vec) { j = nlohmann::json{{"x", vec.x}, {"y", vec.y}, {"z", vec.z}}; }

inline void from_json(const nlohmann::json &j, vec3 &vec) {
    j.at("x").get_to(vec.x);
    j.at("y").get_to(vec.y);
    j.at("z").get_to(vec.z);
}
} // namespace glm

Vector used as color "r", "g", "b"

#pragma once
#include <glm/glm.hpp>
#include <nlohmann/json.hpp>

class Color : public glm::vec3 {
  public:
    using glm::vec3::vec3;

    template <typename V> Color(const

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@4Source
Comment options

@gregmarr
Comment options

@4Source
Comment options

@4Source
Comment options

Answer selected by 4Source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants