74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
#include "dl_graphics.h"
|
|
|
|
#include "vk/dl_vk.h"
|
|
#include "math/dl_coor.h"
|
|
|
|
namespace dl
|
|
{
|
|
|
|
|
|
|
|
// 汉
|
|
void Graphics::Dot(const Position3& p)
|
|
{
|
|
std::array<VertexGfx, 1> v;
|
|
v[0]._pos = toShorter(_mat * toLonger(p, 1.0_f));
|
|
v[0]._color = _col[0];
|
|
|
|
g_vk->GfxPushDot(v[0]);
|
|
}
|
|
|
|
void Graphics::Line(const Position3& p0, const Position3& p1)
|
|
{
|
|
std::array<VertexGfx, 2> v;
|
|
v[0]._pos = toShorter(_mat * toLonger(p0, 1.0_f));
|
|
v[1]._pos = toShorter(_mat * toLonger(p1, 1.0_f));
|
|
v[0]._color = _col[0];
|
|
v[1]._color = _col[1];
|
|
|
|
g_vk->GfxPushLine(v[0], v[1]);
|
|
}
|
|
|
|
void Graphics::Triangle(const Position3& p0, const Position3& p1, const Position3& p2)
|
|
{
|
|
std::array<VertexGfx, 2> v;
|
|
v[0]._pos = toShorter(_mat * toLonger(p0, 1.0_f));
|
|
v[1]._pos = toShorter(_mat * toLonger(p1, 1.0_f));
|
|
v[2]._pos = toShorter(_mat * toLonger(p2, 1.0_f));
|
|
v[0]._color = _col[0];
|
|
v[1]._color = _col[1];
|
|
v[2]._color = _col[2];
|
|
g_vk->GfxPushTriangle(v[0], v[1], v[2]);
|
|
}
|
|
|
|
void Graphics::TriangleSolid(const Position3& p0, const Position3& p1, const Position3& p2)
|
|
{
|
|
std::array<VertexGfx, 2> v;
|
|
v[0]._pos = toShorter(_mat * toLonger(p0, 1.0_f));
|
|
v[1]._pos = toShorter(_mat * toLonger(p1, 1.0_f));
|
|
v[2]._pos = toShorter(_mat * toLonger(p2, 1.0_f));
|
|
v[0]._color = _col[0];
|
|
v[1]._color = _col[1];
|
|
v[2]._color = _col[2];
|
|
g_vk->GfxPushTriangleSolid(v[0], v[1], v[2]);
|
|
}
|
|
|
|
void Graphics::RenderCoor(Coor* coor)
|
|
{
|
|
SetMatrix(coor);
|
|
|
|
Line({}, { 1, 0, 0 });
|
|
Line({}, { 0, 1, 0 });
|
|
}
|
|
|
|
void Graphics::SetMatrix(Coor* coor)
|
|
{
|
|
Matrix4 m_t = Mat::CreateTranslation(toLonger(coor->GetPosition()));
|
|
Matrix4 m_r = Mat::CreateRotation({ 0, 0, 1 }, coor->GetRotate());
|
|
Matrix4 m_s = Mat::CreateScaling(toLonger(coor->GetPosition(), 1.0_f));
|
|
_mat = m_t * m_r * m_s;
|
|
}
|
|
|
|
}
|
|
|