shadow-over-bishkek001/src/items/GameObjectLoader.h
2026-04-07 20:17:04 +06:00

45 lines
980 B
C++

#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