diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-08 12:00:45 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-08 12:00:45 +0100 |
commit | 9acf4738b15738cb2b9646481b75ba0c05a01e78 (patch) | |
tree | d8a8ce5007ea77f86d33136cdfa014e45d31d72b /draw/quad.cpp | |
parent | a083f5c2124a6a907727b35a5c43d8175d396d73 (diff) |
draw, editor: visualize bounding boxes
Diffstat (limited to 'draw/quad.cpp')
-rw-r--r-- | draw/quad.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/draw/quad.cpp b/draw/quad.cpp new file mode 100644 index 00000000..d7be52f2 --- /dev/null +++ b/draw/quad.cpp @@ -0,0 +1,30 @@ +#include "quad.hpp" +#include "wireframe.hpp" +#include <Magnum/GL/Renderer.h> + +namespace floormat::wireframe { + +quad::quad(Vector3 center, Vector2 size, float line_width) : + center{center}, size{size}, line_width{line_width} +{} + +quad::vertex_array quad::make_vertex_array() const +{ + const auto Sx = size[0]*.5f, Sy = size[1]*.5f; + const auto Cx_0 = center[0] - Sx, Cx_1 = center[0] + Sx; + const auto Cy_0 = center[1] - Sy, Cy_1 = center[1] + Sy; + const auto Cz = center[2] + 0; + return {{ + { Cx_0, Cy_0, Cz }, + { Cx_1, Cy_0, Cz }, + { Cx_1, Cy_1, Cz }, + { Cx_0, Cy_1, Cz }, + }}; +} + +void quad::on_draw() const +{ + mesh_base::set_line_width(line_width); +} + +} // namespace floormat::wireframe |