#pragma once #include "hecl/SystemChar.hpp" #include "hecl/HMDLMeta.hpp" #include "zeus/CColor.hpp" #include "zeus/CMatrix4f.hpp" #include "zeus/CAABox.hpp" typedef void (*FPercent)(float); enum class EPVSVisSetState { EndOfTree, NodeFound, OutOfBounds }; class VISIRenderer { friend struct VISIBuilder; public: struct Model { hecl::HMDLTopology topology; zeus::CAABox aabb; struct Vert { zeus::CVector3f pos; zeus::CColor color; }; std::vector verts; std::vector idxs; struct Surface { uint32_t first; uint32_t count; bool transparent; }; std::vector surfaces; }; struct Entity { uint32_t entityId; zeus::CAABox aabb; }; struct Light { zeus::CVector3f point; }; protected: int m_argc; const hecl::SystemChar** m_argv; int m_return = 0; zeus::CAABox m_totalAABB; virtual bool SetupShaders() = 0; std::vector m_models; std::vector m_entities; std::vector m_lights; virtual bool SetupVertexBuffersAndFormats() = 0; virtual void SetupRenderPass(const zeus::CVector3f& pos) = 0; FPercent m_updatePercent; public: bool m_terminate = false; struct RGBA8 { uint8_t r; uint8_t g; uint8_t b; uint8_t a; }; VISIRenderer(int argc, const hecl::SystemChar** argv) : m_argc(argc), m_argv(argv) {} virtual void Run(FPercent updatePercent); void Terminate(); virtual void RenderPVSOpaque(RGBA8* bufOut, bool& needTransparent) = 0; virtual void RenderPVSTransparent(const std::function& passFunc) = 0; virtual void RenderPVSEntitiesAndLights(const std::function& passFunc, const std::function& lightPassFunc) = 0; int ReturnVal() const { return m_return; } static std::vector AABBToVerts(const zeus::CAABox& aabb, const zeus::CColor& color); static zeus::CColor ColorForIndex(uint32_t i); static void* makePNGBuffer(unsigned char* rgba, int width, int height, size_t* outsize); };