2017-09-03 05:53:38 +00:00
|
|
|
#include "CAABoxShader.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CAABoxShader::CAABoxShader(bool zOnly)
|
|
|
|
: m_zOnly(zOnly)
|
|
|
|
{
|
2018-05-20 06:14:57 +00:00
|
|
|
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
2017-09-03 05:53:38 +00:00
|
|
|
{
|
|
|
|
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
|
|
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
|
|
|
m_dataBind = TShader<CAABoxShader>::BuildShaderDataBinding(ctx, *this);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void CAABoxShader::setAABB(const zeus::CAABox& aabb)
|
|
|
|
{
|
|
|
|
zeus::CVector3f vboData[] =
|
|
|
|
{
|
|
|
|
{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},
|
|
|
|
|
|
|
|
{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},
|
|
|
|
|
|
|
|
{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},
|
|
|
|
|
|
|
|
{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},
|
|
|
|
|
|
|
|
{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},
|
|
|
|
|
|
|
|
{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},
|
|
|
|
};
|
|
|
|
|
|
|
|
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CAABoxShader::draw(const zeus::CColor& color)
|
|
|
|
{
|
|
|
|
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
|
|
|
m_uniform.m_color = color;
|
|
|
|
m_uniBuf->load(&m_uniform, sizeof(Uniform));
|
|
|
|
|
2017-11-05 06:17:12 +00:00
|
|
|
CGraphics::SetShaderDataBinding(m_dataBind);
|
|
|
|
CGraphics::DrawArray(0, 34);
|
2017-09-03 05:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
URDE_SPECIALIZE_SHADER(CAABoxShader)
|
|
|
|
|
|
|
|
}
|