5static glm::mat4 getRotationMatrix(glm::vec3 newRot) {
6 float radX = glm::radians(newRot.x);
7 float radY = glm::radians(newRot.y);
8 float radZ = glm::radians(newRot.z);
10 glm::mat4 rotationX = glm::rotate(glm::mat4(1.0f), radX, glm::vec3(1.0f, 0.0f, 0.0f));
11 glm::mat4 rotationY = glm::rotate(glm::mat4(1.0f), radY, glm::vec3(0.0f, 1.0f, 0.0f));
12 glm::mat4 rotationZ = glm::rotate(glm::mat4(1.0f), radZ, glm::vec3(0.0f, 0.0f, 1.0f));
14 glm::mat4 rotationMatrix = rotationZ * rotationY * rotationX;
15 return rotationMatrix;
18static glm::vec2 rotatePoint(
float x,
float y,
float centerX,
float centerY,
float radians) {
19 float dx = x - centerX;
20 float dy = y - centerY;
22 centerX + dx * cos(radians) - dy * sin(radians),
23 centerY + dx * sin(radians) + dy * cos(radians)
26static glm::vec2 rotatePoint(
float x,
float y,
float radians) {
27 return rotatePoint(x, y, 0.0f, 0.0f, radians);
34namespace TazGraphEngine {
36 using Position = glm::vec3;
37 using Size = glm::vec3;
38 using Rotation = glm::vec3;
40 using Normal = glm::vec3;
45 Color() : r(0), g(0), b(0), a(0) {}
46 Color(GLubyte R, GLubyte G, GLubyte B, GLubyte A) : r(R), g(G), b(B), a(A) {}
48 glm::vec4 toVec4()
const {
49 return glm::vec4(r, g, b, a) / 255.0f;
52 static Color fromVec4(
const glm::vec4& v) {
54 static_cast<GLubyte
>(v.r * 255.0f),
55 static_cast<GLubyte
>(v.g * 255.0f),
56 static_cast<GLubyte
>(v.b * 255.0f),
57 static_cast<GLubyte
>(v.a * 255.0f)
66 Color operator*(
float scalar)
const {
67 return Color(
static_cast<GLubyte
>(r * scalar),
68 static_cast<GLubyte
>(g * scalar),
69 static_cast<GLubyte
>(b * scalar),
70 static_cast<GLubyte
>(a * scalar));
75 return Color(
static_cast<GLubyte
>(r + other.r),
76 static_cast<GLubyte
>(g + other.g),
77 static_cast<GLubyte
>(b + other.b),
78 static_cast<GLubyte
>(a + other.a));
81 bool operator==(
const Color& other)
const {
82 return r == other.r && g == other.g && b == other.b && a == other.a;
88 Position position = Position(0);
90 inline void setPosition(Position m_position) {
91 position = m_position;
101 void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
110 Normal normal = Normal();
118 inline void setUV(UV m_uv) {
125using TazPosition = TazGraphEngine::Position;
126using TazSize = TazGraphEngine::Size;
127using TazRotation = TazGraphEngine::Rotation;
128using TazUV = TazGraphEngine::UV;
129using TazNormal = TazGraphEngine::Normal;