Brunot
Loading...
Searching...
No Matches
Line.h
Go to the documentation of this file.
1// File: Line.h
2// Description: A class to represent a line, via 2 points, and a color. designed for DebugDraw system, but can
3// have functionality aside from that
4// Author(s): Aidan Hartman (aidan.hartman@digipen.edu)
5// 2025 / 11 / 06
6// (C) Digipen 2025
7// Line.h
8// ____ __ __ __
9// /\__ _\/\ \ /\ \/\ \
10// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
11// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
12// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
13// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
14// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
15
16#pragma once
19
20// namespace gfx
21// {
22// struct Vertex;
23// }
24
25#include "Graphics/Vertex.h"
26#include <Utility>
27
28
29class Line
30{
31public:
32 Line(Vector4D p1, Vector4D p2, Vector4D color = {1.0f, 0.0f, 0.0f, 1.0f})
33 : _p1(std::move(p1))
34 , _p2(std::move(p2))
35 , _color(std::move(color))
36 {
37
38 }
39
40 Line(std::pair<float, float> p1, std::pair<float, float> p2, Vector4D color = {1.0f, 0.f, 0.f, 1.f})
41 : _p1(p1.first, p1.second, 0.f, 1.f)
42 , _p2(p2.first, p2.second, 0.f, 1.f)
43 , _color(std::move(color))
44 {
45
46 }
47
48 Line(const Line& other) = default;
49 Line(Line&& other) noexcept = default;
50 auto operator=(const Line& other) -> Line& = default;
51 auto operator=(Line&& other) noexcept -> Line& = default;
55 explicit operator std::pair<gfx::Vertex, gfx::Vertex>() const;
56
57 [[nodiscard]] auto p1() const -> const Vector4D&;
58 auto p1(const Vector4D& p1) -> void;
59 [[nodiscard]] auto p2() const -> const Vector4D&;
60 auto p2(const Vector4D& p2) -> void;
61 [[nodiscard]] auto color() const -> const Vector4D&;
62 auto color(const Vector4D& color) -> void;
63
64 friend auto operator*(const AffineMatrix& transform, const Line& line) -> Line;
65 friend auto operator*=(Line& line, const AffineMatrix& transform) -> Line&;
66
67private:
68 Vector4D _p1{0.f, 0.f, 0.f, 1.f};
69 Vector4D _p2{0.f, 0.f, 0.f, 1.f};
70 Vector4D _color{1.0f, 0.0f, 0.0f, 1.0f};
71};
A struct for stroing vertexes and handing them to opengl.
auto color() const -> const Vector4D &
Definition Line.cpp:57
auto operator=(const Line &other) -> Line &=default
Vector4D _p2
Definition Line.h:69
Line(const Line &other)=default
auto p1() const -> const Vector4D &
Definition Line.cpp:37
auto p2() const -> const Vector4D &
Definition Line.cpp:47
Line(Vector4D p1, Vector4D p2, Vector4D color={1.0f, 0.0f, 0.0f, 1.0f})
Definition Line.h:32
auto operator=(Line &&other) noexcept -> Line &=default
Line(std::pair< float, float > p1, std::pair< float, float > p2, Vector4D color={1.0f, 0.f, 0.f, 1.f})
Definition Line.h:40
Vector4D _color
Definition Line.h:70
Vector4D _p1
Definition Line.h:68
Line(Line &&other) noexcept=default
Definition AffineMatrix.h:30
Definition Vector4D.h:23