59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include "model.hpp"
|
|
//#include "audio.hpp"
|
|
#include "window.hpp"
|
|
#include "tsr.hpp"
|
|
|
|
namespace TSR {
|
|
|
|
class WorldMap {
|
|
// general
|
|
std::string m_map_path;
|
|
|
|
// loading
|
|
enum class LoadingPhase {
|
|
FIRST,
|
|
PARSE,
|
|
MODELS,
|
|
FINISHED,
|
|
} m_loading_phase;
|
|
|
|
struct ModelInstances {
|
|
std::vector<BasicDrawCtx> m_contexts;
|
|
};
|
|
|
|
using LoadingObjData = std::map<std::string, ModelInstances>;
|
|
|
|
LoadingObjData m_loading_obj_data;
|
|
LoadingObjData::const_iterator m_loading_iter;
|
|
int m_loaded_models;
|
|
|
|
// final
|
|
struct MapObject {
|
|
DrawCtx m_ctx;
|
|
AssetPtr<Model> m_model;
|
|
};
|
|
|
|
std::vector<MapObject> m_objects;
|
|
std::vector<MapObject> m_objects_instanced;
|
|
|
|
public:
|
|
WorldMap(const std::string& map_path);
|
|
|
|
bool Loaded() const { return m_loading_phase == LoadingPhase::FINISHED; }
|
|
const std::string& Name() { return m_map_path; }
|
|
|
|
int LoadNext();
|
|
|
|
void Draw(Renderer& r) const {
|
|
for (const auto& obj : m_objects)
|
|
obj.m_model->Draw(r, &obj.m_ctx);
|
|
|
|
for (const auto& obj : m_objects_instanced)
|
|
obj.m_model->DrawInstanced(r, &obj.m_ctx);
|
|
}
|
|
};
|
|
|
|
|
|
} |