2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
|
|
|
|
2019-09-29 02:22:12 +00:00
|
|
|
#include <array>
|
|
|
|
|
2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
//#include <hecl/Pipeline.hpp>
|
2019-09-29 00:30:53 +00:00
|
|
|
#include <zeus/CAABox.hpp>
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
|
|
|
//static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
2018-10-07 02:59:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAABoxShader::Initialize() {
|
2022-02-01 00:06:54 +00:00
|
|
|
// s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
|
|
|
|
// s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
|
2018-10-07 02:59:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAABoxShader::Shutdown() {
|
2022-02-01 00:06:54 +00:00
|
|
|
// s_Pipeline.reset();
|
|
|
|
// s_zOnlyPipeline.reset();
|
2018-10-07 02:59:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAABoxShader::CAABoxShader(bool zOnly) {
|
2022-02-01 00:06:54 +00:00
|
|
|
// CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
|
|
|
|
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
|
|
|
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
|
|
|
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
|
|
|
|
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
|
|
|
|
// m_dataBind =
|
|
|
|
// ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
|
|
|
|
// bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
|
|
|
// return true;
|
|
|
|
// } BooTrace);
|
2017-09-03 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
2019-09-29 02:22:12 +00:00
|
|
|
const std::array<zeus::CVector3f, 34> vboData{{
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()}, {aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
|
|
|
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.min.x(), aabb.max.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.min.x(), aabb.max.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
|
|
|
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
|
|
|
{aabb.min.x(), aabb.min.y(), aabb.max.z()}, {aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
|
|
|
{aabb.max.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
|
|
|
{aabb.max.x(), aabb.min.y(), aabb.max.z()}, {aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.min.x(), aabb.min.y(), aabb.max.z()}, {aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
|
|
|
{aabb.max.x(), aabb.min.y(), aabb.max.z()}, {aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
|
|
|
{aabb.max.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
|
|
|
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
2019-09-29 02:22:12 +00:00
|
|
|
}};
|
2017-09-03 05:53:38 +00:00
|
|
|
|
2022-02-01 00:06:54 +00:00
|
|
|
// m_vbo->load(vboData.data(), sizeof(vboData));
|
2017-09-03 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAABoxShader::draw(const zeus::CColor& color) {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CAABoxShader::draw", zeus::skMagenta);
|
|
|
|
|
2022-03-05 23:30:30 +00:00
|
|
|
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(/*true*/) * CGraphics::g_GXModelView.toMatrix4f();
|
2018-12-08 05:30:43 +00:00
|
|
|
m_uniform.m_color = color;
|
2022-02-01 00:06:54 +00:00
|
|
|
// m_uniBuf->load(&m_uniform, sizeof(Uniform));
|
|
|
|
//
|
|
|
|
// CGraphics::SetShaderDataBinding(m_dataBind);
|
|
|
|
// CGraphics::DrawArray(0, 34);
|
2017-09-03 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|