added load from json game objects

This commit is contained in:
Vlad committed 2026-04-07 20:17:04 +06:00
1 parent 178f69967b
commit e1b491be73
6 files changed
+242 -3

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#pragma once
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include "external/nlohmann/json.hpp"
#include "TextModel.h"
namespace ZL {
struct Texture;
struct VertexRenderStruct;
class Renderer;
struct GameObjectData {
std::string name;
std::string texturePath;
std::string meshPath;
float rotationX = 0.0f;
float rotationY = 0.0f;
float rotationZ = 0.0f;
float positionX = 0.0f;
float positionY = 0.0f;
float positionZ = 0.0f;
float scale = 1.0f;
};
struct LoadedGameObject {
std::shared_ptr<Texture> texture;
VertexRenderStruct mesh;
std::string name;
};
class GameObjectLoader {
public:
static std::vector<GameObjectData> loadFromJson(const std::string& jsonPath, const std::string& zipPath = "");
static std::unordered_map<std::string, LoadedGameObject> loadAndCreateGameObjects(
const std::string& jsonPath,
Renderer& renderer,
const std::string& zipPath = ""
);
};
} // namespace ZL