2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-02-24 08:28:44 +00:00
|
|
|
|
|
|
|
#include "boo/graphicsdev/glew.h"
|
|
|
|
#include "zeus/CColor.hpp"
|
|
|
|
#include "zeus/CMatrix4f.hpp"
|
|
|
|
#include "zeus/CAABox.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
typedef void (*FPercent)(float);
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EPVSVisSetState { EndOfTree, NodeFound, OutOfBounds };
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class VISIRenderer {
|
|
|
|
friend struct VISIBuilder;
|
|
|
|
|
|
|
|
int m_argc;
|
2021-06-30 18:20:45 +00:00
|
|
|
char** m_argv;
|
2018-12-08 05:30:43 +00:00
|
|
|
int m_return = 0;
|
|
|
|
|
|
|
|
zeus::CAABox m_totalAABB;
|
|
|
|
|
|
|
|
struct UniformBuffer {
|
|
|
|
zeus::CMatrix4f m_xf;
|
|
|
|
} m_uniformBuffer;
|
|
|
|
|
|
|
|
struct Model {
|
|
|
|
GLenum topology;
|
|
|
|
zeus::CAABox aabb;
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct Vert {
|
|
|
|
zeus::CVector3f pos;
|
|
|
|
zeus::CColor color;
|
2017-02-24 08:28:44 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<Vert> verts;
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<uint32_t> idxs;
|
|
|
|
GLuint vbo, ibo, vao;
|
|
|
|
|
|
|
|
struct Surface {
|
|
|
|
uint32_t first;
|
|
|
|
uint32_t count;
|
|
|
|
bool transparent;
|
2017-02-24 08:28:44 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<Surface> surfaces;
|
|
|
|
};
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct Entity {
|
|
|
|
uint32_t entityId;
|
|
|
|
zeus::CAABox aabb;
|
|
|
|
GLuint vbo, vao;
|
|
|
|
};
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct Light {
|
|
|
|
zeus::CVector3f point;
|
|
|
|
GLuint vbo, vao;
|
|
|
|
};
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
GLuint m_vtxShader, m_fragShader, m_program, m_uniLoc;
|
|
|
|
GLuint m_uniformBufferGL;
|
|
|
|
GLuint m_aabbIBO;
|
|
|
|
bool SetupShaders();
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<Model> m_models;
|
|
|
|
std::vector<Entity> m_entities;
|
|
|
|
std::vector<Light> m_lights;
|
|
|
|
bool SetupVertexBuffersAndFormats();
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t m_queryCount;
|
|
|
|
std::unique_ptr<GLuint[]> m_queries;
|
|
|
|
std::unique_ptr<bool[]> m_queryBools;
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
FPercent m_updatePercent;
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static std::vector<Model::Vert> AABBToVerts(const zeus::CAABox& aabb, const zeus::CColor& color);
|
2017-02-24 08:28:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
bool m_terminate = false;
|
|
|
|
struct RGBA8 {
|
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
|
|
|
uint8_t a;
|
|
|
|
};
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
VISIRenderer(int argc, char** argv) : m_argc(argc), m_argv(argv) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
void Run(FPercent updatePercent);
|
|
|
|
void Terminate();
|
|
|
|
void RenderPVSOpaque(RGBA8* bufOut, const zeus::CVector3f& pos, bool& needTransparent);
|
|
|
|
void RenderPVSTransparent(const std::function<void(int)>& passFunc, const zeus::CVector3f& pos);
|
|
|
|
void RenderPVSEntitiesAndLights(const std::function<void(int)>& passFunc,
|
|
|
|
const std::function<void(int, EPVSVisSetState)>& lightPassFunc,
|
|
|
|
const zeus::CVector3f& pos);
|
|
|
|
int ReturnVal() const { return m_return; }
|
|
|
|
};
|