Acheron
Loading...
Searching...
No Matches
basic.hpp
1#pragma once
2
3#include "matrix4.hpp"
4#include <array>
5#include <cstdint>
6
7namespace acheron {
11 struct Color {
12 std::uint8_t r, g, b, a;
13
14 constexpr Color() : r(0), g(0), b(0), a(255) {}
15 constexpr Color(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a) : r(r), g(g), b(b), a(a) {}
16 constexpr Color(std::uint32_t hex) {
17 r = (hex & 0xff000000) >> 24;
18 g = (hex & 0x00ff0000) >> 16;
19 b = (hex & 0x0000ff00) >> 8;
20 a = (hex & 0x000000ff) >> 0;
21 }
22
23 std::array<float,4> toFloat() const {
24 return { r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f };
25 }
26 };
27
31 struct Vector3 {
32 float x, y, z;
33 };
34
38 struct Vector2 {
39 float x, y;
40 };
41
45 struct Transform2D {
46 Vector2 position{0.0f, 0.0f};
47 float rotation{0.0f};
48 Vector2 scale{1.0f, 1.0f};
49
50 Matrix4 ToMatrix4() const {
51 return Matrix4::Translate(position.x, position.y, 0) *
52 Matrix4::RotateZ(rotation) *
53 Matrix4::Scale(scale.x, scale.y, 1);
54 }
55 };
56
60 struct Transform3D {
61 // TODO NOT IMPLIMENTED
62 };
63};
Transform2D struct for representing where an entity is in 2D space.
Definition basic.hpp:45
3D transform, TODO: impliment
Definition basic.hpp:60
2D Vector struct
Definition basic.hpp:38
3D Vector struct
Definition basic.hpp:31