visual_catalog.h 848 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <QString>
  3. #include <QVector3D>
  4. #include <string>
  5. #include <unordered_map>
  6. namespace Engine::Core {
  7. class RenderableComponent;
  8. }
  9. namespace Game::Visuals {
  10. struct VisualDef {
  11. enum class MeshKind { None, Quad, Plane, Cube, Capsule, Ring };
  12. MeshKind mesh = MeshKind::Cube;
  13. QVector3D color{1.0F, 1.0F, 1.0F};
  14. QString texture;
  15. };
  16. class VisualCatalog {
  17. public:
  18. auto loadFromJsonFile(const QString &path,
  19. QString *out_error = nullptr) -> bool;
  20. auto lookup(const std::string &unitType, VisualDef &out) const -> bool;
  21. private:
  22. std::unordered_map<std::string, VisualDef> m_units;
  23. };
  24. auto meshKindFromString(const QString &s) -> VisualDef::MeshKind;
  25. void apply_to_renderable(const VisualDef &def,
  26. Engine::Core::RenderableComponent &r);
  27. } // namespace Game::Visuals